Makefile 697 B

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