bytestring: use newly added mem helpers
[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         strmap \
106         strset \
107         take \
108         tal \
109         tal/grab_file \
110         tal/link \
111         tal/path \
112         tal/stack \
113         tal/str \
114         tal/talloc \
115         talloc \
116         tally \
117         tap \
118         time \
119         timer \
120         ttxml \
121         wwviaudio
122
123 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
124
125 default: libccan.a
126
127 # Automatic dependency generation: makes ccan/*/*.d files.
128 DEPGEN=-MD
129 -include ccan/*/*.d
130
131 # Anything with C files needs building; dir leaves / on, sort uniquifies
132 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
133
134 # Generate everyone's separate Makefiles.
135 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
136
137 ccan/%-Makefile:
138         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
139         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
140
141 # We compile all the ccan/foo/*.o files together into ccan/foo.o
142 OBJFILES=$(DIRS:=.o)
143
144 # We create all the .o files and link them together.
145 $(OBJFILES): %.o:
146         $(LD) -r -o $@ $^
147
148 libccan.a: $(OBJFILES)
149         $(AR) r $@ $(OBJFILES)