]> git.ozlabs.org Git - ccan/blob - Makefile-ccan
tools/ccanlint: build tests are now compulsory
[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 CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. $(DEPGEN)
6
7 # Automatic dependency generation: makes ccan/*.d files.
8 DEPGEN=-MD
9 -include ccan/*/*.d
10
11 # Every directory with .c files is included.
12 DIRS=$(filter-out $(EXCLUDE), $(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c)))))
13
14 # We compile all the ccan/foo/*.o files together into ccan/foo.o
15 OBJFILES=$(DIRS:=.o)
16
17 libccan.a: $(OBJFILES)
18         $(AR) r $@ $^
19
20 # Dependencies are autogenerated in the .d files.
21 # We create all the .o files and link them together.
22 $(OBJFILES): %.o:
23         cd $* && $(CC) -I../.. $(CFLAGS) -c *.c && cd ../.. && $(LD) -r -o $@ `echo $*/*.c ' ' | sed 's/\.c /.o /g'`
24