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