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