Use a configure command instead of working things out in the Makefile.
[openresolv] / Makefile
index 4d1c89a36368bfb04c30ee19760c8c9f9d4eb1ca..75835dac8f49984e04ab04ed665598f16ac8eaf5 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,61 +1,36 @@
+include config.mk
+
 NAME=          openresolv
 VERSION=       3.3.6
 PKG=           ${NAME}-${VERSION}
 
 INSTALL?=      install
 SED?=          sed
-#PREFIX?=      /usr/local
-MANPREFIX?=    /usr/share
-VARBASE?=      /var
 
 BINMODE?=      0755
 DOCMODE?=      0644
 MANMODE?=      0444
 
-SYSCONFDIR?=   ${PREFIX}/etc
-BINDIR=                ${PREFIX}/sbin
-LIBEXECDIR?=   ${PREFIX}/libexec/resolvconf
-VARDIR?=       ${VARBASE}/run/resolvconf
-MANDIR?=       ${MANPREFIX}/man
-
 RESOLVCONF=    resolvconf resolvconf.8 resolvconf.conf.5
 SUBSCRIBERS=   libc dnsmasq named pdnsd unbound
 TARGET=                ${RESOLVCONF} ${SUBSCRIBERS}
 SRCS=          ${TARGET:C,$,.in,} # pmake
 SRCS:=         ${TARGET:=.in} # gmake
 
-# Try to embed correct service restart commands
-_CMD1=         \\1 status >/dev/null 2>\\&1
-_CMD2=         \\1 restart
-_CMD_SH=if [ -x /sbin/rc-service ]; then \
-               printf '/sbin/rc-service -e \\1 \\&\\& /sbin/rc-service \\1 -- -Ds restart'; \
-       elif [ -x /usr/sbin/invoke-rc.d ]; then \
-               printf '/usr/sbin/invoke-rc.d --query --quiet \\1 restart || [ \\\\$$? = 104 ] \\&\\& /usr/sbin/invoke-rc.d ${_CMD2}'; \
-       elif [ -x /sbin/service ]; then \
-               printf '/sbin/service ${_CMD1} \\&\\& /sbin/service ${_CMD2}'; \
-       elif [ -d /usr/local/etc/rc.d ]; then \
-               printf 'if /usr/local/etc/rc.d/${_CMD1}; then'; \
-               printf ' /usr/local/etc/rc.d/${_CMD2}; '; \
-               printf 'elif /etc/rc.d/${_CMD1}; then /etc/rc.d/${_CMD2}; fi'; \
-       elif [ -d /etc/rc.d ]; then \
-               printf '/etc/rc.d/${_CMD1} \\&\\& /etc/rc.d/${_CMD2}'; \
-       elif [ -d /etc/init.d ]; then \
-               printf '/etc/init.d/${_CMD1} \\&\\& /etc/init.d/${_CMD2}'; \
-       fi;
-_CMD!=         ${_CMD_SH}
-RESTARTCMD?=   ${_CMD}$(shell ${_CMD_SH})
+SED_PREFIX=            -e 's:@PREFIX@:${PREFIX}:g'
+SED_SYSCONFDIR=                -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
+SED_LIBEXECDIR=                -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
+SED_VARDIR=            -e 's:@VARDIR@:${VARDIR}:g'
+SED_RESTARTCMD=                -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD}:g'
 
 .SUFFIXES: .in
 
 all: ${TARGET}
 
 .in:
-       ${SED} -e 's:@PREFIX@:${PREFIX}:g' \
-               -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' \
-               -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' \
-               -e 's:@VARDIR@:${VARDIR}:g' \
-               -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD}:g' \
-               $@.in > $@
+       ${SED}  ${SED_PREFIX} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
+               ${SED_VARDIR} ${SED_RESTARTCMD} \
+               $< > $@
 
 clean:
        rm -f ${TARGET} openresolv-${VERSION}.tar.bz2
@@ -63,8 +38,8 @@ clean:
 installdirs:
 
 install: ${TARGET}
-       ${INSTALL} -d ${DESTDIR}${BINDIR}
-       ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${BINDIR}
+       ${INSTALL} -d ${DESTDIR}${SBINDIR}
+       ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${SBINDIR}
        ${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
        test -e ${DESTDIR}${SYSCONFDIR}/resolvconf.conf || \
        ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}