######################################################################
# 
# Imakefile -- Imake rules for PTS.
# Dean Collins, Thu Jul 30 13:46:51 PDT 1992
#
# Modified: Dean Collins Sat Feb 12 23:27:44 1994
# Cleaned up, simplified, etc.
#
# Modified: Dean Collins Thu Mar 10 20:44:34 1994
# Moved customization to Imake.config, which each Imakefile
# will #include.  This eliminates the need to set CC within
# each one.
#
######################################################################
#
# Copyright (c) 1992,1993,1994,1995 Dean Collins.
# Copyright (c) 1992 University of Idaho, Moscow, Idaho.
# 
# Permission to use, copy, modify, and distribute this software and its
# documentation free of charge for any purpose is hereby granted without
# fee, provided that the above copyright notice appear in all copies and
# that both that copyright notice and this permission notice appear in
# supporting documentation, and that the name of the University of Idaho
# not be used in advertising or publicity pertaining to distribution of
# the software without specific, written prior permission.  The University
# of Idaho makes no representations about the suitability of this software
# for any purpose.  It is provided "as is" without express or implied warranty.
# 
# THE UNIVERSITY OF IDAHO DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
# SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
# IN NO EVENT SHALL THE UNIVERSITY OF IDAHO BE LIABLE FOR ANY SPECIAL,
# INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.
######################################################################


######################################################################
#  YOU SHOULDN'T NEED TO MODIFY ANYTHING IN THIS FILE.
#  All customization is now done in Imake.config.
######################################################################


#include "Imake.config"


#define IHaveSubdirs
#define PassCDebugFlags 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

SUBDIRS = util zdbm config neb_cld xpts ptsager newprob ptstypes doc/Manual
#SUBDIRS = util zdbm config neb_cld xpts ptsager newprob ptstypes \
#		text cpts doc/Manual contrib

all:: pts.h pts.sed

#This is needed so things won't barf.
depend:: pts.h pts.sed

MakeSubdirs($(SUBDIRS))
DependSubdirs($(SUBDIRS))
/*CleanSubdirs($(SUBDIRS))*/
LintSubdirs($(SUBDIRS))



all::
	@echo Welcome to PTS version 1.1a2!



###### pts.cf ###################
# Install the config file.  Create a config file manually ("pts.cf")
# in the config directory before installing.
# (You can start with config/sample.config, but it must be customized.)
# This should not overwrite an existing pts.cf file, as far as I know.
PTSInstallNonExecFile(config/pts.cf,pts.cf,$(CFGDIR),$(OWNER))

# Make the PTSROOT directory hierarchy.  You should be the "support"
# user when running "make install".
install:: xpts/xpts ptsager/ptsager
	$(MKDIRHIER) $(PTSROOT)
	chown $(OWNER) $(PTSROOT)

util::
	cd util; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

zdbm::
	cd zdbm; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

neb_cld::
	cd neb_cld; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

web::
	cd web; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

cpts::
	cd cpts; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)'

configtest::
	cd config; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' configtest

xpts::
	cd xpts; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' xpts

ptsager::
	cd ptsager; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' ptsager

newprob::
	cd newprob; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' ptsager

ptstypes::
	cd ptstypes; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' ptsager

ptsprt::
	cd contrib/ptsprt; $(MAKE) $(MFLAGS) 'CDEBUGFLAGS=$(CDEBUGFLAGS)' ptsprt


clean::
	$(RM) pts.h pts.sed

pts.h: Imake.config Imakefile
	echo '/*' > $@
	echo ' * pts.h -- #defines for PTS .c files.' >> $@
	echo ' *' >> $@
	echo ' * THIS FILE IS AUTOMATICALLY GENERATED.  DO NOT MODIFY.' >> $@
	echo ' *' >> $@
	echo ' * If you need to make changes, modify Imake.config and recreate.' >> $@
	echo ' */' >> $@
	echo >> $@
	echo '#ifndef PTS_H_INCLUDED' >> $@
	echo '#define PTS_H_INCLUDED' >> $@
	echo >> $@
	echo '#define         PTSDIR  "$(PTSDIR)/"' >>$@
	echo '#define         BINDIR  "$(BINDIR)/"' >>$@
	echo '#define        PTSROOT  "$(PTSROOT)/"' >>$@
	echo '#define         CFGDIR  "$(CFGDIR)"' >>$@
	echo '#define     CONFIGFILE  "$(CONFIGFILE)"' >>$@
	echo '#define       SYSOPGID  $(SYSOPGID)' >>$@
	echo '#define          OWNER  "$(OWNER)"' >>$@
	echo '#define    OWNER_EMAIL  "$(OWNER_EMAIL)"' >>$@
	echo '#define     OWNER_NAME  "$(OWNER_NAME)"' >>$@
	echo '#define        WWW_URL  "$(WWW_URL)"' >>$@
	echo '#define     CGIBIN_URL  "$(CGIBIN_URL)"' >>$@
	echo '#define     CGIBIN_DIR  "$(CGIBIN_DIR)"' >>$@
	echo '#define     CGISRC_DIR  "$(CGISRC_DIR)"' >>$@
	echo '#define     HTDOCS_URL  "$(HTDOCS_URL)"' >>$@
	echo '#define     HTDOCS_DIR  "$(HTDOCS_DIR)"' >>$@
	echo '#define        WAISBIN  "$(WAISBIN)"' >>$@
	echo '#define      WAISQUERY  "$(WAISQUERY)"' >>$@
	echo '#define        WAISDIR  "$(WAISDIR)"' >>$@
	echo '#define         IMAGES  "$(IMAGES)"' >>$@
	echo '#define        BGIMAGE  "$(BGIMAGE)"' >>$@
	echo '#define     LINEIMAGE1  "$(LINEIMAGE1)"' >>$@
	echo '#define   HTML_REFRESH  "$(HTML_REFRESH)"' >>$@
	echo '#define    ZOMBIEIMAGE  "$(ZOMBIEIMAGE)"' >>$@
	echo '#define   ZOMBIERIMAGE  "$(ZOMBIERIMAGE)"' >>$@
	echo '#define    WIZARDIMAGE  "$(WIZARDIMAGE)"' >>$@
	echo '#define    SOLVEDIMAGE  "$(SOLVEDIMAGE)"' >>$@
	echo '#define  UNSOLVEDIMAGE  "$(UNSOLVEDIMAGE)"' >>$@
	echo '#define    REOPENIMAGE  "$(REOPENIMAGE)"' >>$@
	echo '#define PTSAUTHORS_URL  "$(PTSAUTHORS_URL)"' >>$@
	echo '#define    PTSINFO_URL  "$(PTSINFO_URL)"' >>$@
	echo '#define        PRINTER  "$(PRINTER)"' >>$@
	echo '#define   PRINTER_OPTS  "$(PRINTER_OPTS)"' >>$@
	echo '#define         MAILER  "$(MAILER)"' >>$@
	echo '#define    MAILER_OPTS  "$(MAILER_OPTS)"' >>$@
	echo '#define      X_LIB_DIR  "$(X_LIB_DIR)"' >>$@
	echo '#define     X_INC_ROOT  "$(X_INC_ROOT)"' >>$@
	echo >> $@
	echo '#endif /* PTS_H_INCLUDED */' >> $@
	@echo $@ created.

pts.sed: Imake.config Imakefile
	$(RM) $@
	echo '1,$$s,%%PTSDIR%%,$(PTSDIR),g' >> $@
	echo '1,$$s,%%BINDIR%%,$(BINDIR),g' >> $@
	echo '1,$$s,%%PTSROOT%%,$(PTSROOT),g' >> $@
	echo '1,$$s,%%CFGDIR%%,$(CFGDIR),g' >> $@
	echo '1,$$s,%%CONFIGFILE%%,$(CONFIGFILE),g' >> $@
	echo '1,$$s,%%SYSOPGID%%,$(SYSOPGID),g' >> $@
	echo '1,$$s,%%OWNER%%,$(OWNER),g' >> $@
	echo '1,$$s,%%OWNER_EMAIL%%,$(OWNER_EMAIL),g' >> $@
	echo '1,$$s,%%OWNER_NAME%%,$(OWNER_NAME),g' >> $@
	echo '1,$$s,%%WWW_URL%%,$(WWW_URL),g' >> $@
	echo '1,$$s,%%CGIBIN_URL%%,$(CGIBIN_URL),g' >> $@
	echo '1,$$s,%%CGIBIN_DIR%%,$(CGIBIN_DIR),g' >> $@
	echo '1,$$s,%%CGISRC_DIR%%,$(CGISRC_DIR),g' >> $@
	echo '1,$$s,%%HTDOCS_URL%%,$(HTDOCS_URL),g' >> $@
	echo '1,$$s,%%HTDOCS_DIR%%,$(HTDOCS_DIR),g' >> $@
	echo '1,$$s,%%WAISBIN%%,$(WAISBIN),g' >> $@
	echo '1,$$s,%%WAISQUERY%%,$(WAISQUERY),g' >> $@
	echo '1,$$s,%%WAISDIR%%,$(WAISDIR),g' >> $@
	echo '1,$$s,%%IMAGES%%,$(IMAGES),g' >> $@
	echo '1,$$s,%%BGIMAGE%%,$(BGIMAGE),g' >> $@
	echo '1,$$s,%%LINEIMAGE1%%,$(LINEIMAGE1),g' >> $@
	echo '1,$$s,%%HTML_REFRESH%%,$(HTML_REFRESH),g' >> $@
	echo '1,$$s,%%ZOMBIEIMAGE%%,$(ZOMBIEIMAGE),g' >> $@
	echo '1,$$s,%%ZOMBIERIMAGE%%,$(ZOMBIERIMAGE),g' >> $@
	echo '1,$$s,%%WIZARDIMAGE%%,$(WIZARDIMAGE),g' >> $@
	echo '1,$$s,%%SOLVEDIMAGE%%,$(SOLVEDIMAGE),g' >> $@
	echo '1,$$s,%%UNSOLVEDIMAGE%%,$(UNSOLVEDIMAGE),g' >> $@
	echo '1,$$s,%%REOPENIMAGE%%,$(REOPENIMAGE),g' >> $@
	echo '1,$$s,%%PTSAUTHORS_URL%%,$(PTSAUTHORS_URL),g' >> $@
	echo '1,$$s,%%PTSINFO_URL%%,$(PTSINFO_URL),g' >> $@
	echo '1,$$s,%%PRINTER%%,$(PRINTER),g' >> $@
	echo '1,$$s,%%PRINTER_OPTS%%,$(PRINTER_OPTS),g' >> $@
	echo '1,$$s,%%MAILER%%,$(MAILER),g' >> $@
	echo '1,$$s,%%MAILER_OPTS%%,$(MAILER_OPTS),g' >> $@
	echo '1,$$s,%%X_LIB_DIR%%,$(X_LIB_DIR),g' >> $@
	echo '1,$$s,%%X_INC_ROOT%%,$(X_INC_ROOT),g' >> $@
	@echo $@ created.



#Similar to "xmkmf -a" only different.
World: world
world:
	xmkmf
	make Makefiles
	make clean
	make pts.h
	make pts.sed
	make depend
	make all
	(cd web; xmkmf; make clean; make all)

veryclean:
	make clean
	(cd web; make clean)
