# $Header: /usr/src/local/icsi/pmake/doc/RCS/Makefile,v 1.11 1992/10/13 19:05:09 stolcke Exp $

#ifdef ultrix
MANDIR = $(DESTDIR)/usr/man
MANEXT1 = l
MANEXT8 = l
#else
MANDIR = $(DESTDIR)/usr/local/man
MANEXT1 = 1
MANEXT8 = 8
#endif
#ifdef NeXT
INSTALL = install -c -u
#else
INSTALL = install -c
#endif
MANMODE = -m 444

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

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

SUBDIRS		= index ex1 ex2 customs


tutorial.t	: index/tmac.index tutorial.ms 
	ditroff -Plw -ms -t $(.ALLSRC) > tut.temp
	(cd index; make index)
	-index/index -Plw -t tut.temp > $(.TARGET)
	rm -f tut.temp index/index

print 		: tutorial.t
	lpr -Plw -h -n tutorial.t

package		::
	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
	$(INSTALL) $(MANMODE) pmake.1 $(MANDIR)/man$(MANEXT1)/pmake.$(MANEXT1)
	$(INSTALL) $(MANMODE) export.1 $(MANDIR)/man$(MANEXT1)/export.$(MANEXT1)
	$(INSTALL) $(MANMODE) reginfo.1 $(MANDIR)/man$(MANEXT1)/reginfo.$(MANEXT1)
	$(INSTALL) $(MANMODE) customs.8 $(MANDIR)/man$(MANEXT8)/customs.$(MANEXT8)
	$(INSTALL) $(MANMODE) cctrl.8 $(MANDIR)/man$(MANEXT8)/cctrl.$(MANEXT8)
	$(INSTALL) $(MANMODE) importquota.8 $(MANDIR)/man$(MANEXT8)/importquota.$(MANEXT8)
	$(INSTALL) $(MANMODE) logd.8 $(MANDIR)/man$(MANEXT8)/logd.$(MANEXT8)

pmake.1		: pmake.mansp tmac.ansp .NOEXPORT
#ifdef HAVE_SPRITE_MAN
	cp pmake.mansp pmake.1
#else
	(head -1 pmake.mansp ; cat tmac.ansp; tail +3 pmake.mansp) > $(.TARGET)
#endif

pmake.psc	: pmake.1
	ditroff -Ppsc -t -man pmake.1 | psdit > $(.TARGET)

clean		: .NOEXPORT
	rm -f pmake.1

# This was the entry for "package" in "makefile".  Don't ask me what
# the difference is between this one and the other "package".  All I
# know is that having both a Makefile and a makefile is seriously
# demented.	-kupfer

package_other	: 
	-mkdir $(PKGDIR)
	-mkdir $(PKGDIR)/index
	cp *.mansp *.ansp *.ms *.psc Makefile makefile $(PKGDIR)
	cp index/tmac.index index/index.c index/Makefile index/README \
            $(PKGDIR)/index
