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