]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
ccanlint: with -vv, give details on attempts to compile examples.
[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 -Werror
6 CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
7
8 #CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Werror $(DEPGEN)
9
10 default: libccan.a
11
12 # Automatic dependency generation: makes ccan/*/*.d files.
13 DEPGEN=-MD
14 -include ccan/*/*.d
15
16 # Every directory with .c files is included.
17 DIRS=$(filter-out $(foreach d,$(EXCLUDE),ccan/$d), $(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c)))))
18
19 # Generate everyone's separate Makefiles.
20 -include $(foreach dir, $(DIRS), $(dir)-Makefile)
21
22 ccan/%-Makefile:
23         @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
24         @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
25
26 # We compile all the ccan/foo/*.o files together into ccan/foo.o
27 OBJFILES=$(DIRS:=.o)
28
29 # We create all the .o files and link them together.
30 $(OBJFILES): %.o:
31         $(LD) -r -o $@ $^
32
33 libccan.a: $(OBJFILES)
34         $(AR) r $@ $(OBJFILES)