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