]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
lstack, lqueue: Move from MODS_WITH_SRC to MODS_NO_SRC
[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         md4 \
83         mem \
84         net \
85         nfs \
86         noerr \
87         ntdb \
88         ogg_to_pcm \
89         opt \
90         order \
91         permutation \
92         pr_log \
93         ptrint \
94         ptr_valid \
95         pushpull \
96         rbtree \
97         rbuf \
98         read_write_all \
99         rfc822 \
100         siphash \
101         sparse_bsearch \
102         str \
103         str/hex \
104         stringbuilder \
105         stringmap \
106         strgrp \
107         strmap \
108         strset \
109         take \
110         tal \
111         tal/grab_file \
112         tal/link \
113         tal/path \
114         tal/stack \
115         tal/str \
116         tal/talloc \
117         talloc \
118         tally \
119         tap \
120         time \
121         timer \
122         ttxml \
123         wwviaudio
124
125 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
126
127 default: libccan.a
128
129 # Automatic dependency generation: makes ccan/*/*.d files.
130 DEPGEN=-MD
131 -include ccan/*/*.d
132
133 # Anything with C files needs building; dir leaves / on, sort uniquifies
134 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
135
136 # Generate everyone's separate Makefiles.
137 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
138
139 ccan/%-Makefile:
140         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
141         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
142
143 # We compile all the ccan/foo/*.o files together into ccan/foo.o
144 OBJFILES=$(DIRS:=.o)
145
146 # We create all the .o files and link them together.
147 $(OBJFILES): %.o:
148         $(LD) -r -o $@ $^
149
150 libccan.a: $(OBJFILES)
151         $(AR) r $@ $(OBJFILES)