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