# $Id: Makefile,v 3.5 1991/08/01 22:38:06 steve Exp $
# $__Header$
#
# Makefile for the "doc" subdirectory of the XGKS package.

# Anticipated, changeable macros (others might not work):
DESTDIR		= /usr/local/ldm#	assumed to have "bin", "etc", "include",
#					"lib", and "man" subdirectories
INSTALL		= install
MANMODE		= 664
OS		= sunos_4.1.1
TBL		= tbl
TROFF		= troff

# End of anticipated macros

MY_MFLAGS	= \
		DESTDIR="$(DESTDIR)" \
		INSTALL="$(INSTALL)" \
		MANMODE="$(MANMODE)" \
		OS="$(OS)" \
		TBL="$(TBL)" \
		TROFF="$(TROFF)"

INST		= $(INSTALL) -c -m $(MANMODE)
MANDIR		= $(DESTDIR)/man
SUBDIRS		= binding userdoc

all:		xgks_synop.3

install:
	@$(MAKE) $(MFLAGS) $(MY_MFLAGS) \
	    $(MANDIR) \
	    $(MANDIR)/man3 \
	    $(MANDIR)/man3/xgks.3

hardcopy:
	@$(MAKE) $(MFLAGS) $(MY_MFLAGS) _sub_targets TARGET=$@

xgks_synop.3:
	awk '{print ".HP 4"; print}' binding/Cbinding.src > $@

clean:
	rm -f xgks_synop.3 core *.out /tmp/xgks.3
	@$(MAKE) $(MFLAGS) $(MY_MFLAGS) _sub_targets TARGET=$@

$(MANDIR):
	mkdir $@
$(MANDIR)/man3:
	mkdir $@
$(MANDIR)/man3/xgks.3:	xgks.3 xgks_synop.3
	soelim xgks.3 | sed 's;===DESTDIR===;$(DESTDIR);g' > /tmp/xgks.3
	$(INST) /tmp/xgks.3 $@
	rm -f /tmp/xgks.3

_sub_targets:	_binding _userdoc

_binding:
	@echo 'Changing to directory binding/'
	@cd binding; \
	$(MAKE) $(MFLAGS) $(MY_MFLAGS) $(TARGET)

_userdoc:
	@echo 'Changing to directory userdoc/'
	@cd userdoc; \
	$(MAKE) $(MFLAGS) $(MY_MFLAGS) $(TARGET)
