rszshm: New module
[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         rszshm \
104         siphash \
105         sparse_bsearch \
106         str \
107         str/hex \
108         stringbuilder \
109         stringmap \
110         strgrp \
111         strmap \
112         strset \
113         take \
114         tal \
115         tal/grab_file \
116         tal/link \
117         tal/path \
118         tal/stack \
119         tal/str \
120         tal/talloc \
121         talloc \
122         tally \
123         tap \
124         time \
125         timer \
126         ttxml \
127         wwviaudio \
128         xstring
129
130 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
131
132 default: libccan.a
133
134 # Automatic dependency generation: makes ccan/*/*.d files.
135 DEPGEN=-MD
136 -include ccan/*/*.d
137
138 # Anything with C files needs building; dir leaves / on, sort uniquifies
139 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
140
141 # Generate everyone's separate Makefiles.
142 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
143
144 ccan/%-Makefile:
145         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
146         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
147
148 # We compile all the ccan/foo/*.o files together into ccan/foo.o
149 OBJFILES=$(DIRS:=.o)
150
151 # We create all the .o files and link them together.
152 $(OBJFILES): %.o:
153         $(LD) -r -o $@ $^
154
155 libccan.a: $(OBJFILES)
156         $(AR) r $@ $(OBJFILES)