Makefile 764 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. TARGET = lfs
  2. CC = gcc
  3. AR = ar
  4. SIZE = size
  5. SRC += $(wildcard *.c emubd/*.c)
  6. OBJ := $(SRC:.c=.o)
  7. DEP := $(SRC:.c=.d)
  8. ASM := $(SRC:.c=.s)
  9. TEST := $(patsubst tests/%.sh,%,$(wildcard tests/test_*))
  10. ifdef DEBUG
  11. CFLAGS += -O0 -g3
  12. else
  13. CFLAGS += -Os
  14. endif
  15. ifdef WORD
  16. CFLAGS += -m$(WORD)
  17. endif
  18. CFLAGS += -I.
  19. CFLAGS += -std=c99 -Wall -pedantic
  20. all: $(TARGET)
  21. asm: $(ASM)
  22. size: $(OBJ)
  23. $(SIZE) -t $^
  24. .SUFFIXES:
  25. test: test_format test_dirs test_files test_alloc test_paths test_orphan
  26. test_%: tests/test_%.sh
  27. ./$<
  28. -include $(DEP)
  29. $(TARGET): $(OBJ)
  30. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  31. %.a: $(OBJ)
  32. $(AR) rcs $@ $^
  33. %.o: %.c
  34. $(CC) -c -MMD $(CFLAGS) $< -o $@
  35. %.s: %.c
  36. $(CC) -S $(CFLAGS) $< -o $@
  37. clean:
  38. rm -f $(TARGET)
  39. rm -f $(OBJ)
  40. rm -f $(DEP)
  41. rm -f $(ASM)