Makefile 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # The toolchain definitions
  2. CC = gcc
  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 ?= -O2 -fomit-frame-pointer -pipe
  16. CFLAGS += -std=gnu99 -D_GNU_SOURCE \
  17. -Wall -Wextra -Wformat=2 -Wundef -Wno-unused-parameter \
  18. -Wshadow -Wpointer-arith
  19. SPARSEFLAGS = $(CFLAGS) -D__transparent_union__=__unused__ -D_STRING_ARCH_unaligned=1
  20. LDFLAGS ?=
  21. BIN = b43-dasm
  22. SRCS = main.c util.c args.c
  23. .SUFFIXES:
  24. .PHONY: all install clean distclean
  25. .DEFAULT_GOAL := all
  26. DEPS = $(sort $(patsubst %.c,dep/%.d,$(1)))
  27. OBJS = $(sort $(patsubst %.c,obj/%.o,$(1)))
  28. # Generate dependencies
  29. $(call DEPS,$(SRCS)): dep/%.d: %.c
  30. @mkdir -p $(dir $@)
  31. $(QUIET_DEPEND) -o $@.tmp -MM -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f $@.tmp $@
  32. -include $(call DEPS,$(SRCS))
  33. # Generate object files
  34. $(call OBJS,$(SRCS)): obj/%.o:
  35. @mkdir -p $(dir $@)
  36. $(QUIET_SPARSE) $(SPARSEFLAGS) $<
  37. $(QUIET_CC) -o $@ -c $(CFLAGS) $<
  38. all: $(BIN)
  39. $(BIN): $(call OBJS,$(SRCS))
  40. $(QUIET_CC) $(CFLAGS) -o $(BIN) $(call OBJS,$(SRCS)) $(LDFLAGS)
  41. install: all
  42. install -m 755 $(BIN) $(PREFIX)/bin/
  43. install -m 755 b43-ivaldump $(PREFIX)/bin/
  44. install -m 755 brcm80211-ivaldump $(PREFIX)/bin/
  45. install -m 755 brcm80211-fwconv $(PREFIX)/bin/
  46. clean:
  47. -rm -Rf obj dep *~ *.orig *.rej
  48. distclean: clean
  49. -rm -f $(BIN)