Makefile-ccan 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  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. CCAN_CFLAGS=-g -O3 -Wall -Wstrict-prototypes -Wold-style-definition -Wmissing-prototypes -Wmissing-declarations -Werror
  5. CFLAGS = $(CCAN_CFLAGS) -I. $(DEPGEN)
  6. #CFLAGS=-g -Wall -Wstrict-prototypes -Wold-style-definition -Werror $(DEPGEN)
  7. default: libccan.a
  8. # Automatic dependency generation: makes ccan/*/*.d files.
  9. DEPGEN=-MD
  10. -include ccan/*/*.d
  11. # Every directory with .c files is included.
  12. DIRS=$(filter-out $(foreach d,$(EXCLUDE),ccan/$d), $(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c)))))
  13. # Generate everyone's separate Makefiles.
  14. -include $(foreach dir, $(DIRS), $(dir)-Makefile)
  15. ccan/%-Makefile:
  16. @echo $@: $(wildcard ccan/$*/*.[ch]) ccan/$*/_info > $@
  17. @echo ccan/$*.o: $(patsubst %.c, %.o, $(wildcard ccan/$*/*.c)) >> $@
  18. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  19. OBJFILES=$(DIRS:=.o)
  20. # We create all the .o files and link them together.
  21. $(OBJFILES): %.o:
  22. $(LD) -r -o $@ $^
  23. libccan.a: $(OBJFILES)
  24. $(AR) r $@ $(OBJFILES)