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