From: Michael Buesch Date: Thu, 26 Nov 2009 14:28:21 +0000 (+0100) Subject: ssb_sprom: Add sparse support, Add quiet build, Add autodependencies X-Git-Tag: b43-fwcutter-013~5 X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=883671d1a412bb7fb9d2b112f63a3fe10d02e726;p=b43-tools.git ssb_sprom: Add sparse support, Add quiet build, Add autodependencies Signed-off-by: Michael Buesch --- diff --git a/ssb_sprom/Makefile b/ssb_sprom/Makefile index eb0eac0..01efc0e 100644 --- a/ssb_sprom/Makefile +++ b/ssb_sprom/Makefile @@ -1,22 +1,55 @@ -CC = cc -PREFIX = /usr/local -CFLAGS = -std=c99 -O2 -fomit-frame-pointer -Wall -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 -OBJECTS = ssb_sprom.o utils.o +PREFIX ?= /usr/local +CFLAGS += -std=c99 -O2 -fomit-frame-pointer -Wall -D_BSD_SOURCE +LDFLAGS ?= -all: ssb_sprom +SRCS = ssb_sprom.c utils.c +BIN = ssb_sprom -ssb_sprom: $(OBJECTS) - $(CC) $(CFLAGS) -o ssb-sprom $(OBJECTS) $(LDFLAGS) +.SUFFIXES: +.PHONY: all install clean distclean +.DEFAULT_GOAL := all + +DEPS = $(sort $(patsubst %.c,dep/%.d,$(1))) +OBJS = $(sort $(patsubst %.c,obj/%.o,$(1))) + +# 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 $@ + +-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): $(call OBJS,$(SRCS)) + $(QUIET_CC) $(CFLAGS) -o $(BIN) $(call OBJS,$(SRCS)) $(LDFLAGS) install: all - -install -o 0 -g 0 -m 755 ssb-sprom $(PREFIX)/bin/ + install -o 0 -g 0 -m 755 $(BIN) $(PREFIX)/bin/ clean: - -rm -f *~ *.o *.orig *.rej ssb-sprom + -rm -Rf obj dep *~ *.orig *.rej -# dependencies -ssb_sprom.o: ssb_sprom.h utils.h -utils.o: utils.h ssb_sprom.h +distclean: clean + -rm -f $(BIN)