Makefile 988 B

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