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