Makefile 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. TARGET = lfs.a
  2. ifneq ($(wildcard test.c main.c),)
  3. override TARGET = lfs
  4. endif
  5. CC ?= gcc
  6. AR ?= ar
  7. SIZE ?= size
  8. SRC += $(wildcard *.c emubd/*.c)
  9. OBJ := $(SRC:.c=.o)
  10. DEP := $(SRC:.c=.d)
  11. ASM := $(SRC:.c=.s)
  12. TEST := $(patsubst tests/%.sh,%,$(wildcard tests/test_*))
  13. SHELL = /bin/bash -o pipefail
  14. ifdef DEBUG
  15. override CFLAGS += -O0 -g3
  16. else
  17. override CFLAGS += -Os
  18. endif
  19. ifdef WORD
  20. override CFLAGS += -m$(WORD)
  21. endif
  22. override CFLAGS += -I.
  23. override CFLAGS += -std=c99 -Wall -pedantic -Wshadow -Wunused-parameter
  24. all: $(TARGET)
  25. asm: $(ASM)
  26. size: $(OBJ)
  27. $(SIZE) -t $^
  28. .SUFFIXES:
  29. test: test_format test_dirs test_files test_seek test_truncate \
  30. test_entries test_interspersed test_alloc test_paths test_attrs \
  31. test_move test_orphan test_corrupt
  32. @rm test.c
  33. test_%: tests/test_%.sh
  34. ifdef QUIET
  35. @./$< | sed -n '/^[-=]/p'
  36. else
  37. ./$<
  38. endif
  39. -include $(DEP)
  40. lfs: $(OBJ)
  41. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  42. %.a: $(OBJ)
  43. $(AR) rcs $@ $^
  44. %.o: %.c
  45. $(CC) -c -MMD $(CFLAGS) $< -o $@
  46. %.s: %.c
  47. $(CC) -S $(CFLAGS) $< -o $@
  48. clean:
  49. rm -f $(TARGET)
  50. rm -f $(OBJ)
  51. rm -f $(DEP)
  52. rm -f $(ASM)