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