Makefile-ccan 944 B

12345678910111213141516171819202122232425
  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. # Automatic dependency generation: makes ccan/*.d files.
  7. DEPGEN=-MD
  8. -include ccan/*/*.d
  9. # Every directory with .c files is included.
  10. DIRS=$(filter-out $(EXCLUDE), $(patsubst %/, %, $(sort $(dir $(wildcard ccan/*/*.c)))))
  11. # We compile all the ccan/foo/*.o files together into ccan/foo.o
  12. OBJFILES=$(DIRS:=.o)
  13. libccan.a: $(OBJFILES)
  14. $(AR) r $@ $^
  15. # Dependencies are autogenerated in the .d files.
  16. # We create all the .o files and link them together.
  17. $(OBJFILES): %.o:
  18. cd $* && $(CC) -I../.. $(CFLAGS) -c *.c && cd ../.. && $(LD) -r -o $@ `echo $*/*.c ' ' | sed 's/\.c /.o /g'`