Makefile-ccan 1.0 KB

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