]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
ccanlint: enhance and streamline "output" testing lines.
[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         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)