summaryrefslogtreecommitdiff
path: root/example/Makefile
blob: 55778dfc82b5f99665196f2a31f6bda5a7f028c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
.PHONY: clean

VERSION = $(shell cat ../VERSION)


GCC = /usr/bin/gcc
FLAGS = -g -Wall
DEPS = foo.h bar.h
OBJ = foo.o bar.o main.o
LIBS = /usr/lib/libprom.so /usr/lib/libpromhttp.so

PROM_DEB_PACKAGE = ../prom/libprom-dev-${VERSION}-Linux.deb
PROM_TGZ_PACKAGE = ../prom/libprom-dev-${VERSION}-Linux.tar.gz

PROMHTTP_DEB_PACKAGE = ../promhttp/libpromhttp-dev-${VERSION}-Linux.deb
PROMHTTP_TGZ_PACKAGE = ../promhttp/libpromhttp-dev-${VERSION}-Linux.tar.gz

example: ${OBJ} ${LIBS}
	gcc -g -o $@ ${FLAGS} -O1 -pthread ${OBJ} -lprom -lpromhttp -lmicrohttpd

${PROM_DEB_PACKAGE}:
	cd .. && ./auto build && ./auto package

${PROMHTTP_DEB_PACKAGE}:
	cd .. && ./auto build && ./auto package

/usr/lib/libprom.so: ${PROM_DEB_PACKAGE}
	dpkg -i ${PROM_DEB_PACKAGE}

/usr/lib/libpromhttp.so: ${PROMHTTP_DEB_PACKAGE}
	dpkg -i ${PROMHTTP_DEB_PACKAGE}

%.o: %.c ${PROM_DEB_PACKAGE} ${PROMHTTP_DEB_PACKAGE} ${LIBS} ${DEPS}
	${GCC} ${FLAGS} -c $< -o $@

clean:
	-rm ${OBJ} example ${PROM_DEB_PACKAGE} ${PROM_TGZ_PACKAGE} ${PROMHTTP_DEB_PACKAGE} ${PROMHTTP_TGZ_PACKAGE}
	-dpkg -r libprom-dev
	-dpkg -r libpromhttp-dev