Simplify autodep handling for Make, thank you GCC.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-01-30 22:49:37 +01:00
1 parent e6a27743a4
commit b55702a97d
1 file changed
+4 -14
+4 -14
View File
@@ -49,23 +49,18 @@ HEADER = uev.h
OBJS := main.o io.o timer.o signal.o OBJS := main.o io.o timer.o signal.o
SRCS := $(OBJS:.o=.c) SRCS := $(OBJS:.o=.c)
DEPS := $(addprefix .,$(SRCS:.c=.d)) DEPS := $(SRCS:.c=.d)
VER = 1 VER = 1
SOLIB = $(LIBNAME).so.$(VER) SOLIB = $(LIBNAME).so.$(VER)
SYMLIB = $(LIBNAME).so SYMLIB = $(LIBNAME).so
STATICLIB = $(LIBNAME).a STATICLIB = $(LIBNAME).a
TARGET = $(STATICLIB) $(SOLIB) TARGET = $(STATICLIB) $(SOLIB)
# Pattern rules # Pretty printing and GCC -M for auto dep files
.c.o: %.o: %.c
@printf " CC $(subst $(ROOTDIR)/,,$(shell pwd)/)$@\n" @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 # Build rules
all: $(TARGET) all: $(TARGET)
@@ -128,9 +123,4 @@ dist:
@(cd ..; md5sum $(ARCHIVE) | tee $(ARCHIVE).md5) @(cd ..; md5sum $(ARCHIVE) | tee $(ARCHIVE).md5)
# Include automatically generated rules # Include automatically generated rules
ifneq ($(MAKECMDGOALS),clean)
ifneq ($(MAKECMDGOALS),distclean)
-include $(DEPS) -include $(DEPS)
endif
endif