#
# Makefile for documentation for pmake, customs, and prefix 
#
# $Id: Makefile,v 1.21 1996/08/19 01:04:32 stolcke Exp $ ICSI (Berkeley)
#
# Copyright (c) 1988, 1989 by the Regents of the University of California
# Copyright (c) 1988, 1989 by Adam de Boor
# Copyright (c) 1989 by Berkeley Softworks
#
# Permission to use, copy, modify, and distribute this
# software and its documentation for any non-commercial purpose
# and without fee is hereby granted, provided that the above copyright
# notice appears in all copies.  The University of California,
# Berkeley Softworks and Adam de Boor make no representations about
# the suitability of this software for any purpose.  It is provided
# "as is" without express or implied warranty.
#

# most of the stuff here is machine independent
.EXPORT:

MANDIR		= /usr/local/man
MANEXT1		= 1
MANEXT8		= 8

MANMODE		= -m 444

# ditroff driver and postprocessor

#ifdef HAVE_GROFF
# these will work but won't print those nice STOP signs on the margins ...
DITROFF		= gtroff
DEVICE		= -Tps
MSMAC		= -ms
MANMAC		= -C -M/usr/lib/tmac -man
PSDIT		= grops
#else !HAVE_GROFF
DITROFF		= ditroff
DEVICE		= -Tpsc
MSMAC		= -ms
MANMAC		= -man
PSDIT		= psdit
#endif HAVE_GROFF

# ditroff runs only on some of our machines
WHERE		= .EXPORT=SunOS4.1.3

DONT_MAKE_PMAKE	=
#include	"../common.mk"

#if exists(../config.mk)
#include	"../config.mk"
#endif

LOCALS		= tutorial.ms tutorial.psc \
                  pmake.mansp pmake.psc \
                  prefix.ms prefix.psc \
		  Lst.mansp Lst.psc Makefile tmac.ansp \
                  cctrl.8 customs.8 importquota.8 reginfo.1 export.1 rexport.1

SUBDIRS		= index customs

.MAIN		: pmake.1

tutorial.psc	: index/index index/tmac.index tutorial.ms $(WHERE)
	$(DITROFF) $(DEVICE) $(MSMAC) -t index/tmac.index tutorial.ms | \
		index/index -t | \
		$(PSDIT) > $(.TARGET)

print 		: tutorial.psc .NOEXPORT
	lpr tutorial.psc

package		:: .NOEXPORT
	if [ ! -d $(PKGDIR) ]; then \
		mkdir $(PKGDIR) ; \
	fi
	cp $(LOCALS) $(PKGDIR)
	for i in $(SUBDIRS); do \
		(cd $i; $(MAKE) "PKGDIR=$(PKGDIR)/$i" package) ; \
	done

install		:: pmake.1 .NOEXPORT
	test -d $(DESTDIR)$(MANDIR) || mkdir $(DESTDIR)$(MANDIR)
	test -d $(DESTDIR)$(MANDIR)/man$(MANEXT1) || \
		mkdir $(DESTDIR)$(MANDIR)/man$(MANEXT1)
	test -d $(DESTDIR)$(MANDIR)/man$(MANEXT8) || \
		mkdir $(DESTDIR)$(MANDIR)/man$(MANEXT8)
	$(INSTALL) $(MANMODE) pmake.1 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT1)/pmake.$(MANEXT1)
	$(INSTALL) $(MANMODE) export.1 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT1)/export.$(MANEXT1)
	$(INSTALL) $(MANMODE) reginfo.1 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT1)/reginfo.$(MANEXT1)
	$(INSTALL) $(MANMODE) rexport.1 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT1)/rexport.$(MANEXT1)
	$(INSTALL) $(MANMODE) customs.8 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT8)/customs.$(MANEXT8)
	$(INSTALL) $(MANMODE) cctrl.8 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT8)/cctrl.$(MANEXT8)
	$(INSTALL) $(MANMODE) importquota.8 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT8)/importquota.$(MANEXT8)
	$(INSTALL) $(MANMODE) logd.8 \
		$(DESTDIR)$(MANDIR)/man$(MANEXT8)/logd.$(MANEXT8)

pmake.1		: pmake.mansp tmac.ansp .NOEXPORT
	sed \
		-e 's,@SYSTEM_MK@,$(SYSTEM_MK),g' \
		-e 's,@LIBDIR@,$(LIBDIR),g' \
		-e '/^\.so tmac.ansp/r tmac.ansp' \
		-e '/^\.so tmac.ansp/d' pmake.mansp > $(.TARGET)

.SUFFIXES:	.psc .mansp .ms

.mansp.psc	: $(WHERE)
	$(DITROFF) $(DEVICE) -t $(MANMAC) $< | $(PSDIT) > $(.TARGET)

.ms.psc		: $(WHERE)
	$(DITROFF) $(DEVICE) -t $(MSMAC) $< | $(PSDIT) > $(.TARGET)

index/index	: $(WHERE)
	cd index; $(MAKE) 'CFLAGS=-DDITROFF=\"$(DITROFF)\"' index

clean		:: .NOEXPORT
	rm -f pmake.1
	rm -f index/index

