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