Release openresolv-3.12.0
[openresolv] / Makefile
1 PKG=            openresolv
2
3 # Nasty hack so that make clean works without configure being run
4 _CONFIG_MK!=    test -e config.mk && echo config.mk || echo config-null.mk
5 CONFIG_MK?=     ${_CONFIG_MK}
6 include         ${CONFIG_MK}
7
8 SBINDIR?=       /sbin
9 SYSCONFDIR?=    /etc
10 LIBEXECDIR?=    /libexec/resolvconf
11 VARDIR?=        /var/run/resolvconf
12
13 ECHO?=          echo
14 INSTALL?=       install
15 SED?=           sed
16
17 VERSION!=       ${SED} -n 's/OPENRESOLV_VERSION="\(.*\)".*/\1/p' resolvconf.in
18
19 BINMODE?=       0755
20 DOCMODE?=       0644
21 MANMODE?=       0444
22
23 RESOLVCONF=             resolvconf resolvconf.8 resolvconf.conf.5
24 SUBSCRIBERS=            libc dnsmasq named pdnsd pdns_recursor unbound
25 LIBC_SUBSCRIBERS=       avahi-daemon mdnsd
26 TARGET=         ${RESOLVCONF} ${SUBSCRIBERS} ${LIBC_SUBSCRIBERS}
27 SRCS=           ${TARGET:C,$,.in,} # pmake
28 SRCS:=          ${TARGET:=.in} # gmake
29
30 SED_SBINDIR=            -e 's:@SBINDIR@:${SBINDIR}:g'
31 SED_SYSCONFDIR=         -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
32 SED_LIBEXECDIR=         -e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
33 SED_VARDIR=             -e 's:@VARDIR@:${VARDIR}:g'
34 SED_RCDIR=              -e 's:@RCDIR@:${RCDIR}:g'
35 SED_RESTARTCMD=         -e 's:@RESTARTCMD@:${RESTARTCMD}:g'
36 SED_RCDIR=              -e 's:@RCDIR@:${RCDIR}:g'
37 SED_STATUSARG=          -e 's:@STATUSARG@:${STATUSARG}:g'
38
39 DISTPREFIX?=    ${PKG}-${VERSION}
40 DISTFILEGZ?=    ${DISTPREFIX}.tar.gz
41 DISTFILE?=      ${DISTPREFIX}.tar.xz
42 DISTINFO=       ${DISTFILE}.distinfo
43 DISTINFOSIGN=   ${DISTINFO}.asc
44 CKSUM?=         cksum -a SHA256
45 PGP?=           netpgp
46
47 GITREF?=        HEAD
48
49 .SUFFIXES: .in
50
51 all: ${TARGET}
52
53 .in: Makefile ${CONFIG_MK}
54         ${SED}  ${SED_SBINDIR} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
55                 ${SED_VARDIR} \
56                 ${SED_RCDIR} ${SED_RESTARTCMD} ${SED_RCDIR} ${SED_STATUSARG} \
57                 $< > $@
58
59 clean:
60         rm -f ${TARGET}
61
62 distclean: clean
63         rm -f config.mk ${DISTFILE} ${DISTINFO} ${DISTINFOSIGN}
64
65 installdirs:
66
67 proginstall: ${TARGET}
68         ${INSTALL} -d ${DESTDIR}${SBINDIR}
69         ${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${SBINDIR}
70         ${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
71         test -e ${DESTDIR}${SYSCONFDIR}/resolvconf.conf || \
72         ${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
73         ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
74         ${INSTALL} -m ${DOCMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
75         ${INSTALL} -d ${DESTDIR}${LIBEXECDIR}/libc.d
76         ${INSTALL} -m ${DOCMODE} ${LIBC_SUBSCRIBERS} \
77                 ${DESTDIR}${LIBEXECDIR}/libc.d
78
79 maninstall:
80         ${INSTALL} -d ${DESTDIR}${MANDIR}/man8
81         ${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
82         ${INSTALL} -d ${DESTDIR}${MANDIR}/man5
83         ${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
84
85 install: proginstall maninstall
86
87 dist-git:
88         git archive --prefix=${DISTPREFIX}/ ${GITREF} | xz >${DISTFILE}
89
90 dist-inst:
91         mkdir /tmp/${DISTPREFIX}
92         cp -RPp * /tmp/${DISTPREFIX}
93         (cd /tmp/${DISTPREFIX}; make clean)
94         tar -cvjpf ${DISTFILE} -C /tmp ${DISTPREFIX}
95         rm -rf /tmp/${DISTPREFIX}
96
97 dist: dist-git
98
99 distinfo: dist
100         rm -f ${DISTINFO} ${DISTINFOSIGN}
101         ${CKSUM} ${DISTFILE} >${DISTINFO}
102         #printf "SIZE (${DISTFILE}) = %s\n" $$(wc -c <${DISTFILE}) >>${DISTINFO}
103         ${PGP} --clearsign --output=${DISTINFOSIGN} ${DISTINFO}
104         chmod 644 ${DISTINFOSIGN}
105         ls -l ${DISTFILE} ${DISTINFO} ${DISTINFOSIGN}
106
107 import: dist
108         rm -rf /tmp/${DISTPREFIX}
109         ${INSTALL} -d /tmp/${DISTPREFIX}
110         tar xvJpf ${DISTFILE} -C /tmp
111
112 _import-src:
113         rm -rf ${DESTDIR}/*
114         ${INSTALL} -d ${DESTDIR}
115         cp LICENSE README.md ${SRCS} resolvconf.conf ${DESTDIR};
116         cp resolvconf.8.in resolvconf.conf.5.in ${DESTDIR};
117         @${ECHO}
118         @${ECHO} "============================================================="
119         @${ECHO} "openresolv-${VERSION} imported to ${DESTDIR}"
120
121 import-src:
122         ${MAKE} _import-src DESTDIR=`if [ -n "${DESTDIR}" ]; then echo "${DESTDIR}"; else  echo /tmp/${DISTPREFIX}; fi`