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