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