Use printf to get exact escaping for sed.
[openresolv] / Makefile
1 NAME=           openresolv
2 VERSION=        3.2
3 PKG=            ${NAME}-${VERSION}
4
5 INSTALL?=       install
6 SED?=           sed
7 PREFIX?=        /usr/local
8 MANPREFIX?=     /usr/share
9 VARBASE?=       /var
10
11 BINMODE?=       0755
12 DOCMODE?=       0644
13 MANMODE?=       0444
14
15 SYSCONFDIR?=    ${PREFIX}/etc
16 BINDIR=         ${PREFIX}/sbin
17 LIBEXECDIR?=    ${PREFIX}/libexec/resolvconf
18 VARDIR?=        ${VARBASE}/run/resolvconf
19 MANDIR?=        ${MANPREFIX}/man
20
21 RESOLVCONF=     resolvconf resolvconf.8 resolvconf.conf.5
22 SUBSCRIBERS=    libc dnsmasq named pdns_recursor
23 TARGET=         ${RESOLVCONF} ${SUBSCRIBERS}
24
25 _CMD_SH=if [ -x /sbin/rc-service ]; then \
26                 printf '/sbin/rc-service \\1 -- --ifstarted restart'; \
27         elif [ -d /etc/rc.d ]; then \
28                 printf '/etc/rc.d/\\1 status \\&\\& /etc/rc.d/\\1 restart'; \
29         elif [ -d /etc/init.d ]; then \
30                 printf '/etc/init.d/\\1 status \\&\\& /etc/rc.d/\\1 restart'; \
31         fi
32 _CMD!=          ${_CMD_SH}
33 RESTARTCMD?=    ${_CMD}$(shell ${_CMD_SH})
34
35 .SUFFIXES: .in
36
37 all: ${TARGET}
38
39 .in:
40         ${SED} -e 's:@PREFIX@:${PREFIX}:g' \
41                 -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g' \
42                 -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g' \
43                 -e 's:@VARDIR@:${VARDIR}:g' \
44                 -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD}:g' \
45                 $@.in > $@
46
47 clean:
48         rm -f ${TARGET} openresolv-${VERSION}.tar.bz2
49
50 installdirs:
51
52 install: ${TARGET}
53         ${INSTALL} -d ${DESTDIR}${BINDIR}
54         ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${BINDIR}
55         ${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
56         ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
57         ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
58         ${INSTALL} -m ${BINMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
59         ${INSTALL} -d ${DESTDIR}${MANDIR}/man8
60         ${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
61         ${INSTALL} -d ${DESTDIR}${MANDIR}/man5
62         ${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
63
64 dist:
65         ${INSTALL} -d /tmp/${PKG}
66         cp -RPp . /tmp/${PKG}
67         (cd /tmp/${PKG}; ${MAKE} clean)
68         rm -rf /tmp/${PKG}/*.bz2 /tmp/${PKG}/.svn
69         tar cvjpf ${PKG}.tar.bz2 -C /tmp ${PKG} 
70         rm -rf /tmp/${PKG} 
71         ls -l ${PKG}.tar.bz2