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