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