Makefile 804 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  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_seek test_parallel \
  26. test_alloc test_paths test_orphan test_corrupt
  27. test_%: tests/test_%.sh
  28. ./$<
  29. -include $(DEP)
  30. $(TARGET): $(OBJ)
  31. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  32. %.a: $(OBJ)
  33. $(AR) rcs $@ $^
  34. %.o: %.c
  35. $(CC) -c -MMD $(CFLAGS) $< -o $@
  36. %.s: %.c
  37. $(CC) -S $(CFLAGS) $< -o $@
  38. clean:
  39. rm -f $(TARGET)
  40. rm -f $(OBJ)
  41. rm -f $(DEP)
  42. rm -f $(ASM)