]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
Build info files
[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 MODS := a_star \
10         aga \
11         agar \
12         alignof \
13         altstack \
14         antithread \
15         antithread/alloc \
16         argcheck \
17         array_size \
18         asearch \
19         asort \
20         asprintf \
21         autodata \
22         avl \
23         base64 \
24         bdelta \
25         bitmap \
26         block_pool \
27         breakpoint \
28         btree \
29         build_assert \
30         bytestring \
31         cast \
32         ccan_tokenizer \
33         cdump \
34         charset \
35         check_type \
36         ciniparser \
37         compiler \
38         container_of \
39         cppmagic \
40         cpuid \
41         crc \
42         crcsync \
43         crypto/ripemd160 \
44         crypto/sha256 \
45         crypto/shachain \
46         daemonize \
47         daemon_with_notify \
48         darray \
49         deque \
50         dgraph \
51         endian \
52         eratosthenes \
53         err \
54         failtest \
55         foreach \
56         generator \
57         grab_file \
58         hash \
59         heap \
60         htable \
61         idtree \
62         ilog \
63         invbloom \
64         io \
65         isaac \
66         iscsi \
67         jacobson_karels \
68         jmap \
69         jset \
70         json \
71         lbalance \
72         likely \
73         list \
74         lpq \
75         lqueue \
76         lstack \
77         md4 \
78         mem \
79         minmax \
80         net \
81         nfs \
82         noerr \
83         ntdb \
84         objset \
85         ogg_to_pcm \
86         opt \
87         order \
88         permutation \
89         pipecmd \
90         pr_log \
91         ptrint \
92         ptr_valid \
93         pushpull \
94         rbtree \
95         rbuf \
96         read_write_all \
97         rfc822 \
98         rszshm \
99         short_types \
100         siphash \
101         sparse_bsearch \
102         str \
103         str/hex \
104         strgrp \
105         stringbuilder \
106         stringmap \
107         strmap \
108         strset \
109         structeq \
110         take \
111         tal \
112         tal/grab_file \
113         tal/link \
114         tal/path \
115         tal/stack \
116         tal/str \
117         tal/talloc \
118         talloc \
119         tally \
120         tap \
121         tcon \
122         time \
123         timer \
124         tlist \
125         ttxml \
126         typesafe_cb \
127         version \
128         wwviaudio \
129         xstring
130
131 # Anything with C files needs building; dir leaves / on, sort uniquifies
132 MODS_WITH_SRC = $(patsubst ccan/%/, %, $(sort $(foreach m, $(MODS), $(dir $(wildcard ccan/$m/*.c)))))
133
134 default: libccan.a
135
136 # Automatic dependency generation: makes ccan/*/*.d files.
137 DEPGEN=-MMD
138 -include $(foreach m, $(MODS), ccan/$(m)/*.d)
139
140 DIRS=$(patsubst %, ccan/%, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)))
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)