]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
tal: append the length property to the initial allocation.
[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 # Normal modules: no external dependencies, just a header:
10 MODS_NORMAL_NO_SRC := alignof \
11         array_size \
12         asearch \
13         build_assert \
14         bytestring \
15         cast \
16         check_type \
17         compiler \
18         container_of \
19         darray \
20         endian \
21         objset \
22         short_types \
23         tcon \
24         tlist \
25         typesafe_cb
26
27 # No external dependencies, with C code:
28 MODS_NORMAL_WITH_SRC := antithread \
29         antithread/alloc \
30         asort \
31         asprintf \
32         autodata \
33         avl \
34         bdelta \
35         block_pool \
36         btree \
37         ccan_tokenizer \
38         charset \
39         ciniparser \
40         crc \
41         crcsync \
42         daemonize \
43         daemon_with_notify \
44         dgraph \
45         err \
46         failtest \
47         foreach \
48         grab_file \
49         hash \
50         htable \
51         idtree \
52         ilog \
53         isaac \
54         iscsi \
55         json \
56         lbalance \
57         likely \
58         list \
59         md4 \
60         net \
61         noerr \
62         opt \
63         ptr_valid \
64         rbtree \
65         rbuf \
66         read_write_all \
67         rfc822 \
68         sparse_bsearch \
69         str \
70         stringmap \
71         strmap \
72         strset \
73         str_talloc \
74         take \
75         tal \
76         tal/link \
77         tal/path \
78         tal/str \
79         talloc \
80         talloc_link \
81         tally \
82         tap \
83         time \
84         ttxml
85
86 MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
87
88 # Modules which require external dependencies, thus may not pass check.
89 MODS_EXTERNAL_NO_SRC:=
90
91 MODS_EXTERNAL_WITH_SRC:=jmap \
92         jset \
93         nfs \
94         ogg_to_pcm \
95         wwviaudio
96
97 MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
98
99 MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
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, $(MODS_NORMAL_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)