Support gmake-3 and gmake-4
[openresolv] / Makefile
1 NAME=           openresolv
2 VERSION=        3.5.6
3 PKG=            ${NAME}-${VERSION}
4
5 # Nasty hack so that make clean works without configure being run
6 _CONFIG_MK!=    test -e config.mk && echo config.mk || echo config-null.mk
7 CONFIG_MK?=     ${_CONFIG_MK}
8 include         ${CONFIG_MK}
9
10 SBINDIR?=       /sbin
11 SYSCONFDIR?=    /etc
12 LIBEXECDIR?=    /libexec/resolvconf
13 VARDIR?=        /var/run/resolvconf
14 RCDIR?=         /etc/rc.d
15 RESTARTCMD?=    if ${RCDIR}/\1 status >/dev/null 2>\&1; then \
16                         ${RCDIR}/\1 restart; \
17                 fi
18
19 INSTALL?=       install
20 SED?=           sed
21
22 BINMODE?=       0755
23 DOCMODE?=       0644
24 MANMODE?=       0444
25
26 RESOLVCONF=     resolvconf resolvconf.8 resolvconf.conf.5
27 SUBSCRIBERS=    libc dnsmasq named pdnsd unbound
28 TARGET=         ${RESOLVCONF} ${SUBSCRIBERS}
29 SRCS=           ${TARGET:C,$,.in,} # pmake
30 SRCS:=          ${TARGET:=.in} # gmake
31
32 SED_SBINDIR=            -e 's:@SBINDIR@:${SBINDIR}:g'
33 SED_SYSCONFDIR=         -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
34 SED_LIBEXECDIR=         -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
35 SED_VARDIR=             -e 's:@VARDIR@:${VARDIR}:g'
36 SED_RCDIR=              -e 's:@RCDIR@:${RCDIR}:g'
37 SED_RESTARTCMD=         -e 's:@RESTARTCMD \(.*\)@:${RESTARTCMD}:g'
38
39 .SUFFIXES: .in
40
41 all: ${TARGET}
42
43 .in:
44         ${SED}  ${SED_SBINDIR} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
45                 ${SED_VARDIR} ${SED_RCDIR} ${SED_RESTARTCMD} \
46                 $< > $@
47
48 clean:
49         rm -f ${TARGET} openresolv-${VERSION}.tar.bz2
50
51 distclean: clean
52         rm -f config.mk
53
54 installdirs:
55
56 install: ${TARGET}
57         ${INSTALL} -d ${DESTDIR}${SBINDIR}
58         ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${SBINDIR}
59         ${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
60         test -e ${DESTDIR}${SYSCONFDIR}/resolvconf.conf || \
61         ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
62         ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
63         ${INSTALL} -m ${DOCMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
64         ${INSTALL} -d ${DESTDIR}${MANDIR}/man8
65         ${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
66         ${INSTALL} -d ${DESTDIR}${MANDIR}/man5
67         ${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
68
69 import:
70         rm -rf /tmp/${PKG}
71         ${INSTALL} -d /tmp/${PKG}
72         cp README ${SRCS} /tmp/${PKG}
73
74 dist: import
75         cp configure Makefile resolvconf.conf /tmp/${PKG}
76         tar cvjpf ${PKG}.tar.bz2 -C /tmp ${PKG} 
77         rm -rf /tmp/${PKG} 
78         ls -l ${PKG}.tar.bz2