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)
5 #CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations
6 CCAN_CFLAGS=-g3 -ggdb -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Wpointer-arith -Wwrite-strings -DCCAN_STR_DEBUG=1
7 CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
12 # Automatic dependency generation: makes ccan/*/*.d files.
16 # Anything with an _info file is a module.
17 REALLY_ALL=$(patsubst ccan/%/_info, %, $(wildcard ccan/*/_info))
19 # Exclude any modules we can't build.
20 ALL=$(filter-out $(EXCLUDE), $(REALLY_ALL))
22 # Anything with C files needs building; dir leaves / on, sort uniquifies
23 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(ALL), $(dir $(wildcard ccan/$m/*.c)))))
25 # Generate everyone's separate Makefiles.
26 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
29 @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
30 @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
32 # We compile all the ccan/foo/*.o files together into ccan/foo.o
35 # We create all the .o files and link them together.
39 libccan.a: $(OBJFILES)
40 $(AR) r $@ $(OBJFILES)