Makefile 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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
  24. override CFLAGS += -Wshadow -Wunused-parameter -Wjump-misses-init -Wsign-compare
  25. all: $(TARGET)
  26. asm: $(ASM)
  27. size: $(OBJ)
  28. $(SIZE) -t $^
  29. .SUFFIXES:
  30. test: test_format test_dirs test_files test_seek test_truncate \
  31. test_entries test_interspersed test_alloc test_paths test_attrs \
  32. test_move test_orphan test_corrupt
  33. @rm test.c
  34. test_%: tests/test_%.sh
  35. ifdef QUIET
  36. @./$< | sed -n '/^[-=]/p'
  37. else
  38. ./$<
  39. endif
  40. -include $(DEP)
  41. lfs: $(OBJ)
  42. $(CC) $(CFLAGS) $^ $(LFLAGS) -o $@
  43. %.a: $(OBJ)
  44. $(AR) rcs $@ $^
  45. %.o: %.c
  46. $(CC) -c -MMD $(CFLAGS) $< -o $@
  47. %.s: %.c
  48. $(CC) -S $(CFLAGS) $< -o $@
  49. clean:
  50. rm -f $(TARGET)
  51. rm -f $(OBJ)
  52. rm -f $(DEP)
  53. rm -f $(ASM)