From 2cb9ee566f035acad146dc2c3c0b2de675469f02 Mon Sep 17 00:00:00 2001 From: Michael Buesch Date: Thu, 26 Nov 2009 15:22:55 +0100 Subject: [PATCH] fwcutter: Add sparse support, Add quiet build, Add autodependencies Signed-off-by: Michael Buesch --- fwcutter/Makefile | 63 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 46 insertions(+), 17 deletions(-) diff --git a/fwcutter/Makefile b/fwcutter/Makefile index 2eb2e84..197ddef 100644 --- a/fwcutter/Makefile +++ b/fwcutter/Makefile @@ -1,34 +1,63 @@ VERSION = 012 -CC ?= cc -PREFIX ?= /usr/local -CFLAGS ?= -Os -fomit-frame-pointer -CFLAGS += -std=c99 -Wall -pedantic -D_BSD_SOURCE -LDFLAGS ?= +# The toolchain definitions +CC = cc +SPARSE = sparse + +V = @ # Verbose build: make V=1 +C = 0 # Sparsechecker build: make C=1 +Q = $(V:1=) +QUIET_CC = $(Q:@=@echo ' CC '$@;)$(CC) +QUIET_DEPEND = $(Q:@=@echo ' DEPEND '$@;)$(CC) +ifeq ($(C),1) +QUIET_SPARSE = $(Q:@=@echo ' SPARSE '$@;)$(SPARSE) +else +QUIET_SPARSE = @/bin/true +endif +PREFIX ?= /usr/local +CFLAGS ?= -Os -fomit-frame-pointer +CFLAGS += -std=c99 -Wall -pedantic -D_BSD_SOURCE +LDFLAGS ?= -OBJECTS = fwcutter.o md5.o +SRCS = fwcutter.c md5.c BIN = b43-fwcutter CFLAGS += -DFWCUTTER_VERSION_=$(VERSION) -all: $(BIN) +.SUFFIXES: +.PHONY: all install clean distclean +.DEFAULT_GOAL := all + +DEPS = $(sort $(patsubst %.c,dep/%.d,$(1))) +OBJS = $(sort $(patsubst %.c,obj/%.o,$(1))) -fwcutter.o: fwcutter.h fwcutter_list.h md5.h +# Generate dependencies +$(call DEPS,$(SRCS)): dep/%.d: %.c + @mkdir -p $(dir $@) + $(QUIET_DEPEND) -o $@.tmp -MM -MG -MT "$@ $(patsubst dep/%.d,obj/%.o,$@)" $(CFLAGS) $< && mv -f $@.tmp $@ -md5.o: md5.h +-include $(call DEPS,$(SRCS)) + +# Generate object files +$(call OBJS,$(SRCS)): obj/%.o: + @mkdir -p $(dir $@) + $(QUIET_SPARSE) $(SPARSEFLAGS) $< + $(QUIET_CC) -o $@ -c $(CFLAGS) $< + +all: $(BIN) -$(BIN): $(OBJECTS) - $(CC) $(CFLAGS) -o $(BIN) $(OBJECTS) $(LDFLAGS) +$(BIN): $(call OBJS,$(SRCS)) + $(QUIET_CC) $(CFLAGS) -o $(BIN) $(call OBJS,$(SRCS)) $(LDFLAGS) install: all - -install -d -o 0 -g 0 -m 755 $(PREFIX)/bin/ - -install -o 0 -g 0 -m 755 $(BIN) $(PREFIX)/bin/ - -install -d -o 0 -g 0 -m 755 $(PREFIX)/man/man1/ - -install -o 0 -g 0 -m 644 $(BIN).1 $(PREFIX)/man/man1/ + install -d -o 0 -g 0 -m 755 $(PREFIX)/bin/ + install -o 0 -g 0 -m 755 $(BIN) $(PREFIX)/bin/ + install -d -o 0 -g 0 -m 755 $(PREFIX)/man/man1/ + install -o 0 -g 0 -m 644 $(BIN).1 $(PREFIX)/man/man1/ clean: - -rm -f *.o $(BIN) + -rm -Rf obj dep *.orig *.rej *~ distclean: clean - -rm -f *.fw *.orig *.rej *~ + -rm -f *.fw $(BIN) -- 2.31.1