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 -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)
9 # Modules which are just a header:
10 MODS_NO_SRC := alignof \
34 # No external dependencies, with C code:
35 MODS_WITH_SRC := a_star \
134 MODS:=$(MODS_WITH_SRC) $(MODS_NO_SRC)
138 # Automatic dependency generation: makes ccan/*/*.d files.
140 -include $(foreach m, $(MODS), ccan/$(m)/*.d)
142 # Anything with C files needs building; dir leaves / on, sort uniquifies
143 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(filter-out $(MODS_EXCLUDE), $(MODS_WITH_SRC)), $(dir $(wildcard ccan/$m/*.c)))))
145 # Generate everyone's separate Makefiles.
146 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
149 @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
150 @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
152 # We compile all the ccan/foo/*.o files together into ccan/foo.o
155 # We create all the .o files and link them together.
159 libccan.a: $(OBJFILES)
160 $(AR) r $@ $(OBJFILES)