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