]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
mem: add memcheck() for valgrind.
[ccan] / Makefile-ccan
1 # Example makefile which makes a "libccan.a" of everything under ccan/.
2 # For simple projects you could just do:
3 #       SRCFILES += $(wildcard ccan/*/*.c)
4
5 #CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
6 CCAN_CFLAGS=-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
7 CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
8
9 # Modules which are just a header:
10 MODS_NO_SRC := alignof \
11         argcheck \
12         array_size \
13         asearch \
14         bitmap \
15         build_assert \
16         cast \
17         check_type \
18         compiler \
19         container_of \
20         darray \
21         endian \
22         minmax \
23         objset \
24         short_types \
25         structeq \
26         tcon \
27         tlist \
28         typesafe_cb \
29         version
30
31 # No external dependencies, with C code:
32 MODS_WITH_SRC := aga \
33         agar \
34         antithread \
35         antithread/alloc \
36         asort \
37         asprintf \
38         autodata \
39         avl \
40         base64 \
41         bdelta \
42         block_pool \
43         breakpoint \
44         btree \
45         bytestring \
46         ccan_tokenizer \
47         cdump \
48         charset \
49         ciniparser \
50         crc \
51         crcsync \
52         cpuid \
53         crypto/ripemd160 \
54         crypto/sha256 \
55         crypto/shachain \
56         daemonize \
57         daemon_with_notify \
58         dgraph \
59         eratosthenes \
60         err \
61         failtest \
62         foreach \
63         grab_file \
64         hash \
65         heap \
66         htable \
67         idtree \
68         ilog \
69         invbloom \
70         io \
71         isaac \
72         iscsi \
73         jacobson_karels \
74         jmap \
75         json \
76         jset \
77         lbalance \
78         likely \
79         list \
80         lqueue \
81         lstack \
82         md4 \
83         mem \
84         net \
85         nfs \
86         noerr \
87         ntdb \
88         ogg_to_pcm \
89         opt \
90         order \
91         pr_log \
92         ptrint \
93         ptr_valid \
94         pushpull \
95         rbtree \
96         rbuf \
97         read_write_all \
98         rfc822 \
99         siphash \
100         sparse_bsearch \
101         str \
102         str/hex \
103         stringbuilder \
104         stringmap \
105         strgrp \
106         strmap \
107         strset \
108         take \
109         tal \
110         tal/grab_file \
111         tal/link \
112         tal/path \
113         tal/stack \
114         tal/str \
115         tal/talloc \
116         talloc \
117         tally \
118         tap \
119         time \
120         timer \
121         ttxml \
122         wwviaudio
123
124 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
125
126 default: libccan.a
127
128 # Automatic dependency generation: makes ccan/*/*.d files.
129 DEPGEN=-MD
130 -include ccan/*/*.d
131
132 # Anything with C files needs building; dir leaves / on, sort uniquifies
133 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
134
135 # Generate everyone's separate Makefiles.
136 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
137
138 ccan/%-Makefile:
139         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
140         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
141
142 # We compile all the ccan/foo/*.o files together into ccan/foo.o
143 OBJFILES=$(DIRS:=.o)
144
145 # We create all the .o files and link them together.
146 $(OBJFILES): %.o:
147         $(LD) -r -o $@ $^
148
149 libccan.a: $(OBJFILES)
150         $(AR) r $@ $(OBJFILES)