Makefile 1.5 KB

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