summaryrefslogtreecommitdiff
path: root/etc/Makefile.inc
blob: 50ac4975ca55625d7c8b0c9b40b3784c8c7c4740 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#	$OpenBSD: Makefile.inc,v 1.7 2010/06/16 23:33:38 todd Exp $

M=${.CURDIR:C/^.*\/etc\.([^\/]*)$/\1/}

DOCDIR=	${.CURDIR}/../../share/man/man8/man8.${M}

MAKEDEV: ${.CURDIR}/MAKEDEV ${DOCDIR}/MAKEDEV.8

# set 'NOCLEAN=:' to debug

MAKEDEVSRC=	${.CURDIR}/../MAKEDEV.mi
MAKEDEVSRC+=	${.CURDIR}/../MAKEDEV.sub
MAKEDEVSRC+=	${.CURDIR}/../MAKEDEV.common
MAKEDEVSRC+=	MAKEDEV.md

${.CURDIR}/MAKEDEV: ${MAKEDEVSRC}
	@if m4 -I${.CURDIR}/.. -I${.CURDIR} \
	    ${.CURDIR}/../MAKEDEV.mi > MAKEDEV.tmp; then \
	    if ! [ -f ${.CURDIR}/MAKEDEV ]; then \
		echo "    m4 -I.. -I. ../MAKEDEV.mi > MAKEDEV"; \
		cp MAKEDEV.tmp ${.CURDIR}/MAKEDEV; \
		${NOCLEAN} rm MAKEDEV.tmp; \
		exit 0; \
	    fi; \
	    diff MAKEDEV.tmp ${.CURDIR}/MAKEDEV > diffout1 || true; \
	    sed -e 's/^--.*$$//' \
		-e 's/^[\<\>] #.*OpenBSD.*Exp $$//' \
		-e 's/^[0-9,]*c[0-9,]*$$//' \
		-e '/^$$/d' \
		diffout1 > diffout2; \
	    if [ -s diffout2 ]; then \
		echo "    m4 -I.. -I. ../MAKEDEV.mi > MAKEDEV"; \
		cp MAKEDEV.tmp ${.CURDIR}/MAKEDEV || true; \
		${NOCLEAN} rm MAKEDEV.tmp; \
	    fi; \
	    ${NOCLEAN} rm -f diffout1 diffout2; \
	fi; ${NOCLEAN} rm -f MAKEDEV.tmp

MAKEDEVDOC=	${.CURDIR}/../MAKEDEV.man
MAKEDEVDOC+=	${.CURDIR}/../MAKEDEV.mansub
MAKEDEVDOC+=	${.CURDIR}/../MAKEDEV.common
MAKEDEVDOC+=	MAKEDEV.md

${DOCDIR}/MAKEDEV.8: ${MAKEDEVDOC}
	@if m4 -I${.CURDIR}/.. -I${.CURDIR} \
	    ${.CURDIR}/../MAKEDEV.man > MAKEDEV.mtmp; then \
	    if ! [ -f ${DOCDIR}/MAKEDEV.8 ]; then \
		echo "    m4 -I.. -I. ../MAKEDEV.man > ${DOCDIR}/MAKEDEV.8"; \
		cp MAKEDEV.mtmp ${DOCDIR}/MAKEDEV.8; \
		${NOCLEAN} rm MAKEDEV.mtmp; \
		exit 0; \
	    fi; \
	    diff MAKEDEV.mtmp ${DOCDIR}/MAKEDEV.8 > mdiffout1 || true; \
	    sed -e 's/^--.*$$//' \
		-e 's/^[\<\>] \.\\".*OpenBSD.*Exp $$//' \
		-e 's/^[\<\>] \.\\".*\$$OpenBSD.*\$$$$//' \
		-e 's/^[\<\>] \.Dd \$$Mdocdate.*\$$$$//' \
		-e 's/^[\<\>] \.Dd .*[0-9][0-9][0-9][0-9]$$//' \
		-e 's/^[0-9,]*c[0-9,]*$$//' \
		-e '/^$$/d' \
		mdiffout1 > mdiffout2; \
	    if [ -s mdiffout2 ]; then \
		echo "    m4 -I.. -I. ../MAKEDEV.man > ${DOCDIR}/MAKEDEV.8"; \
	    	cp MAKEDEV.mtmp ${DOCDIR}/MAKEDEV.8 || true; \
		${NOCLEAN} rm MAKEDEV.mtmp; \
	    fi; \
	    ${NOCLEAN} rm -f mdiffout1 mdiffout2; \
	fi; ${NOCLEAN} rm -f MAKEDEV.mtmp

.PHONY: ${.CURDIR}/MAKEDEV ${DOCDIR}/MAKEDEV.8