summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorLars-Dominik Braun <lars@6xq.net>2012-06-24 21:01:23 +0200
committerLars-Dominik Braun <lars@6xq.net>2012-06-24 21:01:23 +0200
commitf2d6dc360a7385dd490832bf9fb391addcb250a0 (patch)
tree2a9a67980806158fd8a9cf13515a2604172d0a81 /Makefile
parent9e5e07923e9f696a9d0da42ccc630f92bc8eba7c (diff)
downloadpianobar-windows-f2d6dc360a7385dd490832bf9fb391addcb250a0.tar.gz
pianobar-windows-f2d6dc360a7385dd490832bf9fb391addcb250a0.tar.bz2
pianobar-windows-f2d6dc360a7385dd490832bf9fb391addcb250a0.zip
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
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile18
1 files changed, 17 insertions, 1 deletions
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