#
# Copyright (c) 1990,1991, OPEN SOFTWARE FOUNDATION, INC.
# ALL RIGHTS RESERVED
#
#  $Header: /project/docsrc/src/dte/RCS/Makefile,v 1.24 92/05/05 10:38:15 fred Exp $

InstallCmd	= cp

SHELL		= /bin/sh
TOP		= /tmp/DTE
BINDIR		= $(TOP)/bin/$(MACHINE)
LIBDIR		= $(TOP)/libdata
MANDIR		= $(TOP)/man
MAN1DIR		= $(MANDIR)/man1
MAN4DIR		= $(MANDIR)/man4

#  SNAPSRCDIR is the destination path for this source for snapshot
SNAPSHOT	=
SNAPSRCDIR	= $(SNAPSHOT)/tools/src/dte

CPROGS		= forward elimso fixVertMot roff-cmd rmifdef \
		query_gloss indpostsort indpresort

SHPROGS		= book-format dman dmm dsml fix-man \
		fmt-index fmt-piece fmt-toc fmt-gloss \
		sync-h1-mm sync-h1-man \
		make-ptx rmboxes rmPic syncGen includePS show-ifdefs prepend-so\
		add-cutmark print-eps
PROGS		= $(CPROGS) $(SHPROGS)

EXTRAS		= prepend-so set-libdir

EXTRA_SOURCES	= prepend-so.sh set-libdir.sh add-cutmark.sh print-eps.sh \
		expand_fname.c

C_SOURCES	= forward.c elimso.c fixVertMot.c roff-cmd.c \
		rmifdef.c query_gloss.c indpostsort.c indpresort.c

SH_SOURCES	= dman.sh dmm.sh dsml.sh \
		book-format.sh fix-man.sh make-ptx.sh \
		fmt-index.sh fmt-toc.sh fmt-piece.sh fmt-gloss.sh \
		sync-h1-mm.sh sync-h1-man.sh \
		rmboxes.sh rmPic.sh syncGen.sh includePS.sh \
		show-ifdefs.sh $(EXTRA_SOURCES)

OTHERS		= Makefile

SOURCES		= $(C_SOURCES) $(SH_SOURCES) $(OTHERS)

MAN1FILES	= book-format.1 dman.1 dmm.1 dte.1
MAN4FILES	= description.4 glossary.4
MANFILES	= $(MAN1FILES) $(MAN4FILES)
ALL_ARGS	= TOP=$(TOP) BINDIR=$(BINDIR) MACHINE=$(MACHINE) \
		  SNAPSHOT=$(SNAPSHOT)

all: clobber programs

programs: $(PROGS) $(EXTRAS)
#	( cd glossary ; make all $(ALL_ARGS) )

book-format:	book-format.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fmt-piece:	fmt-piece.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fmt-index:	fmt-index.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fmt-gloss:	fmt-gloss.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fmt-toc:	fmt-toc.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
show-ifdefs:	show-ifdefs.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
make-ptx:	make-ptx.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
dmm:		dmm.sh		; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
dman:		dman.sh		; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
dsml:		dsml.sh		; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fix-man:	fix-man.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
fix-pic:	fix-pic.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
rmPic:		rmPic.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
rmboxes:	rmboxes.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
sync-h1-man:	sync-h1-man.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
sync-h1-mm:	sync-h1-mm.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
syncGen:	syncGen.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
includePS:	includePS.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
prepend-so:	prepend-so.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
set-libdir:	set-libdir.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
add-cutmark:	add-cutmark.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@
print-eps:	print-eps.sh	; rm -f $@; $(InstallCmd) $@.sh $@; chmod +x $@

scripts: $(SHPROGS)

install: all install-man
	-( if [ -d $(BINDIR) ]; then true; else mkdir $(BINDIR); fi )
	( cd $(BINDIR) ; rm -f $(PROGS) )
	$(InstallCmd) $(PROGS) $(BINDIR)
#	( cd glossary ; make install $(ALL_ARGS) )

install-man:
	-( if [ -d $(MANDIR) ]; then true; else mkdir $(MANDIR); fi )
	-( if [ -d $(MAN1DIR) ]; then true; else mkdir $(MAN1DIR); fi )
	-( if [ -d $(MAN4DIR) ]; then true; else mkdir $(MAN4DIR); fi )
	-(cd $(MAN1DIR) ; rm -f $(MAN1FILES) )
	-(cd $(MAN4DIR) ; rm -f $(MAN4FILES) )
	$(InstallCmd) $(MAN1FILES) $(MAN1DIR)
	$(InstallCmd) $(MAN4FILES) $(MAN4DIR)

prep_dir: $(BINDIR)

$(BINDIR):
	mkdir $(BINDIR)

snapshot:
	@sh -c 'if [ -z "$(SNAPSHOT)" ]; \
	    then echo "SNAPSHOT must be defined on command line - no default!";\
		exit 1 ; \
	    else true ; fi'
	echo $(ALL_ARGS)
	-( if [ -d $(SNAPSRCDIR) ]; \
		then true; else mkdir $(SNAPSRCDIR); fi )
	( cd $(SNAPSRCDIR) ; rm -f $(SOURCES) $(MANFILES) )
	$(InstallCmd) $(SOURCES) $(SNAPSRCDIR)/.
	$(InstallCmd) $(MANFILES) $(SNAPSRCDIR)/.
#	-( if [ -d $(SNAPSRCDIR)/glossary ]; \
#		then true; else mkdir $(SNAPSRCDIR)/glossary ; fi )
#	( cd glossary ; make snapshot $(ALL_ARGS) )

clean:
	-rm -f *.o core a.out *~
#	( cd glossary ; make clean )

clobber: clean
	-rm -f $(PROGS)
#	( cd glossary ; make clobber )

rev-list:
	@echo "# Files in `pwd`"
	@(p=`pwd` ; rcsstat -R -V $(SOURCES) $(MANFILES) | sed -e "s@^\.@$$p@" )
	@echo ""
#	@( cd glossary ; make $@ )

