Makefile 954 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. SHELL = /bin/bash -o pipefail
  11. ifdef DEBUG
  12. override CFLAGS += -O0 -g3
  13. else
  14. override CFLAGS += -Os
  15. endif
  16. ifdef WORD
  17. override CFLAGS += -m$(WORD)
  18. endif
  19. override CFLAGS += -I.
  20. override CFLAGS += -std=c99 -Wall -pedantic
  21. all: $(TARGET)
  22. asm: $(ASM)
  23. size: $(OBJ)
  24. $(SIZE) -t $^
  25. .SUFFIXES:
  26. test: test_format test_dirs test_files test_seek test_truncate test_parallel \
  27. test_alloc test_paths test_orphan test_move test_corrupt
  28. test_%: tests/test_%.sh
  29. ifdef QUIET
  30. @./$< | sed -n '/^[-=]/p'
  31. else
  32. ./$<
  33. endif
  34. -include $(DEP)
  35. $(TARGET): $(OBJ)
  36. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  37. %.a: $(OBJ)
  38. $(AR) rcs $@ $^
  39. %.o: %.c
  40. $(CC) -c -MMD $(CFLAGS) $< -o $@
  41. %.s: %.c
  42. $(CC) -S $(CFLAGS) $< -o $@
  43. clean:
  44. rm -f $(TARGET)
  45. rm -f $(OBJ)
  46. rm -f $(DEP)
  47. rm -f $(ASM)