xref: /freebsd/share/mk/bsd.doc.mk (revision 48991a368427cadb9cdac39581d1676c29619c52)
1#	from: @(#)bsd.doc.mk	5.3 (Berkeley) 1/2/91
2#	$Id: bsd.doc.mk,v 1.22 1995/10/15 16:14:42 jfieber Exp $
3
4PRINTER?=	ascii
5
6BIB?=		bib
7EQN?=		eqn -T${PRINTER}
8GREMLIN?=	grn
9GRIND?=		vgrind -f
10INDXBIB?=	indxbib
11PIC?=		pic
12REFER?=		refer
13.if ${PRINTER} == "ascii"
14ROFF?=          groff -mtty-char ${TRFLAGS} ${MACROS} -o${PAGES}
15.else
16ROFF?=		groff ${TRFLAGS} ${MACROS} -o${PAGES}
17.endif
18SOELIM?=	soelim
19SOELIMPP=	sed ${SOELIMPPARGS}
20SOELIMPPARGS0=	${SRCS} ${EXTRA}
21SOELIMPPARGS1=	${SOELIMPPARGS0:S/^/-e\\ \'s:\(\.so[\\ \\	][\\ \\	]*\)\(/}
22SOELIMPPARGS2=	${SOELIMPPARGS1:S/$/\)\$:\1${SRCDIR}\/\2:\'/}
23SOELIMPPARGS=	${SOELIMPPARGS2:S/\\'/'/g}
24TBL?=		tbl
25
26DOC?=		paper
27
28TRFLAGS+=	-T${PRINTER}
29.if defined(USE_EQN)
30TRFLAGS+=	-e
31.endif
32.if defined(USE_TBL)
33TRFLAGS+=	-t
34.endif
35.if defined(USE_PIC)
36TRFLAGS+=	-p
37.endif
38.if defined(USE_SOELIM)
39TRFLAGS+=	-s
40.endif
41.if defined(USE_REFER)
42TRFALGS+=	-R
43.endif
44
45.if defined(NODOCCOMPRESS)
46DFILE=	${DOC}.${PRINTER}
47GZIPCMD=	cat
48.else
49DFILE=	${DOC}.${PRINTER}.gz
50GZIPCMD=	gzip -c
51.endif
52
53PAGES?=		1-
54
55# Compatibility mode flag for groff.  Use this when formatting documents with
56# Berkeley me macros.
57COMPAT?=	-C
58
59.PATH: ${.CURDIR} ${SRCDIR}
60
61.MAIN:	all
62all:	${DFILE}
63
64.if !target(print)
65print: ${DFILE}
66.if defined(NODOCCOMPRESS)
67	lpr -P${PRINTER} ${DFILE}
68.else
69	${GZIPCMD} -d ${DFILE} | lpr -P${PRINTER}
70.endif
71.endif
72
73.if !target(obj)
74.if defined(NOOBJ)
75obj:
76.else
77obj:
78	@cd ${.CURDIR}; rm -f obj; \
79	here=`pwd`; dest=/usr/obj`echo $$here | sed 's,^/usr/src,,'`; \
80	${ECHO} "$$here -> $$dest"; ln -s $$dest obj; \
81	if test -d /usr/obj -a ! -d $$dest; then \
82		mkdir -p $$dest; \
83	else \
84		true; \
85	fi;
86.endif
87.endif
88
89clean:
90	rm -f ${DOC}.${PRINTER} ${DOC}.ps ${DOC}.ascii \
91		${DOC}.ps.gz ${DOC}.ascii.gz [eE]rrs mklog ${CLEANFILES}
92
93cleandir: clean
94	cd ${.CURDIR}; rm -rf obj
95
96FILES?=	${SRCS}
97realinstall:
98	@if [ ! -d "${DESTDIR}${BINDIR}/${VOLUME}" ]; then \
99                /bin/rm -f ${DESTDIR}${BINDIR}/${VOLUME}  ; \
100                mkdir -p ${DESTDIR}${BINDIR}/${VOLUME}  ; \
101                chown root.wheel ${DESTDIR}${BINDIR}/${VOLUME}  ; \
102                chmod 755 ${DESTDIR}${BINDIR}/${VOLUME}  ; \
103        else \
104                true ; \
105        fi
106	${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
107		${DFILE} ${DESTDIR}${BINDIR}/${VOLUME}
108
109install:	beforeinstall realinstall afterinstall
110
111.if !target(beforeinstall)
112beforeinstall:
113
114.endif
115.if !target(afterinstall)
116afterinstall:
117
118.endif
119
120DISTRIBUTION?=	doc
121.if !target(distribute)
122distribute:
123	cd ${.CURDIR} ; $(MAKE) install DESTDIR=${DISTDIR}/${DISTRIBUTION} SHARED=copies
124.endif
125
126spell: ${SRCS}
127	(cd ${.CURDIR};  spell ${SRCS} ) | sort | \
128		comm -23 - ${.CURDIR}/spell.ok > ${DOC}.spell
129
130BINDIR?=	/usr/share/doc
131BINMODE=        444
132
133SRCDIR?=	${.CURDIR}
134
135.if !target(${DFILE})
136${DFILE}::	${SRCS} ${EXTRA} ${OBJS}
137# XXX ${.ALLSRC} doesn't work unless there are a lot of .PATH.foo statements.
138ALLSRCS=	${SRCS:S;^;${SRCDIR}/;}
139${DFILE}::	${SRCS}
140.if defined(USE_SOELIMPP)
141	${SOELIMPP} ${ALLSRCS} | ${ROFF} | ${GZIPCMD} > ${.TARGET}
142.else
143	(cd ${SRCDIR}; ${ROFF} ${.ALLSRC}) | ${GZIPCMD} > ${.TARGET}
144.endif
145.else
146.if !defined(NODOCCOMPRESS)
147${DFILE}:	${DOC}.${PRINTER}
148	${GZIPCMD} ${DOC}.${PRINTER} > ${.TARGET}
149.endif
150.endif
151
152.if !target(depend)
153depend:
154
155.endif
156
157.if !target(maninstall)
158maninstall:
159
160.endif
161