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