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