Makefile 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # The toolchain definitions
  2. CC = cc
  3. SPARSE = sparse
  4. V = @ # Verbose build: make V=1
  5. C = 0 # Sparsechecker build: make C=1
  6. Q = $(V:1=)
  7. QUIET_CC = $(Q:@=@echo ' CC '$@;)$(CC)
  8. QUIET_DEPEND = $(Q:@=@echo ' DEPEND '$@;)$(CC)
  9. ifeq ($(C),1)
  10. QUIET_SPARSE = $(Q:@=@echo ' SPARSE '$@;)$(SPARSE)
  11. else
  12. QUIET_SPARSE = @/bin/true
  13. endif
  14. PREFIX ?= /usr/local
  15. CFLAGS += -std=c99 -O2 -fomit-frame-pointer -Wall -D_BSD_SOURCE
  16. LDFLAGS ?=
  17. SRCS = ssb_sprom.c utils.c
  18. BIN = ssb-sprom
  19. .SUFFIXES:
  20. .PHONY: all install clean distclean
  21. .DEFAULT_GOAL := all
  22. DEPS = $(sort $(patsubst %.c,dep/%.d,$(1)))
  23. OBJS = $(sort $(patsubst %.c,obj/%.o,$(1)))
  24. # Generate dependencies
  25. $(call DEPS,$(SRCS)): dep/%.d: %.c
  26. @mkdir -p $(dir $@)
  27. $(QUIET_DEPEND) -o $@.tmp -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f $@.tmp $@
  28. -include $(call DEPS,$(SRCS))
  29. # Generate object files
  30. $(call OBJS,$(SRCS)): obj/%.o:
  31. @mkdir -p $(dir $@)
  32. $(QUIET_SPARSE) $(SPARSEFLAGS) $<
  33. $(QUIET_CC) -o $@ -c $(CFLAGS) $<
  34. all: $(BIN)
  35. $(BIN): $(call OBJS,$(SRCS))
  36. $(QUIET_CC) $(CFLAGS) -o $(BIN) $(call OBJS,$(SRCS)) $(LDFLAGS)
  37. install: all
  38. install -o 0 -g 0 -m 755 $(BIN) $(PREFIX)/bin/
  39. clean:
  40. -rm -Rf obj dep *~ *.orig *.rej
  41. distclean: clean
  42. -rm -f $(BIN)