ccanlint: fix missing file.
[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         cppmagic \
21         darray \
22         endian \
23         lqueue \
24         lstack \
25         minmax \
26         objset \
27         short_types \
28         structeq \
29         tcon \
30         tlist \
31         typesafe_cb \
32         version
33
34 # No external dependencies, with C code:
35 MODS_WITH_SRC := a_star \
36         aga \
37         agar \
38         altstack \
39         antithread \
40         antithread/alloc \
41         asort \
42         asprintf \
43         autodata \
44         avl \
45         base64 \
46         bdelta \
47         block_pool \
48         breakpoint \
49         btree \
50         bytestring \
51         ccan_tokenizer \
52         cdump \
53         charset \
54         ciniparser \
55         crc \
56         crcsync \
57         cpuid \
58         crypto/ripemd160 \
59         crypto/sha256 \
60         crypto/shachain \
61         daemonize \
62         daemon_with_notify \
63         deque \
64         dgraph \
65         eratosthenes \
66         err \
67         failtest \
68         foreach \
69         generator \
70         grab_file \
71         hash \
72         heap \
73         htable \
74         idtree \
75         ilog \
76         invbloom \
77         io \
78         isaac \
79         iscsi \
80         jacobson_karels \
81         jmap \
82         json \
83         jset \
84         lbalance \
85         likely \
86         list \
87         lpq \
88         md4 \
89         mem \
90         net \
91         nfs \
92         noerr \
93         ntdb \
94         ogg_to_pcm \
95         opt \
96         order \
97         permutation \
98         pipecmd \
99         pr_log \
100         ptrint \
101         ptr_valid \
102         pushpull \
103         rbtree \
104         rbuf \
105         read_write_all \
106         rfc822 \
107         rszshm \
108         siphash \
109         sparse_bsearch \
110         str \
111         str/hex \
112         stringbuilder \
113         stringmap \
114         strgrp \
115         strmap \
116         strset \
117         take \
118         tal \
119         tal/grab_file \
120         tal/link \
121         tal/path \
122         tal/stack \
123         tal/str \
124         tal/talloc \
125         talloc \
126         tally \
127         tap \
128         time \
129         timer \
130         ttxml \
131         wwviaudio \
132         xstring
133
134 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
135
136 default: libccan.a
137
138 # Automatic dependency generation: makes ccan/*/*.d files.
139 DEPGEN=-MMD
140 -include $(foreach m, $(MODS), ccan/$(m)/*.d)
141
142 # Anything with C files needs building; dir leaves / on, sort uniquifies
143 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
144
145 # Generate everyone's separate Makefiles.
146 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
147
148 ccan/%-Makefile:
149         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
150         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
151
152 # We compile all the ccan/foo/*.o files together into ccan/foo.o
153 OBJFILES=$(DIRS:=.o)
154
155 # We create all the .o files and link them together.
156 $(OBJFILES): %.o:
157         $(LD) -r -o $@ $^
158
159 libccan.a: $(OBJFILES)
160         $(AR) r $@ $(OBJFILES)