$OpenBSD: patch-Makefile,v 1.16 2012/05/10 11:23:18 dcoppa Exp $ Use pkg-config for libmad and gnutls (upstream git commit eee4424677964ddc5b0f01d120db71f160a7c9e1) Correct LDFLAGS for pianobar/libpiano linking (upstream git commit c9aff4f4ceddc70b8b98ca8d5d248eac6be2619f) --- Makefile.orig Sun May 6 16:33:54 2012 +++ Makefile Thu May 10 13:12:13 2012 @@ -6,15 +6,8 @@ LIBDIR:=${PREFIX}/lib INCDIR:=${PREFIX}/include MANDIR:=${PREFIX}/share/man DYNLINK:=0 +CFLAGS+=-std=c99 -fgnu89-inline -# Respect environment variables set by user; does not work with := -ifeq (${CFLAGS},) - CFLAGS=-O2 -DNDEBUG -endif -ifeq (${CC},cc) - CC=c99 -endif - PIANOBAR_DIR=src PIANOBAR_SRC=\ ${PIANOBAR_DIR}/main.c \ @@ -73,11 +66,12 @@ ifeq (${DISABLE_MAD}, 1) LIBMAD_LDFLAGS= else LIBMAD_CFLAGS=-DENABLE_MAD - LIBMAD_LDFLAGS=-lmad + LIBMAD_CFLAGS+=$(shell pkg-config --cflags mad) + LIBMAD_LDFLAGS=$(shell pkg-config --libs mad) endif -LIBGNUTLS_CFLAGS= -LIBGNUTLS_LDFLAGS=-lgnutls +LIBGNUTLS_CFLAGS=$(shell pkg-config --cflags gnutls) +LIBGNUTLS_LDFLAGS=$(shell pkg-config --libs gnutls) LIBGCRYPT_CFLAGS= LIBGCRYPT_LDFLAGS=-lgcrypt @@ -87,50 +81,40 @@ LIBJSONC_LDFLAGS=$(shell pkg-config --libs json) # build pianobar ifeq (${DYNLINK},1) -pianobar: ${PIANOBAR_OBJ} ${PIANOBAR_HDR} libpiano.so.0 - @echo " LINK $@" - @${CC} -o $@ ${PIANOBAR_OBJ} ${LDFLAGS} -lao -lpthread -lm -L. -lpiano \ - ${LIBFAAD_LDFLAGS} ${LIBMAD_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \ - ${LIBGCRYPT_LDFLAGS} ${LIBJSONC_LDFLAGS} +pianobar: ${PIANOBAR_OBJ} ${PIANOBAR_HDR} libpiano.so.${LIBpiano_VERSION} + ${CC} -o $@ ${PIANOBAR_OBJ} ${LDFLAGS} -lao -pthread -lm -L. -lpiano \ + ${LIBFAAD_LDFLAGS} ${LIBMAD_LDFLAGS} ${LIBGNUTLS_LDFLAGS} else pianobar: ${PIANOBAR_OBJ} ${PIANOBAR_HDR} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} \ ${LIBWAITRESS_HDR} - @echo " LINK $@" - @${CC} ${CFLAGS} ${LDFLAGS} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} \ - ${LIBWAITRESS_OBJ} -lao -lpthread -lm \ + ${CC} ${CFLAGS} ${LDFLAGS} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} \ + ${LIBWAITRESS_OBJ} -lao -pthread -lm \ ${LIBFAAD_LDFLAGS} ${LIBMAD_LDFLAGS} ${LIBGNUTLS_LDFLAGS} \ ${LIBGCRYPT_LDFLAGS} ${LIBJSONC_LDFLAGS} -o $@ endif # build shared and static libpiano -libpiano.so.0: ${LIBPIANO_RELOBJ} ${LIBPIANO_HDR} ${LIBWAITRESS_RELOBJ} \ +libpiano.so.${LIBpiano_VERSION}: ${LIBPIANO_RELOBJ} ${LIBPIANO_HDR} ${LIBWAITRESS_RELOBJ} \ ${LIBWAITRESS_HDR} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} - @echo " LINK $@" - @${CC} -shared -Wl,-soname,libpiano.so.0 ${CFLAGS} ${LDFLAGS} \ - ${LIBGNUTLS_LDFLAGS} ${LIBGCRYPT_LDFLAGS} \ - -o libpiano.so.0.0.0 ${LIBPIANO_RELOBJ} \ + ${CC} -shared ${CFLAGS} ${LDFLAGS} \ + ${LIBGNUTLS_LDFLAGS} ${LIBGCRYPT_LDFLAGS} ${LIBJSONC_LDFLAGS} \ + -o libpiano.so.${LIBpiano_VERSION} ${LIBPIANO_RELOBJ} \ ${LIBWAITRESS_RELOBJ} - @ln -s libpiano.so.0.0.0 libpiano.so.0 - @ln -s libpiano.so.0 libpiano.so - @echo " AR libpiano.a" - @${AR} rcs libpiano.a ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} + ${AR} rcs libpiano.a ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} %.o: %.c - @echo " CC $<" - @${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ + ${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ ${LIBFAAD_CFLAGS} ${LIBMAD_CFLAGS} ${LIBGNUTLS_CFLAGS} \ ${LIBJSONC_CFLAGS} -c -o $@ $< # create position independent code (for shared libraries) %.lo: %.c - @echo " CC $< (PIC)" - @${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ - ${LIBJSONC_CFLAGS} \ - -c -fPIC -o $@ $< + ${CC} ${CFLAGS} -I ${LIBPIANO_INCLUDE} -I ${LIBWAITRESS_INCLUDE} \ + ${LIBFAAD_CFLAGS} ${LIBMAD_CFLAGS} ${LIBGNUTLS_CFLAGS} \ + ${LIBJSONC_CFLAGS} -c -fPIC -o $@ $< clean: - @echo " CLEAN" - @${RM} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} ${LIBWAITRESS_OBJ}/test.o \ + ${RM} ${PIANOBAR_OBJ} ${LIBPIANO_OBJ} ${LIBWAITRESS_OBJ} ${LIBWAITRESS_OBJ}/test.o \ ${LIBPIANO_RELOBJ} ${LIBWAITRESS_RELOBJ} pianobar libpiano.so* \ libpiano.a waitress-test @@ -177,17 +161,15 @@ else install: pianobar endif install -d ${DESTDIR}/${BINDIR}/ - install -m755 pianobar ${DESTDIR}/${BINDIR}/ + ${INSTALL_PROGRAM} pianobar ${DESTDIR}/${BINDIR}/ install -d ${DESTDIR}/${MANDIR}/man1/ - install -m644 contrib/pianobar.1 ${DESTDIR}/${MANDIR}/man1/ + ${INSTALL_MAN} contrib/pianobar.1 ${DESTDIR}/${MANDIR}/man1/ install-libpiano: install -d ${DESTDIR}/${LIBDIR}/ - install -m644 libpiano.so.0.0.0 ${DESTDIR}/${LIBDIR}/ - ln -s libpiano.so.0.0.0 ${DESTDIR}/${LIBDIR}/libpiano.so.0 - ln -s libpiano.so.0 ${DESTDIR}/${LIBDIR}/libpiano.so - install -m644 libpiano.a ${DESTDIR}/${LIBDIR}/ + ${INSTALL_DATA} libpiano.so.${LIBpiano_VERSION} ${DESTDIR}/${LIBDIR}/ + ${INSTALL_DATA} libpiano.a ${DESTDIR}/${LIBDIR}/ install -d ${DESTDIR}/${INCDIR}/ - install -m644 src/libpiano/piano.h ${DESTDIR}/${INCDIR}/ + ${INSTALL_DATA} src/libpiano/piano.h ${DESTDIR}/${INCDIR}/ .PHONY: install install-libpiano test debug all