Makefile-ccan 2.71 KB
Newer Older
1 2
# Example makefile which makes a "libccan.a" of everything under ccan/.
# For simple projects you could just do:
3
#	SRCFILES += $(wildcard ccan/*/*.c)
4

5 6
#CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -Wundef -DCCAN_STR_DEBUG=1
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 10
# Modules which are just a header:
MODS_NO_SRC := alignof \
11
	argcheck \
12 13
	array_size \
	asearch \
14
	bitmap \
15 16 17 18 19 20 21
	build_assert \
	cast \
	check_type \
	compiler \
	container_of \
	darray \
	endian \
22 23
	lqueue \
	lstack \
24
	minmax \
25 26
	objset \
	short_types \
Rusty Russell's avatar
Rusty Russell committed
27
	structeq \
28 29
	tcon \
	tlist \
30 31
	typesafe_cb \
	version
32 33

# No external dependencies, with C code:
34 35
MODS_WITH_SRC := aga \
	agar \
Dan Good's avatar
Dan Good committed
36
	altstack \
37
	antithread \
38
	antithread/alloc \
39 40 41 42
	asort \
	asprintf \
	autodata \
	avl \
43
	base64 \
44 45
	bdelta \
	block_pool \
Rusty Russell's avatar
Rusty Russell committed
46
	breakpoint \
47
	btree \
48
	bytestring \
49
	ccan_tokenizer \
Rusty Russell's avatar
Rusty Russell committed
50
	cdump \
51 52 53 54
	charset \
	ciniparser \
	crc \
	crcsync \
Ahmed Samy's avatar
Ahmed Samy committed
55
	cpuid \
56
	crypto/ripemd160 \
57 58
	crypto/sha256 \
	crypto/shachain \
59 60
	daemonize \
	daemon_with_notify \
Dan Good's avatar
Dan Good committed
61
	deque \
62
	dgraph \
63
	eratosthenes \
64 65 66
	err \
	failtest \
	foreach \
David Gibson's avatar
David Gibson committed
67
	generator \
68 69
	grab_file \
	hash \
Emilio G. Cota's avatar
Emilio G. Cota committed
70
	heap \
71 72 73
	htable \
	idtree \
	ilog \
74
	invbloom \
Rusty Russell's avatar
Rusty Russell committed
75
	io \
76 77
	isaac \
	iscsi \
David Gibson's avatar
David Gibson committed
78
	jacobson_karels \
79
	jmap \
80
	json \
81
	jset \
82 83 84
	lbalance \
	likely \
	list \
David Gibson's avatar
David Gibson committed
85
	lpq \
86
	md4 \
87
	mem \
88
	net \
89
	nfs \
90
	noerr \
Rusty Russell's avatar
Rusty Russell committed
91
	ntdb \
92
	ogg_to_pcm \
93
	opt \
94
	order \
95
	permutation \
Rusty Russell's avatar
Rusty Russell committed
96
	pipecmd \
97
	pr_log \
Rusty Russell's avatar
Rusty Russell committed
98
	ptrint \
99
	ptr_valid \
Rusty Russell's avatar
Rusty Russell committed
100
	pushpull \
101
	rbtree \
Rusty Russell's avatar
Rusty Russell committed
102
	rbuf \
103 104
	read_write_all \
	rfc822 \
Dan Good's avatar
Dan Good committed
105
	rszshm \
106
	siphash \
107 108
	sparse_bsearch \
	str \
109
	str/hex \
110
	stringbuilder \
111
	stringmap \
Andrew Jeffery's avatar
Andrew Jeffery committed
112
	strgrp \
113 114 115 116
	strmap \
	strset \
	take \
	tal \
Rusty Russell's avatar
Rusty Russell committed
117
	tal/grab_file \
118
	tal/link \
Rusty Russell's avatar
Rusty Russell committed
119
	tal/path \
Delio Brignoli's avatar
Delio Brignoli committed
120
	tal/stack \
Rusty Russell's avatar
Rusty Russell committed
121
	tal/str \
122
	tal/talloc \
123 124 125 126
	talloc \
	tally \
	tap \
	time \
127
	timer \
128
	ttxml \
129 130
	wwviaudio \
	xstring
131

132
MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
133

134 135 136
default: libccan.a

# Automatic dependency generation: makes ccan/*/*.d files.
137
DEPGEN=-MD
138
-include ccan/*/*.d
139

140
# Anything with C files needs building; dir leaves / on, sort uniquifies
141
DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
142

143 144 145 146 147 148 149
# Generate everyone's separate Makefiles.
-include $(foreach dir, $(DIRS), $(dir)-Makefile)

ccan/%-Makefile:
	@echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
	@echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@

150 151
# We compile all the ccan/foo/*.o files together into ccan/foo.o
OBJFILES=$(DIRS:=.o)
152

153
# We create all the .o files and link them together.
154
$(OBJFILES): %.o:
155
	$(LD) -r -o $@ $^
156

157 158
libccan.a: $(OBJFILES)
	$(AR) r $@ $(OBJFILES)