str_talloc: delete.
[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         jacobson_karels \
64         jmap \
65         json \
66         jset \
67         lbalance \
68         likely \
69         list \
70         md4 \
71         net \
72         nfs \
73         noerr \
74         ogg_to_pcm \
75         opt \
76         ptr_valid \
77         rbtree \
78         rbuf \
79         read_write_all \
80         rfc822 \
81         siphash \
82         sparse_bsearch \
83         str \
84         stringmap \
85         strmap \
86         strset \
87         take \
88         tal \
89         tal/grab_file \
90         tal/link \
91         tal/path \
92         tal/str \
93         tal/talloc \
94         talloc \
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)