Home | History | Annotate | Line # | Download | only in mk
bsd.man.mk revision 1.56
      1 #	$NetBSD: bsd.man.mk,v 1.56 2000/09/22 05:37:57 phil Exp $
      2 #	@(#)bsd.man.mk	8.1 (Berkeley) 6/8/93
      3 
      4 .if !target(__initialized__)
      5 __initialized__:
      6 .if exists(${.CURDIR}/../Makefile.inc)
      7 .include "${.CURDIR}/../Makefile.inc"
      8 .endif
      9 .include <bsd.own.mk>
     10 .include <bsd.obj.mk>
     11 .include <bsd.depall.mk>
     12 .MAIN:		all
     13 .endif
     14 
     15 .PHONY:		catinstall maninstall catpages manpages catlinks manlinks cleanman html installhtml cleanhtml
     16 .if ${MKMAN} != "no"
     17 realinstall:	${MANINSTALL}
     18 .endif
     19 cleandir distclean: cleanman
     20 
     21 TMACDIR?=	${DESTDIR}/usr/share/tmac
     22 HTMLDIR?=	${DESTDIR}/usr/share/man
     23 CATDEPS?=	${TMACDIR}/tmac.andoc \
     24 		${TMACDIR}/tmac.doc \
     25 		${TMACDIR}/tmac.doc-ditroff \
     26 		${TMACDIR}/tmac.doc-common \
     27 		${TMACDIR}/tmac.doc-nroff \
     28 		${TMACDIR}/tmac.doc-syms
     29 MANTARGET?=	cat
     30 NROFF?=		nroff -Tascii
     31 TBL?=		tbl
     32 
     33 
     34 .SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 \
     35 	   .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 .cat7 .cat8 .cat9 \
     36 	   .html1 .html2 .html3 .html4 .html5 .html6 .html7 .html8 .html9
     37 
     38 .9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1: \
     39     ${CATDEPS}
     40 .if !defined(USETBL)
     41 	@echo "${NROFF} -mandoc ${.IMPSRC} > ${.TARGET}"
     42 	@${NROFF} -mandoc ${.IMPSRC} > ${.TARGET} || \
     43 	 (rm -f ${.TARGET}; false)
     44 .else
     45 	@echo "${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET}"
     46 	@${TBL} ${.IMPSRC} | ${NROFF} -mandoc > ${.TARGET} || \
     47 	 (rm -f ${.TARGET}; false)
     48 .endif
     49 
     50 .9.html9 .8.html8 .7.html7 .6.html6 .5.html5 .4.html4 .3.html3 .2.html2 .1.html1: \
     51     ${CATDEPS}
     52 .if !defined(USETBL)
     53 	@echo "${NROFF} -mdoc2html ${.IMPSRC} > ${.TARGET}"
     54 	@${NROFF} -mdoc2html ${.IMPSRC} > ${.TARGET} || \
     55 	 (rm -f ${.TARGET}; false)
     56 .else
     57 	@echo "${TBL} ${.IMPSRC} | ${NROFF} -mdoc2html > ${.TARGET}"
     58 	@${TBL} ${.IMPSRC} | ${NROFF} -mdoc2html > ${.TARGET} || \
     59 	 (rm -f ${.TARGET}; false)
     60 .endif
     61 
     62 .if defined(MAN) && !empty(MAN)
     63 MANPAGES=	${MAN}
     64 CATPAGES=	${MANPAGES:C/(.*).([1-9])/\1.cat\2/}
     65 .NOPATH:	${CATPAGES}
     66 .if !defined(NOHTML)
     67 HTMLPAGES=	${MANPAGES:C/(.*).([1-9])/\1.html\2/}
     68 .endif
     69 .endif
     70 
     71 MINSTALL=	${INSTALL} ${RENAME} ${PRESERVE} ${COPY} ${INSTPRIV} \
     72 		    -o ${MANOWN} -g ${MANGRP} -m ${MANMODE}
     73 
     74 .if defined(MANZ)
     75 # chown and chmod are done afterward automatically
     76 MCOMPRESS=	gzip -cf
     77 MCOMPRESSSUFFIX= .gz
     78 .endif
     79 
     80 catinstall: catlinks
     81 maninstall: manlinks
     82 
     83 __installpage: .USE
     84 .if defined(MCOMPRESS) && !empty(MCOMPRESS)
     85 	@rm -f ${.TARGET}
     86 	${MCOMPRESS} ${.ALLSRC} > ${.TARGET}
     87 	@chown ${MANOWN}:${MANGRP} ${.TARGET}
     88 	@chmod ${MANMODE} ${.TARGET}
     89 .else
     90 	${MINSTALL} ${.ALLSRC} ${.TARGET}
     91 .endif
     92 
     93 
     94 # Rules for cat'ed man page installation
     95 .if defined(CATPAGES) && !empty(CATPAGES) && ${MKCATPAGES} != "no"
     96 catpages:: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
     97 .PRECIOUS: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
     98 .if !defined(UPDATE)
     99 .PHONY: ${CATPAGES:@P@${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}@}
    100 .endif
    101 
    102 .   for P in ${CATPAGES}
    103 .	if !defined(BUILD) && !make(all) && !make(${P})
    104 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: .MADE
    105 .	endif
    106 ${DESTDIR}${MANDIR}/${P:T:E}${MANSUBDIR}/${P:T:R}.0${MCOMPRESSSUFFIX}: ${P} __installpage
    107 .   endfor
    108 .else
    109 catpages::
    110 .endif
    111 
    112 # Rules for source page installation
    113 .if defined(MANPAGES) && !empty(MANPAGES)
    114 manpages:: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
    115 .PRECIOUS: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
    116 .if !defined(UPDATE)
    117 .PHONY: ${MANPAGES:@P@${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}@}
    118 .endif
    119 
    120 .   for P in ${MANPAGES}
    121 ${DESTDIR}${MANDIR}/man${P:T:E}${MANSUBDIR}/${P}${MCOMPRESSSUFFIX}: ${P} __installpage
    122 .   endfor
    123 .else
    124 manpages::
    125 .endif
    126 
    127 .if ${MKCATPAGES} != "no"
    128 catlinks: catpages
    129 .if defined(MLINKS) && !empty(MLINKS)
    130 	@set ${MLINKS}; \
    131 	while test $$# -ge 2; do \
    132 		name=$$1; \
    133 		shift; \
    134 		dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
    135 		l=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
    136 		name=$$1; \
    137 		shift; \
    138 		dir=${DESTDIR}${MANDIR}/cat$${name##*.}; \
    139 		t=$${dir}${MANSUBDIR}/$${name%.*}.0${MCOMPRESSSUFFIX}; \
    140 		if test $$l -nt $$t -o ! -f $$t; then \
    141 			echo $$t -\> $$l; \
    142 			ln -f $$l $$t; \
    143 		fi; \
    144 	done
    145 .endif
    146 .else
    147 catlinks:
    148 .endif
    149 
    150 manlinks: manpages
    151 .if defined(MLINKS) && !empty(MLINKS)
    152 	@set ${MLINKS}; \
    153 	while test $$# -ge 2; do \
    154 		name=$$1; \
    155 		shift; \
    156 		dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
    157 		l=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
    158 		name=$$1; \
    159 		shift; \
    160 		dir=${DESTDIR}${MANDIR}/man$${name##*.}; \
    161 		t=$${dir}${MANSUBDIR}/$${name}${MCOMPRESSSUFFIX}; \
    162 		if test $$l -nt $$t -o ! -f $$t; then \
    163 			echo $$t -\> $$l; \
    164 			ln -f $$l $$t; \
    165 		fi; \
    166 	done
    167 .endif
    168 
    169 # Html rules
    170 html: ${HTMLPAGES}
    171 
    172 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
    173 .for P in ${HTMLPAGES} 
    174 ${HTMLDIR}/${P:T:E}/${P:T:R}.html: ${P}
    175 	${MINSTALL} ${.ALLSRC} ${.TARGET}
    176 .endfor
    177 .endif
    178 installhtml: ${HTMLPAGES:@P@${HTMLDIR}/${P:T:E}/${P:T:R}.html@}
    179 
    180 cleanhtml:
    181 .if defined(HTMLPAGES) && !empty(HTMLPAGES)
    182 	rm -f ${HTMLPAGES}
    183 .endif
    184 
    185 
    186 .if defined(CATPAGES)
    187 .if ${MKCATPAGES} != "no" && ${MKMAN} != "no"
    188 realall: ${CATPAGES}
    189 .else
    190 realall:
    191 .endif
    192 
    193 cleanman:
    194 	rm -f ${CATPAGES}
    195 .else
    196 cleanman:
    197 .endif
    198 
    199 # Make sure all of the standard targets are defined, even if they do nothing.
    200 clean depend includes lint regress tags:
    201