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 # Normal modules: no external dependencies, just a header:
10 MODS_NORMAL_NO_SRC := alignof \
27 # No external dependencies, with C code:
28 MODS_NORMAL_WITH_SRC := antithread \
84 MODS_NORMAL:=$(MODS_NORMAL_WITH_SRC) $(MODS_NORMAL_NO_SRC)
86 # Modules which require external dependencies, thus may not pass check.
87 MODS_EXTERNAL_NO_SRC:=
89 MODS_EXTERNAL_WITH_SRC:=jmap \
95 MODS_EXTERNAL:=$(MODS_EXTERNAL_NO_SRC) $(MODS_EXTERNAL_WITH_SRC)
97 MODS:=$(MODS_EXTERNAL) $(MODS_NORMAL)
101 # Automatic dependency generation: makes ccan/*/*.d files.
105 # Anything with C files needs building; dir leaves / on, sort uniquifies
106 DIRS=$(patsubst %/, %, $(sort $(foreach m, $(MODS_NORMAL_WITH_SRC), $(dir $(wildcard ccan/$m/*.c)))))
108 # Generate everyone's separate Makefiles.
109 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
112 @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
113 @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
115 # We compile all the ccan/foo/*.o files together into ccan/foo.o
118 # We create all the .o files and link them together.
122 libccan.a: $(OBJFILES)
123 $(AR) r $@ $(OBJFILES)