]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
Add a set of simple version comparison helpers
[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         version
27
28 # No external dependencies, with C code:
29 MODS_NORMAL_WITH_SRC := antithread \
30         antithread/alloc \
31         asort \
32         asprintf \
33         autodata \
34         avl \
35         bdelta \
36         block_pool \
37         btree \
38         ccan_tokenizer \
39         charset \
40         ciniparser \
41         crc \
42         crcsync \
43         daemonize \
44         daemon_with_notify \
45         dgraph \
46         err \
47         failtest \
48         foreach \
49         grab_file \
50         hash \
51         htable \
52         idtree \
53         ilog \
54         isaac \
55         iscsi \
56         json \
57         lbalance \
58         likely \
59         list \
60         md4 \
61         net \
62         noerr \
63         opt \
64         ptr_valid \
65         rbtree \
66         rbuf \
67         read_write_all \
68         rfc822 \
69         siphash \
70         sparse_bsearch \
71         str \
72         stringmap \
73         strmap \
74         strset \
75         str_talloc \
76         take \
77         tal \
78         tal/link \
79         tal/path \
80         tal/str \
81         talloc \
82         talloc_link \
83         tally \
84         tap \
85         time \
86         ttxml
87
88 MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
89
90 # Modules which require external dependencies, thus may not pass check.
91 MODS_EXTERNAL_NO_SRC:=
92
93 MODS_EXTERNAL_WITH_SRC:=jmap \
94         jset \
95         nfs \
96         ogg_to_pcm \
97         tal/talloc \
98         wwviaudio
99
100 MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
101
102 MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
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, $(MODS_NORMAL_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)