Makefile 861 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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_move test_corrupt
  27. test_%: tests/test_%.sh
  28. ifdef QUIET
  29. ./$< | sed '/^[^-=]/d'
  30. else
  31. ./$<
  32. endif
  33. -include $(DEP)
  34. $(TARGET): $(OBJ)
  35. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  36. %.a: $(OBJ)
  37. $(AR) rcs $@ $^
  38. %.o: %.c
  39. $(CC) -c -MMD $(CFLAGS) $< -o $@
  40. %.s: %.c
  41. $(CC) -S $(CFLAGS) $< -o $@
  42. clean:
  43. rm -f $(TARGET)
  44. rm -f $(OBJ)
  45. rm -f $(DEP)
  46. rm -f $(ASM)