From f2d6dc360a7385dd490832bf9fb391addcb250a0 Mon Sep 17 00:00:00 2001 From: Lars-Dominik Braun Date: Sun, 24 Jun 2012 21:01:23 +0200 Subject: Auto-dependency generation Modified example from GNU make manual[1] and [2]. Closes #221. [1] http://www.gnu.org/software/make/manual/make.html#Automatic-Prerequisites [2] http://make.paulandlesley.org/autodep.html --- Makefile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index d48a56e..aaed094 100644 --- a/Makefile +++ b/Makefile @@ -115,6 +115,21 @@ libpiano.so.0: ${LIBPIANO_RELOBJ} ${LIBPIANO_HDR} ${LIBWAITRESS_RELOBJ} \ @echo " AR libpiano.a" @${AR} rcs libpiano.a ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} + +# build dependency files +%.d: %.c + @set -e; rm -f $@; \ + $(CC) -M ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ + ${LIBFAAD_CFLAGS} ${LIBMAD_CFLAGS} ${LIBGNUTLS_CFLAGS} \ + ${LIBGCRYPT_CFLAGS} ${LIBJSONC_CFLAGS} $< > $@.$$$$; \ + sed '1 s,^.*\.o[ :]*,$*.o $@ : ,g' < $@.$$$$ > $@; \ + rm -f $@.$$$$ + +-include $(PIANOBAR_SRC:.c=.d) +-include $(LIBPIANO_SRC:.c=.d) +-include $(LIBWAITRESS_SRC:.c=.d) + +# build standard object files %.o: %.c @echo " CC $<" @${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ @@ -132,7 +147,8 @@ clean: @echo " CLEAN" @${RM} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} ${LIBWAITRESS_OBJ}/test.o \ ${LIBPIANO_RELOBJ} ${LIBWAITRESS_RELOBJ} pianobar libpiano.so* \ - libpiano.a waitress-test + libpiano.a waitress-test $(PIANOBAR_SRC:.c=.d) $(LIBPIANO_SRC:.c=.d) \ + $(LIBWAITRESS_SRC:.c=.d) all: pianobar -- cgit v1.2.3