From 8eed5e3ecb9d362d5d561bbc102de646347848b9 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Thu, 23 Sep 2010 20:05:25 -0300 Subject: [PATCH] Makefile cleanup and instrumentation (verbosity, dependencies, etc.) - solidify/Makefile: added verbosity control (default is silent, enable verbose output with V=1) - solidify/Makefile: added "spotless" target - solidify/Makefile (CFLAGS): moved warning options to CFLAGS_WARN - solidify/Makefile: added dependency use and generation, with friendly permission from fped/Makefile --- solidify/Makefile | 51 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 46 insertions(+), 5 deletions(-) diff --git a/solidify/Makefile b/solidify/Makefile index ab6ef27..29b52e4 100644 --- a/solidify/Makefile +++ b/solidify/Makefile @@ -1,13 +1,54 @@ -CFLAGS=-Wall -g `pkg-config --cflags gtk+-2.0` -LDFLAGS=-lm `pkg-config --libs gtk+-2.0` +SHELL = /bin/bash -OBJS=array.o face.o histo.o level.o solidify.o +OBJS = array.o face.o histo.o level.o solidify.o -.PHONY: all clean +CFLAGS_WARN = -Wall -Wshadow -Wmissing-prototypes \ + -Wmissing-declarations -Wno-format-zero-length + +CFLAGS = $(CFLAGS_WARN) -g `pkg-config --cflags gtk+-2.0` +LDFLAGS = -lm `pkg-config --libs gtk+-2.0` + +# ----- Verbosity control ----------------------------------------------------- + +CC_normal := $(CC) +DEPEND_normal := $(CPP) $(CFLAGS) -MM -MG + +CC_quiet = @echo " CC " $@ && $(CC_normal) +DEPEND_quiet = @$(DEPEND_normal) + +ifeq ($(V),1) + CC = $(CC_normal) + DEPEND = $(DEPEND_normal) +else + CC = $(CC_quiet) + DEPEND = $(DEPEND_quiet) +endif + +# ----- Rules ----------------------------------------------------------------- + +.PHONY: all clean spotless all: solidify solidify: $(OBJS) clean: - rm -f $(OBJS) + rm -f $(OBJS) $(OBJS:.o=.d) + +spotless: clean + rm -f solidify + +# ----- Dependencies ---------------------------------------------------------- + +# compile and generate dependencies, from fped, based on +# http://scottmcpeak.com/autodepend/autodepend.html + +%.o: %.c + $(CC) -c $(CFLAGS) $*.c -o $*.o + $(DEPEND) $*.c | \ + sed -e \ + '/^\(.*:\)\? */{p;s///;s/ *\\\?$$/ /;s/ */:\n/g;H;}' \ + -e '$${g;p;}' -e d >$*.d; \ + [ "$${PIPESTATUS[*]}" = "0 0" ] || { rm -f $*.d; exit 1; } + +-include $(OBJS:.o=.d)