From b55702a97d7dde08dcca388f72474cd4a5573fca Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Fri, 30 Jan 2015 22:47:48 +0100 Subject: [PATCH] Simplify autodep handling for Make, thank you GCC. Signed-off-by: Joachim Nilsson --- Makefile | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index f93c88a..89240aa 100644 --- a/Makefile +++ b/Makefile @@ -49,23 +49,18 @@ HEADER = uev.h OBJS := main.o io.o timer.o signal.o SRCS := $(OBJS:.o=.c) -DEPS := $(addprefix .,$(SRCS:.c=.d)) +DEPS := $(SRCS:.c=.d) VER = 1 SOLIB = $(LIBNAME).so.$(VER) SYMLIB = $(LIBNAME).so STATICLIB = $(LIBNAME).a TARGET = $(STATICLIB) $(SOLIB) -# Pattern rules -.c.o: +# Pretty printing and GCC -M for auto dep files +%.o: %.c @printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n" - @$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $< + @$(CC) $(CFLAGS) $(CPPFLAGS) -c -MMD -MP -o $@ $< -# Smart autodependecy generation via GCC -M. -.%.d: %.c - @$(SHELL) -ec "$(CC) -MM $(CFLAGS) $(CPPFLAGS) $< 2>/dev/null \ - | sed 's,.*: ,$*.o $@ : ,g' > $@; \ - [ -s $@ ] || rm -f $@" # Build rules all: $(TARGET) @@ -128,9 +123,4 @@ dist: @(cd ..; md5sum $(ARCHIVE) | tee $(ARCHIVE).md5) # Include automatically generated rules -ifneq ($(MAKECMDGOALS),clean) -ifneq ($(MAKECMDGOALS),distclean) -include $(DEPS) -endif -endif -