aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: d912aadbc23ebad9218eec052d1a3b393384cb1c (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
CFLAGS = -std=c99 -pedantic -Wall -fPIC
CPPFLAGS = -D_XOPEN_SOURCE=700

ifneq ($(DEBUG), 1)
	CFLAGS += -O2
	CPPFLAGS += -DNDEBUG
else
	CFLAGS += -g
	CPPFLAGS += -DDEBUG
endif

CHECK_CFLAGS = $(shell pkg-config check --cflags)
CHECK_LDLIBS = $(shell pkg-config check --libs)
CURL_LDLIBS = -lcurl
EXPAT_LDLIBS = -lexpat

VERSION = "0.1.0"

.PHONY: all check clean doc memcheck

all: libdbfp.so

check: libdbfp.so dbfp_check
	LD_LIBRARY_PATH=. ./dbfp_check

clean:
	$(RM) libdbfp.so
	$(RM) dbfp_check
	$(RM) dbfp.o dbfp_check.o

doc: man/dbfp_close.3 man/dbfp_init.3 man/dbfp_departure_close.3 man/dbfp_location_close.3 man/dbfp_query_departure.3 man/dbfp_query_location.3

memcheck: libdbfp.so dbfp_check
	LD_LIBRARY_PATH=. CK_FORK=no valgrind --tool=memcheck ./dbfp_check

man/dbfp_close.3: man/dbfp_close.pod
	pod2man -c "DB timetable API" -n "DBFP_CLOSE" -r $(VERSION) -s 3 $^ > $@

man/dbfp_departure_close.3: man/dbfp_departure_close.pod
	pod2man -c "DB timetable API" -n "DBFP_DEPARTURE_CLOSE" -r $(VERSION) -s 3 $^ > $@

man/dbfp_init.3: man/dbfp_init.pod
	pod2man -c "DB timetable API" -n "DBFP_INIT" -r $(VERSION) -s 3 $^ > $@

man/dbfp_location_close.3: man/dbfp_location_close.pod
	pod2man -c "DB timetable API" -n "DBFP_LOCATION_CLOSE" -r $(VERSION) -s 3 $^ > $@

man/dbfp_query_departure.3: man/dbfp_query_departure.pod
	pod2man -c "DB timetable API" -n "DBFP_QUERY_DEPARTURE" -r $(VERSION) -s 3 $^ > $@

man/dbfp_query_location.3: man/dbfp_query_location.pod
	pod2man -c "DB timetable API" -n "DBFP_QUERY_LOCATION" -r $(VERSION) -s 3 $^ > $@

libdbfp.so: LDFLAGS += -shared
libdbfp.so: LDLIBS += $(CURL_LDLIBS)
libdbfp.so: LDLIBS += $(EXPAT_LDLIBS)
libdbfp.so: dbfp.o
	$(CC) $(LDFLAGS) -o $@ $^ $(LDLIBS)

dbfp_check: LDLIBS += $(CHECK_LDLIBS)
dbfp_check: LDLIBS += -ldbfp -L.
dbfp_check: dbfp_check.o

dbfp.o: dbfp.c dbfp.h

dbfp_check.o: CFLAGS += $(CHECK_CFLAGS)
dbfp_check.o: dbfp_check.c dbfp.h dbfp.c