Makefile 964 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. BUILD ?= build
  2. all: $(BUILD)/rots-util
  3. CFLAGS += -Iinclude
  4. CFLAGS += -Wall -Wundef -Wextra -Wshadow -Wimplicit-function-declaration
  5. CFLAGS += -Wredundant-decls -Wmissing-prototypes -Wstrict-prototypes
  6. CFLAGS += -D_GNU_SOURCE
  7. LIBS = -lcrypto -lssl
  8. CC = gcc
  9. LD = gcc
  10. obj-y += source/file.o
  11. obj-y += source/image.o
  12. obj-y += source/info.o
  13. obj-y += source/main.o
  14. obj-y += source/option.o
  15. obj-y += source/pack.o
  16. obj-y += source/sign.o
  17. obj-y += source/unpack.o
  18. obj-y += source/verify.o
  19. obj-y += source/x509.o
  20. obj = $(addprefix $(BUILD)/, $(obj-y))
  21. # Include the dependencies.
  22. -include $(obj:.o=.d)
  23. # Set up the toolchain.
  24. .SECONDARY:
  25. clean:
  26. @echo "CLEAN"
  27. @rm -rf $(BUILD)
  28. # Rule to compile C source code.
  29. $(BUILD)/%.o: %.c
  30. @echo "CC $<"
  31. @mkdir -p $(dir $@)
  32. @$(CC) -c $< -o $@ $(CFLAGS) -MT $@ -MMD -MP -MF $(@:.o=.d)
  33. $(BUILD)/rots-util: $(obj) $(LDSCRIPT)
  34. @echo "LD $@"
  35. @mkdir -p $(dir $@)
  36. @$(LD) -o $@ $(CFLAGS) $(LDFLAGS) $(obj) $(LIBS)
  37. .PHONY: clean