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