    INSTALLDIR = /usr/local/icp
        BINDIR = /usr/local/bin
       INFODIR = /usr/local/emacs/info
# To disable the installation of the on-line
# manual, leave INFODIR blank in the line above.

# Names of programs to be installed
#
           ICP = icp
    MBX_SERVER = mbx_server

# pathname of perl if you have it
#
          PERL = /usr/local/bin/perl

# unlikely to need modification below this line
#
  INSTBINFLAGS = -m 0775
  INSTLIBFLAGS = -m 0664
        MKDIRH = install/mkdirhier
           PWD = /usr/bin/pwd
           SED = /usr/bin/sed
            M4 = /usr/bin/m4
           TAR = /usr/bin/tar
       INSTALL = /usr/bin/install


install install.bin::
	$(MKDIRH) bin/generic
	$(MKDIRH) $(INSTALLDIR)
	@if [ -d prolog/xpce ]; then m4xpce=yes; else m4xpce=no; fi; \
	$(SED) -e "s:@INSTALLDIR@:$(INSTALLDIR):" \
		-e "s:@m4xpce@:m4xpce:" \
		-e "s:@ICP@:$(ICP):" \
		install/icp.sed | $(M4) - > bin/generic/$(ICP); \
	$(SED) -e "s:@INSTALLDIR@:$(INSTALLDIR):" \
		-e "s:@MBX_SERVER@:$(MBX_SERVER):" \
		install/mbx_server.sed | $(M4) - > bin/generic/$(MBX_SERVER)


install::
	@(dir=$(INSTALLDIR); \
	installdir=`(cd $$dir; $(PWD))`; \
	if [ `$(PWD)` != $$installdir ]; then \
		echo ; \
		echo "Installing run-time system in $$dir ..." ; \
		echo ; \
		(set -x; umask 022; $(TAR) cf - bin prolog parlog include lib | \
		(cd $$dir ; $(TAR) xvfB - )); \
	fi)

install install.bin::
	$(MKDIRH) $(BINDIR)
	@echo "" 
	@echo "Installing scripts in $(BINDIR) ..."
	@echo ""
	$(INSTALL) $(INSTBINFLAGS) bin/generic/$(ICP) $(BINDIR)
	$(INSTALL) $(INSTBINFLAGS) bin/generic/$(MBX_SERVER) $(BINDIR)

install install.doc::
	@if [ -d info ] ; then \
		(dir=$(INFODIR); \
		infodir=`(cd $$dir; $(PWD))`; \
		if [ x$$dir != x -a $$infodir != `$(PWD)`/info ]; then \
			echo ; \
			echo "Installing on-line manual in $$dir ..." ; \
			echo ; \
			$(MKDIRH) $$dir; \
			(set -x; $(INSTALL) $(INSTLIBFLAGS) info/* $$dir); \
			echo ; \
			echo "Add the following two lines to $$dir/dir :" ; \
			echo '* ICP: (icp.info).		IC prolog ][' ; \
			echo '* Parlog: (parlog.info).	Parlog' ; \
		fi) \
	else \
		echo ; \
		echo "warning: on-line manual has not been generated yet !"; \
		echo ; \
	fi

install::
	@echo
	@echo
	@echo "Using Mailboxes:"
	@echo "If you wish to use the mailbox communication primitives,"
	@echo "the following lines must be installed in /etc/services"
	@echo "by your system administrator."
	@echo "--------------------------------------------------------------"
	@cat install/icp-services
	@echo "--------------------------------------------------------------"
	@echo "The above lines are in the file install/icp-services and if"
	@echo "you have perl, they may be installed automatically by typing"
	@echo
	@echo "        make services"

install::
	@echo
	@echo
	@echo "Installation of IC-Prolog ][ completed."
	@echo
	@echo "Hardcopies of the manuals may be printed from the dvi"
	@echo "files in doc/*."
	@echo

#
#  To add new lines to /etc/services
#
services:
	(cd ./install; $(PERL) inst-services.perl)

