Makefile 716 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. cc = gcc
  2. src = $(shell ls src/*.c)
  3. obj = $(src:.c=.o)
  4. ldflags = -lgc
  5. tests=$(shell ls tests/*.c)
  6. tests_bin=$(tests:.c=.bin)
  7. all: libdymc.a
  8. -rm -rf build/
  9. -@mkdir -p build/include/dymc/
  10. -@mkdir -p build/lib
  11. mv libdymc.a build/lib/
  12. cp src/*.h build/include/dymc
  13. libdymc.a: $(obj)
  14. ar cr $@ $^
  15. test: $(tests_bin)
  16. @echo
  17. @echo "Run tests:"
  18. @scripts/runall.sh $^
  19. $(obj):%.o:%.c
  20. $(cc) -c -g $< -MD -MF $@.d -o $@
  21. $(tests_bin):%.bin:%.c libdymc.a
  22. $(cc) -g -Isrc/ $(ldflags) $< libdymc.a -MD -MF $@.d -o $@
  23. clean:
  24. -rm $(shell find tests/ -name '*.bin')
  25. -rm $(shell find . -name '*.o' -or -name '*.a' -or -name '*.d')
  26. -rm -rf build
  27. DEPS := $(shell find . -name *.d)
  28. ifneq ($(DEPS),)
  29. include $(DEPS)
  30. endif