]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
tal/link: new module for reference-count style coding for tal.
[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         read_write_all \
66         rfc822 \
67         sparse_bsearch \
68         str \
69         stringmap \
70         strmap \
71         strset \
72         str_talloc \
73         take \
74         tal \
75         tal/link \
76         tal/path \
77         tal/str \
78         talloc \
79         talloc_link \
80         tally \
81         tap \
82         time \
83         ttxml
84
85 MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
86
87 # Modules which require external dependencies, thus may not pass check.
88 MODS_EXTERNAL_NO_SRC:=
89
90 MODS_EXTERNAL_WITH_SRC:=jmap \
91         jset \
92         nfs \
93         ogg_to_pcm \
94         wwviaudio
95
96 MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
97
98 MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
99
100 default: libccan.a
101
102 # Automatic dependency generation: makes ccan/*/*.d files.
103 DEPGEN=-MD
104 -include ccan/*/*.d
105
106 # Anything with C files needs building; dir leaves / on, sort uniquifies
107 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(MODS_NORMAL_WITH_SRC), $(dir $(wildcard ccan/$m/*.c)))))
108
109 # Generate everyone's separate Makefiles.
110 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
111
112 ccan/%-Makefile:
113         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
114         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
115
116 # We compile all the ccan/foo/*.o files together into ccan/foo.o
117 OBJFILES=$(DIRS:=.o)
118
119 # We create all the .o files and link them together.
120 $(OBJFILES): %.o:
121         $(LD) -r -o $@ $^
122
123 libccan.a: $(OBJFILES)
124         $(AR) r $@ $(OBJFILES)