xref: /freebsd/contrib/openresolv/Makefile (revision 5dae51da3da0cc94d17bd67b308fad304ebec7e0)
1PKG=		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
5CONFIG_MK?=	${_CONFIG_MK}
6include		${CONFIG_MK}
7
8SBINDIR?=	/sbin
9SYSCONFDIR?=	/etc
10LIBEXECDIR?=	/libexec/resolvconf
11VARDIR?=	/var/run/resolvconf
12
13INSTALL?=	install
14SED?=		sed
15
16VERSION!=	${SED} -n 's/OPENRESOLV_VERSION="\(.*\)".*/\1/p' resolvconf.in
17
18BINMODE?=	0755
19DOCMODE?=	0644
20MANMODE?=	0444
21
22RESOLVCONF=	resolvconf resolvconf.8 resolvconf.conf.5
23SUBSCRIBERS=	libc dnsmasq named pdnsd unbound
24TARGET=		${RESOLVCONF} ${SUBSCRIBERS}
25SRCS=		${TARGET:C,$,.in,} # pmake
26SRCS:=		${TARGET:=.in} # gmake
27
28SED_SBINDIR=		-e 's:@SBINDIR@:${SBINDIR}:g'
29SED_SYSCONFDIR=		-e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
30SED_LIBEXECDIR=		-e 's:@LIBEXECDIR@:${LIBEXECDIR}:g'
31SED_VARDIR=		-e 's:@VARDIR@:${VARDIR}:g'
32SED_RCDIR=		-e 's:@RCDIR@:${RCDIR}:g'
33SED_RESTARTCMD=		-e 's:@RESTARTCMD@:${RESTARTCMD}:g'
34SED_RCDIR=		-e 's:@RCDIR@:${RCDIR}:g'
35SED_STATUSARG=		-e 's:@STATUSARG@:${STATUSARG}:g'
36
37DISTPREFIX?=	${PKG}-${VERSION}
38DISTFILEGZ?=	${DISTPREFIX}.tar.gz
39DISTFILE?=	${DISTPREFIX}.tar.xz
40FOSSILID?=	current
41
42.SUFFIXES: .in
43
44all: ${TARGET}
45
46.in: Makefile ${CONFIG_MK}
47	${SED}	${SED_SBINDIR} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
48		${SED_VARDIR} \
49		${SED_RCDIR} ${SED_RESTARTCMD} ${SED_RCDIR} ${SED_STATUSARG} \
50		$< > $@
51
52clean:
53	rm -f ${TARGET}
54
55distclean: clean
56	rm -f config.mk ${DISTFILE}
57
58installdirs:
59
60proginstall: ${TARGET}
61	${INSTALL} -d ${DESTDIR}${SBINDIR}
62	${INSTALL} -m ${BINMODE} resolvconf ${DESTDIR}${SBINDIR}
63	${INSTALL} -d ${DESTDIR}${SYSCONFDIR}
64	test -e ${DESTDIR}${SYSCONFDIR}/resolvconf.conf || \
65	${INSTALL} -m ${DOCMODE} resolvconf.conf ${DESTDIR}${SYSCONFDIR}
66	${INSTALL} -d ${DESTDIR}${LIBEXECDIR}
67	${INSTALL} -m ${DOCMODE} ${SUBSCRIBERS} ${DESTDIR}${LIBEXECDIR}
68
69maninstall:
70	${INSTALL} -d ${DESTDIR}${MANDIR}/man8
71	${INSTALL} -m ${MANMODE} resolvconf.8 ${DESTDIR}${MANDIR}/man8
72	${INSTALL} -d ${DESTDIR}${MANDIR}/man5
73	${INSTALL} -m ${MANMODE} resolvconf.conf.5 ${DESTDIR}${MANDIR}/man5
74
75install: proginstall maninstall
76
77import:
78	rm -rf /tmp/${DISTPREFIX}
79	${INSTALL} -d /tmp/${DISTPREFIX}
80	cp README ${SRCS} /tmp/${DISTPREFIX}
81
82dist:
83	fossil tarball --name ${DISTPREFIX} ${FOSSILID} ${DISTFILEGZ}
84	gunzip -c ${DISTFILEGZ} | xz >${DISTFILE}
85	rm ${DISTFILEGZ}
86