Makefile 772 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. target = fvm
  2. cflags = -g
  3. ldflags = -lm
  4. cc = gcc
  5. src = $(shell find src/ -name '*.c' -not -name 'main.c')
  6. obj = $(src:.c=.o)
  7. tests=$(shell find tests/ -name '*.c')
  8. tests_bin=$(tests:.c=.bin)
  9. all: $(target)
  10. full: all $(tests_bin)
  11. $(target): $(obj) src/main.o
  12. $(cc) $(cflags) $(ldflags) -o $@ $^
  13. test: $(tests_bin)
  14. @echo
  15. @echo "Run tests:"
  16. @scripts/runall.sh $^
  17. $(obj):%.o:%.c
  18. $(cc) -c $(cflags) $< -MD -MF $@.d -o $@
  19. src/main.o:src/main.c
  20. $(cc) -c $(cflags) $< -MD -MF $@.d -o $@
  21. $(tests_bin):%.bin:%.c $(obj)
  22. $(cc) -Isrc/ $(cflags) $(ldflags) $< $(obj) -MD -MF $@.d -o $@
  23. clean:
  24. -rm $(shell find tests/ -name '*.bin')
  25. -rm $(shell find . -name '*.o' -or -name '*.d')
  26. -rm $(target)
  27. DEPS := $(shell find . -name *.d)
  28. ifneq ($(DEPS),)
  29. include $(DEPS)
  30. endif