Makefile-ccan 877 B

123456789101112131415161718192021222324
  1. # Example makefile which makes a "libccan.a" of everything under ccan/.
  2. # For simple projects you could just do:
  3. # SRCFILES += $(wildcard ccan/*/[a-z]*.c)
  4. CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror -I. $(DEPGEN)
  5. # Automatic dependency generation: makes ccan/*.d files.
  6. DEPGEN=-MD
  7. -include ccan/*/*.d
  8. # Every directory with .c files (other than _info.c) is included.
  9. DIRS=$(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/[a-z]*.c))))
  10. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  11. OBJFILES=$(DIRS:=.o)
  12. libccan.a: $(OBJFILES)
  13. $(AR) r $@ $^
  14. # Dependencies are autogenerated in the .d files.
  15. # We create all the .o files and link them together.
  16. $(OBJFILES): %.o:
  17. cd $* && $(CC) -I../.. $(CFLAGS) -c [a-z]*.c && cd ../.. && $(LD) -r -o $@ `echo $*/[a-z]*.c ' ' | sed 's/\.c /.o /g'`