-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
99 lines (79 loc) · 2.67 KB
/
Makefile
File metadata and controls
99 lines (79 loc) · 2.67 KB
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
CFLAGS+=-O
CFLAGS+=-fPIC
LDFLAGS=
#CHECK=valgrind --leak-check=full --show-leak-kinds=all
#CHECK=ddd
#CHECK=gdb
#CHECK=time
.PHONY: all
all: README.md libmap.a libmap.so test_map libtimer.a libtimer.so test_timer test_group_union_find test_group_bfs
#### Examples
.PHONY: test_map
test_map: libmap.so examples/test_map
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. $(CHECK) ./examples/test_map
@echo "*********************"
examples/test_map: CFLAGS+=-std=c23
examples/test_map: CPPFLAGS+=-I.
examples/test_map: LDFLAGS+=-L.
examples/test_map: LDLIBS=-lmap
examples/test_map: examples/test_map.c
.PHONY: test_timer
test_timer: libmap.so libtimer.so examples/test_timer
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. $(CHECK) ./examples/test_timer
@echo "*********************"
examples/test_timer: CFLAGS+=-std=c23
examples/test_timer: CPPFLAGS+=-I.
examples/test_timer: LDFLAGS+=-L.
examples/test_timer: LDLIBS=-ltimer
examples/test_timer: examples/test_timer.c
.PHONY: test_group_union_find
test_group_union_find: libmap.so examples/test_group_union_find
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. $(CHECK) ./examples/test_group_union_find
@echo "*********************"
examples/test_group_union_find: CFLAGS+=-std=c23
examples/test_group_union_find: CPPFLAGS+=-I.
examples/test_group_union_find: LDFLAGS+=-L.
examples/test_group_union_find: LDLIBS=-lmap
examples/test_group_union_find: examples/test_group_union_find.c
.PHONY: test_group_bfs
test_group_bfs: libmap.so examples/test_group_bfs
@echo "********* $@ ************"
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:. $(CHECK) ./examples/test_group_bfs
@echo "*********************"
examples/test_group_bfs: CFLAGS+=-std=c23
examples/test_group_bfs: CPPFLAGS+=-I.
examples/test_group_bfs: LDFLAGS+=-L.
examples/test_group_bfs: LDLIBS=-lmap
examples/test_group_bfs: examples/test_group_bfs.c
#### Libraries
#C11 compliant, since <threads.h> is required.
%.o: CFLAGS+=-std=c11
libtimer.a: ARFLAGS=rcs
libtimer.a: timer.o map.o
rm -f -- "$@"
$(AR) $(ARFLAGS) -- "$@" $^
@nm -A -g --defined-only -- "$@"
libtimer.so: LDFLAGS+=-shared
libtimer.so: timer.o map.o
$(CC) $(LDFLAGS) -o "$@" $^
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 -- "$@"
.INTERMEDIATE: timer.o map.o
#### Documentation
.PHONY: doc
doc: README_map.html README_timer.html README.md
.INTERMEDIATE: README_map.md README_timer.md
README.md: README_map.md README_timer.md
cat README_map.md README_timer.md >| README.md
README_%.md: %.h ./h2md
chmod +x ./h2md
./h2md "$<" >| "$@"