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