-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (106 loc) · 4.33 KB
/
Makefile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
CFLAGS=
CFLAGS+=-O
#CFLAGS+=-g
#CFLAGS+=-pg
CFLAGS+=-fPIC
LDFLAGS=
#LDFLAGS+=-pg
#VALGRIND=valgrind --leak-check=full
.PHONY: all
all: doc run_examples
.PHONY: help
help:
@echo "Use one of those prerequisites: run_examples (default), libs, qsip_wc_test, fuzzyword, intensive, timers, callgraph, cloc, doc or <language>/LC_MESSAGES/libwqm.mo"
#### Examples
.PHONY: run_examples
run_examples: qsip_wc_test fuzzyword intensive timers
.PHONY: qsip_wc_test
qsip_wc_test: libs examples/qsip/qsip_wc_test
@echo "********* $@ ************"
cd examples/qsip ; LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../.. $(VALGRIND) ./qsip_wc_test
@echo "*********************"
.PHONY: fuzzyword
fuzzyword: libs examples/fuzzyword/fuzzyword
@echo "********* $@ ************"
cd examples/fuzzyword ; LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:../.. ./fuzzyword \
premir ministr constitutiotn arlmée républiqeu plaine pouvoit résrevé apanache finances dépenser contgaint paliatiff constitutionnaliseraint
@echo "*********************"
.PHONY: intensive
intensive: libs examples/intensive/intensive
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. ./examples/intensive/intensive
@echo "*********************"
.PHONY: timers
timers: libs examples/timers/timers
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. ./examples/timers/timers
@echo "*********************"
examples/qsip/qsip_wc_test: LDFLAGS+=-L.
examples/qsip/qsip_wc_test: LDLIBS=-lwqm -ltimer -lmap -lm
examples/qsip/qsip_wc_test: examples/qsip/qsip_wc_test.o examples/qsip/qsip_wc.o
#examples/qsip/qsip_wc_test.o: CPPFLAGS+=-DSIZE=100 -DTIMES=10 # for valgrind or gdb
examples/qsip/qsip_wc_test.o: CFLAGS+=-std=c23
examples/qsip/qsip_wc_test.o: CPPFLAGS+=-I.
examples/qsip/qsip_wc.o: CFLAGS+=-std=c23
examples/qsip/qsip_wc.o: CPPFLAGS+=-I.
examples/fuzzyword/fuzzyword: CFLAGS+=-std=c23
examples/fuzzyword/fuzzyword: CPPFLAGS+=-DCOLLATE
examples/fuzzyword/fuzzyword: CPPFLAGS+=-I.
examples/fuzzyword/fuzzyword: LDFLAGS+=-L.
examples/fuzzyword/fuzzyword: LDLIBS=-lwqm -ltimer -lmap -lm
examples/fuzzyword/fuzzyword: examples/fuzzyword/fuzzyword.c
examples/intensive/intensive: CFLAGS+=-std=c23
examples/intensive/intensive: CPPFLAGS+=-I.
examples/intensive/intensive: LDFLAGS+=-L.
examples/intensive/intensive: LDLIBS=-lwqm -ltimer -lmap -lm
examples/intensive/intensive: examples/intensive/intensive.c
examples/timers/timers: CFLAGS+=-std=c23
examples/timers/timers: CPPFLAGS+=-I.
examples/timers/timers: LDFLAGS+=-L.
examples/timers/timers: LDLIBS=-lwqm -ltimer -lmap -lm -lrt
examples/timers/timers: examples/timers/timers.c
#### Tools
.PHONY: callgraph
callgraph:
@cflow -fposix -n --main threadpool_create_and_start --main threadpool_add_task --main threadpool_cancel_task --main threadpool_wait_and_destroy --main threadpool_task_continuation --main threadpool_task_continue wqm.c | grep -v '<>'
.PHONY: cloc
cloc: map.h map.c timer.h timer.c wqm.h wqm.c
cloc --quiet --hide-rate --by-file $^
#### Libraries
.PHONY: libs
libs: libmap.a libmap.so libtimer.a libtimer.so libwqm.a libwqm.so
#C11 compliant, since <threads.h> is required.
%.o: CFLAGS+=-std=c11
.INTERMEDIATE: wqm.o
# Uncomment to prepare for gettext
#wqm.o: CPPFLAGS+=-I/usr/share/gettext -include gettext.h -DENABLE_NLS=1
#wqm.o: CPPFLAGS+=-DPACKAGE="\"libwqm\"" -DLOCALEDIR="\"${PWD}\"" -D"_(s)"="dgettext(PACKAGE,s)" -Di18n_init="do{bindtextdomain(PACKAGE,LOCALEDIR);}while(0)"
lib%.so: LDFLAGS+=-shared
lib%.so: %.o
$(CC) $(LDFLAGS) -o "$@" "$^"
lib%.a: ARFLAGS=rcs
lib%.a: %.o
rm -f -- "$@"
$(AR) $(ARFLAGS) -- "$@" "$^"
@nm -A -g --defined-only -- "$@"
#### Internationalization
# Prepare for gettext (with make fr/LC_MESSAGES/libwqm.mo for instance)
%/LC_MESSAGES/libwqm.mo: po/%.po
mkdir -p "$(dir $@)"
msgfmt --output-file="$@" -- "$^"
po/fr.po: po/libwqm.pot
mkdir -p "$(dir $@)"
[ ! -f "$@" ] || msgmerge -U -N --lang=fr -i --no-location --no-wrap -- "$@" "$^"
[ -f "$@" ] || msginit --no-translator -l fr --no-wrap -i "$^" -o "$@"
po/libwqm.pot: wqm.c
mkdir -p "$(dir $@)"
xgettext -o "$@" -LC -k_ -i --package-name=libwqm --no-wrap --no-location -- "$^"
#### Documentation
.PHONY: doc
doc: README.html README_map.html README_trace.html README_timer.html
.SECONDARY: README_map.md README_trace.md README_timer.md
README_%.md: %.h ./h2md
chmod +x ./h2md
./h2md "$<" >| "$@"
%.html: %.md
pandoc -f markdown -- "$^" > "$@" || :