#!/bin/sh

############################################################################
#cr                                                                       
#cr            (C) Copyright 1995 The Board of Trustees of the            
#cr                        University of Illinois                         
#cr                         All Rights Reserved                           
#cr                                                                       
############################################################################

############################################################################
# RCS INFORMATION:
#
# 	$RCSfile: configure,v $
# 	$Author: dalke $	$Locker:  $		$State: Exp $
#	$Revision: 1.109 $	$Date: 1996/05/14 19:59:47 $
#
############################################################################
# DESCRIPTION:
#
# Main configuration script for vmd.
#
# Usage:		configure [ optionlist ]
# where [ optionlist ] is one or more of the following, separated by spaces:
#
#       architectures:
# IRIX4                 - set up to compile on an SGI, IRIX 4.X or earlier
# IRIX5                 - set up to compile on an SGI, IRIX 5.X or later
# HPUX9                 - set up to compile on an HP-UX machine
# AIX3                  - set up to compile on an RS/6000 machine
# LINUX                 - set up to compile on a Linux machine
#
#       graphics/windowing library:
# GL			- use GL for windows and graphics (default)
# OPENGL		- user OPENGL for graphics, X for windows
# STARBASE        	- use Starbase for graphics
# NOGRAPHICS		- do not include ANY graphics capability
#
#       graphical user interface library:
# FORMS	| XFORMS	- use X-FORMS library for GUI (default)
# TK             	- use TK library for GUI
# NOGUI			- do not use ANY GUI library
#
#	optional components:
# TCL      | NOTCL	- use/do not use the Tcl scripting language parser
# REMOTE   | NOREMOTE	- include/exclude remote sim connection option
# CAVE     | NOCAVE	- include/exclude cave display option
# UNC      | NOUNC	- include/exclude UNC tracker lib for spatial tracker
# EXTERNAL | NOEXTERNAL	- allow/disallow external input via Tcl-DP
# SIGMA    | NOSIGMA	- include/exclude SIgMA MD interface (experimental)
# ALPHA    | NOALPHA    - use external calls to the alpha shape programs
# SURF     | NOSURF     - use the SURF code from UNC
#
#       other options:
# DEBUG    | NODEBUG	- include/exclude debugging statement code
# OPTIMIZE | NOOPTIMIZE	- compile with/without standard optimization (ie -O)
# MAKE     | NOMAKE	- does/does not do the co & make after configuring
# SILENT   | NOSILENT	- suppress/do not suppress make command echo
# HELP                  - print out help message, and exit this script
#
# If conflicting options are given, the last one in the command is used.
#
# If no architecture is given, this script will try to guess the system;
# if that fails, this script will exit.
#
# If no arguments are given, the file 'configure.options' is checked; if it
# exists, the contents of the file are used for the current options.  Upon
# completion of a successful configure, configure.options is rewritten with
# a copy of the most recently used options.
#
# Configuration parameters are read from the file 'configure.parameters' if it
# exists; this file can contain values for configuration params in the format
#                               <keyword>=<value>
# with no spaces between <keyword> and <value>. The keywords are all described
# at the start of this script.  Default values
# for all parameters are first declared at the start of this script, after
# which the file configure.parameters is read which can contain new values for
# selected parameters.
############################################################################

############################################################################
# default values for program configurable parameters ***STARTPARAMS***
############################################################################

###########################
# installation parameters
###########################
# name of shell script used to start program; this is the name used by users
INSTALLNAME=vmd

# directory where program data files and OS-specific executables are installed
INSTALLLIBDIR=/usr/local/lib/$INSTALLNAME

# directory where startup scripts and utility programs are installed.
# this should be a directory in the path of users who will run the program
INSTALLBINDIR=/usr/local/bin

###########################
# compilation parameters
###########################

# location of TCL library and include file; if TCL is not being used,
# the next two options will be ignored.  If left blank, standard system
# directories will be searched.
TCL_INCLUDE_DIR=${TCL_INCLUDE_DIR-/usr/local/include}
TCL_LIBRARY_DIR=${TCL_LIBRARY_DIR-/usr/local/lib}

# location of TclX
TCLX_INCLUDE_DIR=${TCLX_INCLUDE_DIR-/usr/local/include}
TCLX_LIBRARY_DIR=${TCLX_LIBRARY_DIR-/usr/local/lib}

# location of Tcl-DP (for EXTERNAL option)
TCLDP_INCLUDE_DIR=${TCLDP_INCLUDE_DIR-/usr/local/include}
TCLDP_LIBRARY_DIR=${TCLDP_LIBRARY_DIR-/usr/local/lib}

# location of OpenGL library and include files; if OPENGL is not being used,
# the next two options will be ignored.  If left blank, standard system
# directories will be searched.  This also specifies the names of the
# OpenGL libraries. Note that these options require -I and -L in front of
# the include and library directory names
OPENGL_INCLUDE_DIR=
OPENGL_LIBRARY_DIR=
OPENGL_LIBRARIES="-lGL -lGLU -lX11"

# name of 'Babel' conversion program executable, with the complete path
DEFBABELBIN=$INSTALLBINDIR/babel

# default type of display to use upon startup of program: WIN, CAVE, or TEXT
DEFDISPLAY=WIN

# distance from the 'world' coordinates origin to the screen, in the same
# units as the DEFHEIGHT value.  If > 0, the screen is between the viewer
# and the origin; if < 0, the origin is in FRONT of the screen.
DEFDIST="-2.0"

# default screen height, a floating-point value.  This distance is in 'world'
# coordinate system
DEFHEIGHT="6.0"

# name of default html viewer to use; this value may be overridden when the
# program is run with the environment variable VMDHTMLVIEWER
DEFHTMLVIEWER=Mosaic

# whether or not to display the program title on startup: ON or OFF
DEFTITLE=ON

# default temporary file storage directory
DEFTMPDIR="/tmp"

# name of program initialization file, with default setting variables
INITFILENAME=.vmd_init

# max number of characters used for string comparisons
MAXSTRINGLEN=6

# program version number
PROGVERSION=1.1

# text prompt string
PROMPTSTRING="vmd > "

# startup command script file.  Read after program initialization.
STARTUPFILENAME=.vmdrc

# main VMD url
VMD_HOMEPAGE=http://www.ks.uiuc.edu/Research/vmd

# VMD help url
VMD_HELPPAGE=http://www.ks.uiuc.edu/Research/vmd

###########################
# configure script parameters ***ENDPARAMS***
###########################

# who is actually to blame for this mess
AUTHORS="W. Humphrey, A. Dalke, K. Hamer, J. Leech, J. Phillips"

# where to put files when making available for anon ftp
INSTALLFTPDIR=/Net/lisboa/usr/ftp/pub/mdscope/vmd

archlist="IRIX4 IRIX5 HPUX9 AIX3 LINUX"

###########################
# useful functions
###########################

# print usage
myusage() {
  echo "Usage: $0 [ optlist ]"
  echo "  where [ optlist ] is zero or more of the following:"
  echo " "
  echo "  HELP: print out this information."
  echo " "
  echo "  IRIX4:    set up to compile on an SGI, IRIX 4.X or earlier"
  echo "  IRIX5:    set up to compile on an SGI, IRIX 5.X or later"
  echo "  HPUX9:    set up to compile on an HP-UX machine"
  echo "  AIX3:     set up to compile on an RS/6000 machine"
  echo "  LINUX:    set up to compile on a Linux machine"
  echo " "
  echo "  GL: use the GL library for windows and graphics (def)."
  echo "  OPENGL: use the OpenGL library for graphics, X for windows."
  echo "  STARBASE: use the Starbase library for graphics."
  echo "  NOGRAPHICS: do not include any graphics capability."
  echo "  FORMS or XFORMS: use the X-FORMS GUI library (def)."
  echo "  TK: use the TK GUI library (STARBASE only)."
  echo "  NOGUI: do not include any GUI library."
  echo "  TCL or NOTCL: include/exclude Tcl parser (requires Tcl, TclX, and Tcl-DP)."
  echo "  EXTERNAL or NOEXTERNAL: include/exclude Tcl-DP support for external calls"
  echo "  REMOTE or NOREMOTE: include/exlude remote connection cababilities."
  echo "  CAVE or NOCAVE: include/exclude support for CAVE display (GL only)."
  echo "  ALPHA or NOALPHA: use external calls to the alpha shape programs."
  echo "  SURF or NOSURF: use external calls to the SURF program."
  echo "  UNC or NOUNC: include/exclude support for using UNC TRACKER lib."
  echo "  DEBUG or NODEBUG: include/exclude debugging statements."
  echo "  OPTIMIZE or NOOPTIMIZE: compile (or do not compile) with -O flag."
  echo "  MAKE or NOMAKE: re-co and remake the code after config, or skip."
  echo "  SILENT or NOSILENT: suppress (do not suppress) make command echo."
  exit 1
}

############################################################################
# main script begins
############################################################################

# make sure we're in the proper directory first
if [ ! -d src ]; then
  cd ..
  if [ ! -d src ]; then
    echo "This is not the proper directory.  Exiting ..."
    exit 1
  fi
fi

# read user settings for parameters, if available 
if [ -f ./configure.parameters ]; then
  echo "Reading user configuration parameters ..."
  . ./configure.parameters
fi


###########################
# initialization
###########################
# check the arguments, parse them, and set flags to get ready to run
###########################

myargs=$*
myarch=unknown
myoptions=
myoptimizeflag="-g"
opt_graphics=gl
opt_gui=forms
opt_tcl=false
opt_remote=false
opt_cave=false
opt_alpha=false
opt_surf=false
opt_unc=false
opt_external=false
opt_sigma=false
opt_debug=false
opt_optim=false
opt_remake=false
opt_silent=true

# check for previous options file
if [ $# = 0 -a -f ./configure.options ]; then
  myargs=`cat ./configure.options`
fi

# parse arguments
for a in $myargs ; do

  if [ "$a" = "HELP" -o "$a" = "help" ]; then
    myusage

  elif [ "$a" = "GL" ]; then
    opt_graphics=gl

  elif [ "$a" = "OPENGL" ]; then
    opt_graphics=opengl

  elif [ "$a" = "STARBASE" ]; then
    opt_graphics=starbase
    opt_gui=tk
    opt_cave=false

  elif [ "$a" = "NOGRAPHICS" ]; then
    opt_graphics=false
    opt_cave=false

  elif [ "$a" = "FORMS" -o "$a" = "XFORMS" ]; then
    opt_gui=forms

  elif [ "$a" = "TK" ]; then
    opt_gui=tk

  elif [ "$a" = "NOGUI" ]; then
    opt_gui=false

  elif [ "$a" = "TCL" ]; then
    opt_tcl=true

  elif [ "$a" = "NOTCL" ]; then
    opt_tcl=false

  elif [ "$a" = "REMOTE" ]; then
    opt_remote=true

  elif [ "$a" = "NOREMOTE" ]; then
    opt_remote=false

  elif [ "$a" = "CAVE" ]; then
    opt_cave=true
    opt_graphics=gl

  elif [ "$a" = "NOCAVE" ]; then
    opt_cave=false

  elif [ "$a" = "ALPHA" ]; then
    opt_alpha=true

  elif [ "$a" = "NOALPHA" ]; then
    opt_alpha=false

  elif [ "$a" = "SURF" ]; then
    opt_surf=true

  elif [ "$a" = "NOSURF" ]; then
    opt_surf=false

  elif [ "$a" = "UNC" ]; then
    opt_unc=true

  elif [ "$a" = "NOUNC" ]; then
    opt_unc=false

  elif [ "$a" = "EXTERNAL" ]; then
    opt_external=true;

  elif [ "$a" = "NOEXTERNAL" ]; then
    opt_external=false;

  elif [ "$a" = "SIGMA" ]; then
    opt_sigma=true

  elif [ "$a" = "NOSIGMA" ]; then
    opt_sigma=false

  elif [ "$a" = "DEBUG" ]; then
    opt_debug=true

  elif [ "$a" = "NODEBUG" ]; then
    opt_debug=false

  elif [ "$a" = "OPTIMIZE" -o "$a" = "OPT" ]; then
    opt_optim=true

  elif [ "$a" = "NOOPTIMIZE" -o "$a" = "NOOPT" ]; then
    opt_optim=false

  elif [ "$a" = "MAKE" ]; then
    opt_remake=true

  elif [ "$a" = "NOMAKE" ]; then
    opt_remake=false

  elif [ "$a" = "SILENT" ]; then
    opt_silent=true

  elif [ "$a" = "NOSILENT" ]; then
    opt_silent=false

  else
    # check for architecture option
    archfound=false
    for b in $archlist; do
      if [ "$b" = "$a" ]; then
        myarch=$b
        archfound=true
      fi
    done
    # make sure an arch was found.  If not, unknown option
    if [ $archfound = false ]; then
      echo "Unknown option $a"
      myusage
    fi
  fi
done


# try to guess the architecture if it is not given
if [ $myarch = unknown ]; then
  # so far, this does not do anything ... but it could check getpvmarch,
  # or run uname -a to look for known machines
  true
fi
  
# make sure the architecture is a supported one
archfound=false
for b in $archlist; do
  if [ "$b" = "$myarch" ]; then
    myarch=$b
    archfound=true
  fi
done
if [ $archfound = false ]; then
  echo "Unsupported architecture.  Please specify one of the following:"
  echo $archlist
  myusage
fi

# create a list with all the options
if [ $opt_graphics = gl ]; then
  myoptions="$myoptions GL"
elif [ $opt_graphics = opengl ]; then
  myoptions="$myoptions OPENGL"
elif [ $opt_graphics = starbase ]; then
  myoptions="$myoptions STARBASE"
else
  myoptions="$myoptions NOGRAPHICS"
fi

if [ $opt_gui = forms ]; then
  myoptions="$myoptions FORMS"
elif [ $opt_gui = tk ]; then
  myoptions="$myoptions TK"
  opt_tcl=true
else
  myoptions="$myoptions NOGUI"
fi

if [ $opt_tcl = true ]; then myoptions="$myoptions TCL"; fi
if [ $opt_remote = true ]; then myoptions="$myoptions REMOTE"; fi
if [ $opt_cave = true ]; then myoptions="$myoptions CAVE"; fi
if [ $opt_alpha = true ]; then myoptions="$myoptions ALPHA"; fi
if [ $opt_surf = true ]; then myoptions="$myoptions SURF"; fi
if [ $opt_unc = true ]; then myoptions="$myoptions UNC"; fi
if [ $opt_external = true ]; then myoptions="$myoptions EXTERNAL"; fi
if [ $opt_sigma = true ]; then myoptions="$myoptions SIGMA"; fi
if [ $opt_debug = true ]; then myoptions="$myoptions DEBUG"; fi
if [ $opt_optim = true ]; then myoptions="$myoptions OPTIMIZE"; fi
if [ $opt_remake = true ]; then myoptions="$myoptions MAKE"; fi
if [ $opt_silent = false ]; then myoptions="$myoptions NOSILENT"; fi

echo "Configuring for architecture $myarch, with the following options:"
echo "   $myoptions"

# create object code working directory, which is where the lib is made
if [ ! -d $myarch ]; then mkdir $myarch; fi 


###########################
# create new makefile
###########################
# create new makefile
###########################
# write data to temporary file, then copy the file to the proper places
###########################
mkfile="temporary_Makefile"
rm -rf $mkfile
echo "# vmd Makefile, generated by configure: `date`" > $mkfile
echo "#" >> $mkfile

###########################
# next section: configurable parameters, based on options
###########################

echo "ARCH			= $myarch" >> $mkfile
echo "INSTALLNAME		= $INSTALLNAME" >> $mkfile
echo "INSTALLLIBDIR		= $INSTALLLIBDIR" >> $mkfile
echo "INSTALLBINDIR		= $INSTALLBINDIR" >> $mkfile
echo "INSTALLFTPDIR		= $INSTALLFTPDIR" >> $mkfile
echo "DEFHTMLVIEWER		= $DEFHTMLVIEWER" >> $mkfile
echo "DEFBABELBIN		= $DEFBABELBIN" >> $mkfile
echo "DEFDISPLAY		= $DEFDISPLAY" >> $mkfile
echo "DEFTITLE			= $DEFTITLE" >> $mkfile
echo "DEFHEIGHT			= $DEFHEIGHT" >> $mkfile
echo "DEFDIST			= $DEFDIST" >> $mkfile
echo "DEFTMPDIR			= $DEFTMPDIR" >> $mkfile
echo "INITFILENAME		= $INITFILENAME" >> $mkfile
echo "MAXSTRINGLEN		= $MAXSTRINGLEN" >> $mkfile
echo "PROGNAME			= $INSTALLNAME"_"$myarch" >> $mkfile
echo "PROGVERSION		= $PROGVERSION" >> $mkfile
echo "PROMPTSTRING		= \"$PROMPTSTRING\"" >> $mkfile
echo "STARTUPFILENAME		= $STARTUPFILENAME" >> $mkfile

echo "TCLINCLUDEDIR		= $TCL_INCLUDE_DIR" >> $mkfile
echo "TCLLIBRARYDIR		= $TCL_LIBRARY_DIR" >> $mkfile

echo "TCLXINCLUDEDIR		= $TCLX_INCLUDE_DIR" >> $mkfile
echo "TCLXLIBRARYDIR		= $TCLX_LIBRARY_DIR" >> $mkfile

echo "TCLDPINCLUDEDIR		= $TCLDP_INCLUDE_DIR" >> $mkfile
echo "TCLDPLIBRARYDIR		= $TCLDP_LIBRARY_DIR" >> $mkfile

echo "OPENGLINCLUDEDIR		= $OPENGL_INCLUDE_DIR" >> $mkfile
echo "OPENGLLIBRARYDIR		= $OPENGL_LIBRARY_DIR" >> $mkfile
echo "OPENGLLIBRARIES 		= $OPENGL_LIBRARIES" >> $mkfile

echo "AUTHORS			= \"$AUTHORS\"" >> $mkfile
echo "VMD_ARCH  		= \"$myarch\"" >> $mkfile
echo "VMD_OPTIONS		= \"$myoptions\"" >> $mkfile
echo "VMD_HOMEPAGE		= \"$VMD_HOMEPAGE\"" >> $mkfile
echo "VMD_HELPPAGE		= \"$VMD_HELPPAGE\"" >> $mkfile

# write proper optimization flag
if [ $opt_optim = true ]; then
  echo "OPTIMIZEFLAG		= \$(ARCH_OPT_FLAG)" >> $mkfile
elif [ $opt_debug = true ]; then
  echo "OPTIMIZEFLAG		= \$(ARCH_DBG_FLAG)" >> $mkfile
else
  echo "OPTIMIZEFLAG              = " >> $mkfile
fi

# signal if make commands should be echoed to the screen, or kept silent
if [ $opt_silent = true ]; then
  echo ".SILENT:" >> $mkfile
fi

cat << \MAKEDECLTXT >> $mkfile

############################################################################
##################  no more configuration beyond this point  ###############
############################################################################

# makefile configuration
VPATH                   = .:../src
SHELL 			= /bin/sh
.SUFFIXES: .C .c ..c .i .o

#################################################################
# file which contains makefile dependencies (generated by make depend)
DEPENDFILE 		= Makedata.depend

# directories for object files, scripts, and different parts of code.
# these are all relative to being in any of the subdirs of the main directory
# such as the src, lib, or bin dirs
MAINDIR			= ../.
SRCDIR 			= ../src
OBJDIR 			= ../$(ARCH)
VMDLIBDIR		= ../lib
SCRIPTLIBDIR		= ../lib
DATADIR			= ../data
BINDIR			= ../bin
DOCDIR			= ../doc
PROTEINSDIR		= ../proteins
BASEDISTRIBDIR		= ../distrib

# information on how to create the distribution
BASEDISTRIBFILE		= $(INSTALLNAME)-$(PROGVERSION)
BASEDISTRIBALLFILE	= $(BASEDISTRIBFILE).all.tar
BASEDISTRIBBINFILE	= $(BASEDISTRIBFILE).bin.tar
LINKDISTRIBALLFILE	= $(INSTALLNAME).all.tar
LINKDISTRIBBINFILE	= $(INSTALLNAME).bin.tar
DISTRIBDIR		= $(BASEDISTRIBDIR)/$(BASEDISTRIBFILE)
DISTRIBMAINDIRS		= bin data lib proteins src
DISTRIBDOCDIRS		= doc
### the CAVE and XForms cannot be redistributed by us
# so when making the distribution move xforms to xforms.local
# and xforms.distrib to xforms.  Do the same for the CAVE
DISTRIBLIBS		= cave xforms libg++ mdcomm unc tcl
DISTRIBLIBSEXTRA	= cave xforms libg++ unc tcl
DISTRIBPROTEINS		= \
			$(PROTEINSDIR)/alanin.pdb \
			$(PROTEINSDIR)/alanin.psf \
			$(PROTEINSDIR)/alanin.DCD \
			$(PROTEINSDIR)/deoxy.pdb \
			$(PROTEINSDIR)/mbco.pdb \
			$(PROTEINSDIR)/star.pdb

# directory where to put the ftp files
FTPDIR                  = $(INSTALLFTPDIR)

# dirs for extra includes (except for OPTIONS, must have -I appended in front)
INCDIRS	= -I. -I$(VMDLIBDIR)/libg++/include $(OPTIONSINCDIRS) -I/usr/include

# dir for extra libs (except for OPTIONS, must have -l & -L appended in front)
LIBDIRS	= -L. -L$(VMDLIBDIR)/libg++/lib_$(ARCH) $(OPTIONSLIBDIRS)

# set up the libs
# the -ll is for the lex library - you might not need it
LIBS		= -ll -lg++ $(OPTIONSLIBS) -lm

# compiler and linker options
CFLAGS		= $(ARCH_COPTS)		$(OPTIMIZEFLAG) $(INCDIRS) \
			-DARCH_$(ARCH)	$(OPTIONSDEFS)	$(USER_COPTS)
CPPFLAGS	= $(ARCH_CPPOPTS)	$(OPTIMIZEFLAG) $(INCDIRS) \
			-DARCH_$(ARCH)	$(OPTIONSDEFS)	$(USER_CPPOPTS)

LFLAGS		= $(LIBDIRS) 	$(LIBS)	$(ARCH_LOPTS)
YFLAGS		= -d

#################################################################
# architecture-specific declarations:
#################################################################
MAKEDECLTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

###########################
# write architecture-specific options
###########################

if [ "$myarch" = "IRIX4" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEIRIX4TXT >> $mkfile
# definitions for IRIX4 architecture
#####
# specific names of programs used in make commands
#####
GLINCDIR	=
GLLIBDIR	=
GLLIBNAME	= -lsphere -lfm_s -lgl_s 
CD		= cd
COPY		= cp
COPYDIR		= cp -r
MAKEDIR		= mkdir
MOVE		= mv -f
DELETE		= rm -f
DELETEDIR	= rm -rf
ECHO		= echo
TAR		= tar
COMPRESS	= compress
GNUCOMPRESS	= /usr/local/bin/gzip
AR		= ar rsc
RANLIB		= /bin/true
COCMD		= co -q
COLOCKCMD	= co -l
CICMD		= ci -m"No message"
LATEX		= latex

#####
# compiler and linker options
#####
CCPP		= CC
CC		= cc
LEX		= lex
YACC		= yacc
ARCH_OPT_FLAG	= -O
ARCH_DBG_FLAG	= -g
ARCH_DEP_FLAG	= -c -M
ARCH_COPTS	=
ARCH_CPPOPTS	= -I/usr/include/CC
ARCH_LOPTS      = -L/usr/lib -lmalloc -lsun -lc_s

MAKEIRIX4TXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

elif [ "$myarch" = "IRIX5" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEIRIX5TXT >> $mkfile
# definitions for IRIX5 architecture
#####
# specific names of programs used in make commands
#####
GLINCDIR	=
GLLIBDIR	=
GLLIBNAME	= -lsphere -lfm_s -lgl_s 
CD		= cd
COPY		= cp
COPYDIR		= cp -r
MAKEDIR		= mkdir
MOVE		= mv -f
DELETE		= rm -f
DELETEDIR	= rm -rf
ECHO		= echo
TAR		= tar
COMPRESS	= compress
GNUCOMPRESS	= /usr/local/bin/gzip
AR		= ar rsc
RANLIB		= /bin/true
COCMD		= co -q
COLOCKCMD	= co -l
CICMD		= ci -m"No message"
LATEX		= latex

#####
# extra compiler and linker options
#####
CCPP		= CC
CC		= cc
LEX		= lex
YACC		= yacc
ARCH_OPT_FLAG	= -O
ARCH_DBG_FLAG	= -g
ARCH_DEP_FLAG	= -c -M
ARCH_COPTS	=
ARCH_CPPOPTS	= -I/usr/include/CC
ARCH_LOPTS      = -L/usr/lib -lmalloc -lc_s

MAKEIRIX5TXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

elif [ "$myarch" = "HPUX9" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEHPUX9TXT >> $mkfile
# definitions for HPUX9 architecture
#####
# specific names of programs used in make commands
#####
GLINCDIR	= -I$(NPGLHOME)/include
GLLIBDIR	= -L/usr/lib/X11R5 -L$(NPGLHOME)/lib
GLLIBNAME	= -Wl,-a,archive -lnpgl_ansi \
		-Wl,-a,shared -lXwindow -lsb -lXhp11 -lX11 -lm -ldld
CD		= cd
COPY		= cp
COPYDIR		= cp -r
MAKEDIR		= mkdir
MOVE		= mv -f
DELETE		= rm -f
DELETEDIR	= rm -rf
ECHO		= echo
TAR		= tar
COMPRESS	= compress
GNUCOMPRESS	= /usr/local/bin/gzip
AR		= ar rsc
RANLIB		= /bin/true
COCMD		= co -q
COLOCKCMD	= co -l
CICMD		= ci -m"No message"
LATEX		= latex

#####
# extra compiler and linker options
# This is for compiling and linking with the NPGL library on HPUX 9.x
#####
CCPP		= CC
CC		= cc
LEX		= lex
YACC		= yacc
ARCH_OPT_FLAG	= -O
ARCH_DBG_FLAG	= -g
ARCH_DEP_FLAG	=
ARCH_COPTS	= -Ae
ARCH_CPPOPTS	= +a1
ARCH_LOPTS      = -lmalloc

MAKEHPUX9TXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

elif [ "$myarch" = "AIX3" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEAIX3TXT >> $mkfile
# definitions for AIX3 architecture
#####
# specific names of programs used in make commands
#####
# SPECIAL NOTE:  when compiling templates during the link phase 
#  ResizeArray.c seems to be compiled twice, which gives errors the
#  second time and stops the link.  To fix this, edit "tempinr/ResizeArray.C"
#  and delete the second occurance of the line 
#   /* 0000000 */ [....]  ResizeArray.c
GLINCDIR	= 
GLLIBDIR	= -L/usr/lib/X11R5
GLLIBNAME	= -lgl
CD		= cd
COPY		= cp
COPYDIR		= cp -r
MAKEDIR		= mkdir
MOVE		= mv -f
DELETE		= rm -f
DELETEDIR	= rm -rf
ECHO		= echo
TAR		= tar
COMPRESS	= compress
GNUCOMPRESS	= /usr/local/bin/gzip
AR		= ar rsc
RANLIB		= /bin/true
COCMD		= co -q
COLOCKCMD	= co -l
CICMD		= ci -m"No message"
LATEX		= latex

#####
# extra compiler and linker options
# This is for compiling and linking on AIX3 with the GL library.
# (This machine doesn't have features we thought were standard)
#####
# on our machines this is at /home/dalke/ftps/flex/flex-2.5.2/flex
CCPP		= xlC
CC		= xlc
LEX		= flex
YACC		= yacc
ARCH_OPT_FLAG	= -O
ARCH_DBG_FLAG	= -g
ARCH_DEP_FLAG	=
ARCH_COPTS	= -Ae
ARCH_CPPOPTS	= -D"sqrtf(x)=sqrt(x)" -D"strcasecmp(x,y)=strupcmp(x,y)" \
		-D"cosf(x)=cos(x)" -D"sinf(x)=sin(x)" -D"fabsf(x)=fabs(x)" \
		 -D"strncasecmp(x,y,n)=strupncmp(x,y,n)" -D"acosf(x)=acos(x)"
ARCH_LOPTS      =

MAKEAIX3TXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

elif [ "$myarch" = "LINUX" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKELINUXTXT >> $mkfile
# definitions for Linux architecture
#####
# specific names of programs used in make commands
#####
GLINCDIR	= 
GLLIBDIR	= 
GLLIBNAME	= 
CD		= cd
COPY		= cp
COPYDIR		= cp -r
MAKEDIR		= mkdir
MOVE		= mv -f
DELETE		= rm -f
DELETEDIR	= rm -rf
ECHO		= echo
TAR		= tar
COMPRESS	= compress
GNUCOMPRESS	= gzip
AR		= ar rsc
RANLIB		= ranlib
COCMD		= co -q
COLOCKCMD	= co -l
CICMD		= ci -m"No message"
LATEX		= latex

#####
# extra compiler and linker options
#####
CCPP		= g++
CC		= gcc
LEX		= lex
YACC		= yacc
ARCH_OPT_FLAG	= -O
ARCH_DBG_FLAG	= -g
ARCH_DEP_FLAG	= -MM
ARCH_COPTS	= -DNO_FLOAT_MATH -DNO_SELECT_HEADER
ARCH_CPPOPTS	= -DNO_FLOAT_MATH -DNO_SELECT_HEADER
ARCH_LOPTS      =

MAKELINUXTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
fi

###########################
# write definitions for different configurable options
###########################
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEOPTIONSHEADTXT >> $mkfile
#################################################################
# optional components
#################################################################
MAKEOPTIONSHEADTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
echo "# options included: $myoptions" >> $mkfile

for opt in $myoptions; do
  if [ "$opt" = "GL" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEGLTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: use GL library for windows and graphics
#	This specifies the libraries used for the rendering library and
#	window manager.
#######################

GRAPHICSDEF		= -DVMDGRAPHICS -DVMDGL
GRAPHICSINCDIR		= $(GLINCDIR)
GRAPHICSLIBDIR		= $(GLLIBDIR)
GRAPHICSLIB		= $(GLLIBNAME)
GRAPHICS_CCPP		= \
				GLDisplayDevice.C \
				GLRenderer.C
GRAPHICS_CC		=
GRAPHICS_H		= \
				GLDisplayDevice.h \
				GLRenderer.h
GRAPHICS_EXTRA		=
GRAPHICS_OBJS		= $(GRAPHICS_CCPP:.C=.o)	$(GRAPHICS_CC:.c=.o)

MAKEGLTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "OPENGL" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEOPENGLTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: use OpenGL library for windows, and X for graphics
#	This specifies the libraries used for the rendering library and
#	window manager.
# NOTE: OpenGL uses post-multiply matrix mode, instead of pre-multiply.
#######################

GRAPHICSDEF		= -DVMDGRAPHICS -DVMDOPENGL -DMATRIX_POST_MULTIPLY \
			  -DUSE_SLOW_CYLINDERS
GRAPHICSINCDIR		= $(OPENGLINCLUDEDIR)
GRAPHICSLIBDIR		= $(OPENGLLIBRARYDIR)
GRAPHICSLIB		= $(OPENGLLIBRARIES)
GRAPHICS_CCPP		= \
				OpenGLDisplayDevice.C \
				OpenGLRenderer.C
GRAPHICS_CC		=
GRAPHICS_H		= \
				OpenGLDisplayDevice.h \
				OpenGLRenderer.h
GRAPHICS_EXTRA		=
GRAPHICS_OBJS		= $(GRAPHICS_CCPP:.C=.o)	$(GRAPHICS_CC:.c=.o)

MAKEOPENGLTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "STARBASE" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKESTARBASETXT >> $mkfile

#######################
# OPTIONAL COMPONENT: use HP Starbase library for graphics.
#       This specifies the libraries used for the rendering library and
#       window manager. libtksb is the Tk Starbase widget and Tcl bindings;
#       configuring STARBASE requires (and specifies) TK and TCL as well.
#######################

GRAPHICSDEF             = -DVMDGRAPHICS -DVMDSTARBASE
GRAPHICSINCDIR          = -I/usr/include/X11R5
GRAPHICSLIBDIR          = -L/usr/lib/X11R5
GRAPHICSLIB             = -ltksb -lXwindow -lsb -lsbdl -lXhp11 -lX11 -lm -ldld
GRAPHICS_CCPP           = \
                                SBDisplayDevice.C \
                                SBRenderer.C
GRAPHICS_CC             =
GRAPHICS_H              = \
                                SBDisplayDevice.h \
                                SBRenderer.h
GRAPHICS_EXTRA          =
GRAPHICS_OBJS           = $(GRAPHICS_CCPP:.C=.o)        $(GRAPHICS_CC:.c=.o)

MAKESTARBASETXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "TCL" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKETCLTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: use Tcl library for script parsing and interpreting
#	Tcl allows VMD to contain a general scripting language with variables,
# control loops, and other fun stuff.  If it is not included, VMD text
# commands will still work, but the general interpreted script capabilities
# will not be available.  The Tcl library must already be installed on
# the system to allow this option to work.
#	All Tcl-specific code is contained in UIText.C
#######################

TCLDEF			= -DVMDTCL
TCLINCDIR		= -I$(TCLINCLUDEDIR) -I$(TCLXINCLUDEDIR)
TCLLIBDIR		= -L$(TCLLIBRARYDIR) -L$(TCLXLIBRARYDIR)
TCLLIB			= -ltclx -ltcl
TCL_CCPP		= ColorInfo.C TclCommands.C MolInfo.C TclGraphics.C \
			Measure.C
TCL_CC			=
TCL_H			= TclCommands.h Measure.h
TCL_EXTRA		=
TCL_OBJS		= $(TCL_CCPP:.C=.o)	$(TCL_CC:.c=.o)

MAKETCLTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "FORMS" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEFORMSTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Use FORMS GUI library
#	This specifies the library used for the on-screen GUI with buttons,
#	menus, etc.
#######################

# FORMS version
GUIDEF			= -DVMDGUI -DVMDFORMS 
GUIDIR			= $(VMDLIBDIR)/xforms
GUIINCDIR		= -I$(GUIDIR)/include 
GUILIBDIR		= -L$(GUIDIR)/$(ARCH) 
GUILIB			= -lforms -lX11
GUI_CCPP		= \
				AnimateFormsObj.C \
				ColorFormsObj.C \
				DisplayFormsObj.C \
				EditFormsObj.C \
				FilesFormsObj.C \
				FormsObj.C \
				GeometryFormsObj.C \
				GraphicsFormsObj.C \
				MainFormsObj.C \
				MolFormsObj.C \
				RemoteFormsObj.C \
				RenderFormsObj.C \
				SimFormsObj.C \
				TrackerFormsObj.C
GUI_CC			= forms_ui.c
GUI_H			= forms_ui.h \
				AnimateFormsObj.h \
				ColorFormsObj.h \
				DisplayFormsObj.h \
				EditFormsObj.h \
				FilesFormsObj.h \
				FormsObj.h \
				GeometryFormsObj.h \
				GraphicsFormsObj.h \
				MainFormsObj.h \
				MolFormsObj.h \
				RemoteFormsObj.h \
				RenderFormsObj.h \
				SimFormsObj.h \
				TrackerFormsObj.h
GUI_EXTRA		= forms_ui.fd
GUI_OBJS		= $(GUI_CCPP:.C=.o)	$(GUI_CC:.c=.o)

MAKEFORMSTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "TK" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKETKTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Use TK GUI library
#       This specifies the library used for the on-screen GUI with buttons,
#       menus, etc. This requires (and explicitly adds) the TCL option.
#       Because TCLDIR etc. specify the location of Tk code as well,
#       not all of the variables are specified here. This also pulls in
#       Extended Tcl and Tk, because they are so useful in writing Tcl code.
#######################

# TK version
GUIDEF                  = -DVMDGUI -DVMDTK
GUIDIR                  = $(VMDLIBDIR)/tcl
GUIINCDIR               = -I$(GUIDIR)/include
GUILIBDIR               = -L$(GUIDIR)/lib_$(ARCH)
GUILIB                  = -ltkx -ltk -ltclx -ltcl -lX11 -lm
GUI_CCPP                = \
				TclCmd.C \
                                UITk.C
GUI_CC                  =
GUI_H                   = UITk.h
GUI_EXTRA               =
GUI_OBJS                = $(GUI_CCPP:.C=.o)     $(GUI_CC:.c=.o)

MAKETKTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "REMOTE" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEREMOTETXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Remote simulation connection support
#	This may be commented out if not required.
#	This allows the program to connect to or launch an MD simulation
#	on a remote computer, and to control and view the simulation results
#	on-line.  It requires an MD application modified to communicate with
#	this program (a primary example of this is namd).
#######################

REMOTEDEF		= -DVMDREMOTE
REMOTEDIR		= $(VMDLIBDIR)/mdcomm
REMOTEINCDIR		= -I$(REMOTEDIR)/include
#Alas, rapp uses a different ARCH spec than we do ...
REMOTELIBDIR		= -L$(REMOTEDIR)/lib_$(ARCH)
REMOTELIB		= -lrapp
REMOTE_CCPP		= \
				CmdRemote.C \
				MDCommUserCommands.C \
				MoleculeRemote.C \
				Remote.C \
				RemoteList.C \
				mdcomm.C
 
REMOTE_CC		=
REMOTE_H		= \
				CmdRemote.h \
				MDCommUserCommands.h \
				MoleculeRemote.h \
				Remote.h \
				RemoteList.h \
				mdcomm.h
REMOTE_EXTRA		=
REMOTE_OBJS		= $(REMOTE_CCPP:.C=.o)	$(REMOTE_CC:.c=.o)

# executable programs for mdcomm system (in lib/mdcomm/bin_ARCH dir)
REMOTE_CONFDIR		= rappd
REMOTE_CONSUMER		= namd_consumer
REMOTE_APPDAEMON	= namdd
REMOTE_DAEMON		= rappd
REMOTE_PROGRAMS		= \
				$(REMOTE_CONSUMER) \
				$(REMOTE_APPDAEMON) \
				$(REMOTE_DAEMON)

MAKEREMOTETXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "SIGMA" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKESIGMATXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Sigma connection support
#	This may be commented out if not required.
#	This allows the program to connect to the Sigma MD code over
#	Unix sockets to control and view simulations online.
#######################

SIGMADEF		= -DVMDSIGMA
SIGMADIR		= $(VMDLIBDIR)/sigma
SIGMAINCDIR		= -I$(SIGMADIR)/include
SIGMALIBDIR		= -L$(SIGMADIR)/lib_$(ARCH)
SIGMALIB		= -lgeneral
SIGMA_CCPP		= \
				CmdSigma.C \
				PickModeDrag.C \
				MoleculeSigma.C
SIGMA_CC		=
SIGMA_H			= \
				CmdSigma.h \
				PickModeDrag.h \
				MoleculeSigma.h
SIGMA_EXTRA		=
SIGMA_OBJS		= $(SIGMA_CCPP:.C=.o)  $(SIGMA_CC:.c=.o)

MAKESIGMATXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "UNC" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEUNCTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: UNC Tracker library support
#	This may be commented out if not required.
#	This allows the use of many different spatial trackers with the
#	library developed at U. of North Carolina.  Without it, non-CAVE
#	tracking is not allowed.
#######################

UNCDEF			= -DVMDUNC
UNCDIR			= $(VMDLIBDIR)/unc
UNCINCDIR		= -I$(UNCDIR)/include
UNCLIBDIR		= -L$(UNCDIR)/lib_$(ARCH)
UNCLIB			= -ltracker -lquat
UNC_CCPP		= UNCTracker.C
UNC_CC			=
UNC_H			= UNCTracker.h
UNC_EXTRA		=
UNC_OBJS		= $(UNC_CCPP:.C=.o)	$(UNC_CC:.c=.o)

MAKEUNCTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "EXTERNAL" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEEXTERNALTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: External interface
#	This may be commented out if not required.
#	This allows other programs to communicate with vmd via Tcl-DP
#######################

EXTERNALDEF		= -DVMDEXTERNAL
#EXTERNALDIR		= /usr/local
EXTERNALINCDIR		= -I$(TCLDP_INCLUDE_DIR)
EXTERNALLIBDIR		= -I$(TCLDP_LIBRARY_DIR)
# we use tcl-dp3.2 without Tk, so need libdplite instead of libdpnetwork
EXTERNALLIB		= -ldplite
EXTERNAL_CCPP		= 
EXTERNAL_CC		=
EXTERNAL_H		=
EXTERNAL_EXTRA		=
EXTERNAL_OBJS		= $(EXTERNAL_CCPP:.C=.o)	$(EXTERNAL_CC:.c=.o)

MAKEEXTERNALTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "CAVE" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

    cat << \MAKECAVETXT >> $mkfile

#######################
# OPTIONAL COMPONENT: EVL/NCSA CAVE support
#	This may be commented out if not required.
#	This will require access to the cave library and headers, and will
#	result in unique CAVE objects being used in the program.
#######################

CAVEDEF			= -DVMDCAVE
CAVEDIR			= $(VMDLIBDIR)/cave
CAVEINCDIR		= -I$(CAVEDIR)/include
CAVELIBDIR		= -L$(CAVEDIR)/lib_$(ARCH)
CAVELIB			= -lcave -lsnd
CAVE_CCPP		= \
				CaveDisplayDevice.C \
				CaveScene.C \
				CaveRoutines.C \
				CaveTracker.C
CAVE_CC			=
CAVE_H			= \
				CaveDisplayDevice.h \
				CaveResizeArray.h 	CaveResizeArray.c \
				CaveRoutines.h \
				CaveScene.h \
				CaveTracker.h
CAVE_EXTRA		=
CAVE_OBJS		= $(CAVE_CCPP:.C=.o)	$(CAVE_CC:.c=.o)

MAKECAVETXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "ALPHA" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   cat << \MAKEALPHATXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Alpha shape code
#	This is the interface between vmd and the alpha shape programs
# from Edelsbrunner's group.  Their code has not yet been released so
# it is doubtful that you will be able to use this.
#######################
ALPHADEF		= -DVMDALPHA_SHAPE
ALPHADIR		= $(VMDLIBDIR)/alpha
ALPHAINCDIR		= -I$(ALPHADIR)/include
ALPHALIBDIR		= -L$(ALPHADIR)/lib_$(ARCH)
ALPHALIB		= -l_alf
ALPHA_CCPP		= AlphaShape.C
ALPHA_CC		=
ALPHA_H			= AlphaShape.h
ALPHA_EXTRA		=
ALPHA_OBJS		= $(ALPHA_CCPP:.C=.o)	$(ALPHA_CC:.c=.o)

MAKEALPHATXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "SURF" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   cat << \MAKESURFTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: SURF shape code
#	This is the interface between vmd and the SURF program
# from UNC (see ftp.cs.unc.edu in /pub/projects/GRIP/SURF)
#######################
SURFDEF			= -DVMDSURF
SURFDIR			= ../lib/surf
SURFINCDIR		= 
SURFLIBDIR		= 
SURFLIB			= 
SURF_CCPP		= DrawMolItemSurface.C Surf.C
SURF_CC			=
SURF_H			= Surf.h
SURF_EXTRA		=
SURF_OBJS		= $(SURF_CCPP:.C=.o)	$(SURF_CC:.c=.o)
SURF_EXE		= surf_$(ARCH)

MAKESURFTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  elif [ "$opt" = "DEBUG" ]; then
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    cat << \MAKEDEBUGTXT >> $mkfile

#######################
# OPTIONAL COMPONENT: Debugging code
#	This will include many statements that print debugging info.
# Note that including this will make the program VERY VERY SLOW.
#######################
DEBUGDEF		= -DVMDDEBUG

MAKEDEBUGTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  fi
done

###### final optional components Makefile statements
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEOPTIONSENDTXT >> $mkfile

OPTIONSDEFS	= $(GRAPHICSDEF)	$(GUIDEF)	$(REMOTEDEF) \
			$(UNCDEF)	$(CAVEDEF) 	$(TCLDEF) \
			$(SIGMADEF)	$(EXTERNALDEF)	$(DEBUGDEF) \
			$(ALPHADEF)	$(SURFDEF)
OPTIONSINCDIRS	= $(GRAPHICSINCDIR)	$(GUIINCDIR)	$(REMOTEINCDIR) \
			$(UNCINCDIR)	$(CAVEINCDIR) 	$(TCLINCDIR) \
			$(SIGMAINCDIR)	$(EXTERNALINCDIR) \
			$(ALPHAINCDIR)  $(SURFINCDIR)
OPTIONSLIBDIRS	= $(GRAPHICSLIBDIR)	$(GUILIBDIR)	$(REMOTELIBDIR) \
			$(UNCLIBDIR)	$(CAVELIBDIR) 	$(TCLLIBDIR)  \
			$(SIGMALIBDIR)	$(EXTERNALLIBDIR) \
			$(ALPHALIBDIR)	$(SURFLIBDIR)
OPTIONSLIBS	= $(GRAPHICSLIB)	$(GUILIB)	$(REMOTELIB) \
			$(UNCLIB)	$(CAVELIB) 	$(TCLLIB) \
			$(SIGMALIB)	$(EXTERNALLIB)  $(ALPHALIB) \
			$(SURFLIB)
OPTIONS_CCPP	= $(GRAPHICS_CCPP)	$(GUI_CCPP)	$(REMOTE_CCPP) \
			$(UNC_CCPP)	$(CAVE_CCPP) 	$(TCL_CCPP) \
			$(SIGMA_CCPP)	$(EXTERNAL_CCPP) \
			$(ALPHA_CCPP)	$(SURF_CCPP)
OPTIONS_CC	= $(GRAPHICS_CC)	$(GUI_CC)	$(REMOTE_CC) \
			$(UNC_CC)	$(CAVE_CC) 	$(TCL_CC) \
			$(SIGMA_CC)	$(EXTERNAL_CC)	$(ALPHA_CC) \
			$(SURF_CC)
OPTIONS_H	= $(GRAPHICS_H)		$(GUI_H)	$(REMOTE_H) \
			$(UNC_H)	$(CAVE_H) 	$(TCL_H) \
			$(SIGMA_H)	$(EXTERNAL_H)	$(ALPHA_H) \
			$(SURF_H)
OPTIONS_EXTRA	= $(GRAPHICS_EXTRA)	$(GUI_EXTRA)	$(REMOTE_EXTRA) \
			$(UNC_EXTRA)	$(CAVE_EXTRA) 	$(TCL_EXTRA) \
			$(SIGMA_EXTRA)	$(EXTERNAL_EXTRA) \
			$(ALPHA_EXTRA)  $(SURF_EXTRA)
OPTIONS_OBJS	= $(GRAPHICS_OBJS)	$(GUI_OBJS)	$(REMOTE_OBJS) \
			$(UNC_OBJS)	$(CAVE_OBJS) 	$(TCL_OBJS) \
			$(SIGMA_OBJS)	$(EXTERNAL_OBJS) \
			$(ALPHA_OBJS)	$(SURF_OBJS)
OPTIONS_SRCS	= $(OPTIONS_CCPP)	$(OPTIONS_CC)

#######################
# end of optional component selection
#######################

MAKEOPTIONSENDTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

#######################
# write lists of all common files in program
#######################
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKEFILELISTTXT >> $mkfile

# VMD source files
VMD_CCPP	= \
		Animation.C \
		ArtDisplayDevice.C \
		AtomColor.C \
		AtomRep.C \
		AtomSel.C \
		Axes.C \
		BabelConvert.C \
		BaseMolecule.C \
		Buttons.C \
		CmdAnimate.C \
		CmdColor.C \
		CmdDisplay.C \
		CmdLabel.C \
		CmdMenu.C \
		CmdMol.C \
		CmdMouse.C \
		CmdPick.C \
		CmdRender.C \
		CmdTool.C \
		CmdTracker.C \
		CmdTrans.C \
		CmdUser.C \
		CmdUtil.C \
		ColorList.C \
		ColorUser.C \
		Command.C \
		CommandQueue.C \
		ConfigList.C \
		CoorDCD.C \
		CoorFile.C \
		CoorFileData.C \
		CoorPDB.C \
		DisplayDevice.C \
		Displayable.C \
		DispCmds.C \
		DrawMolecule.C \
		DrawMolItem.C \
		DrawForce.C \
		DrawPatch.C \
		Enterprise.C \
		FileRenderList.C \
		FileRenderer.C \
		Geometry.C \
		GeometryAngle.C \
		GeometryAtom.C \
		GeometryBond.C \
		GeometryDihedral.C \
		GeometryList.C \
		GeometryMol.C \
		GeometryTug.C \
		Global.C \
		GrabTool.C \
		Inform.C \
		Light.C \
		LightList.C \
		Matrix4.C \
		MolAction.C \
		Molecule.C \
		MoleculeList.C \
		MoleculeFile.C \
		MoleculeFileEDM.C \
		MoleculeGraphics.C \
		MoleculeFilePDB.C \
		MoleculeFilePSF.C \
		MoleculeFileRaster3D.C \
		Mouse.C \
		MoveTool.C \
		NormalScene.C \
		ParseTree.C \
		PickList.C \
		PickMode.C \
		PickModeAtomMove.C \
		PickModeCenter.C \
		PickModeMolLabel.C \
		PickModeQuery.C \
		Pickable.C \
		PointerTool.C \
		PopupMenu.C \
		POVDisplayDevice.C \
		RadianceDisplayDevice.C \
		RayShadeDisplayDevice.C \
		R3dDisplayDevice.C \
		ReadDCD.C \
		ReadEDM.C \
		ReadPDB.C \
		ReadPSF.C \
		RotateTool.C \
		Scene.C \
		Stage.C \
		SymbolTable.C \
		TextTracker.C \
		Timer.C \
		Timestep.C \
		Tokenize.C \
		TokenDisplayDevice.C \
		Tool.C \
		ToolControl.C \
		Tracker.C \
		TrackerList.C \
		TransTool.C \
		TugTool.C \
		UIList.C \
		UIObject.C \
		UIText.C \
		UIVR.C \
		VButton.C \
		VMDTitle.C \
		VRegion.C \
		VRegionList.C \
		startup.C \
		utilities.C \
		vmd.C

VMD_CC	=

# VMD header files ... NOTE: for templates, both the .h AND the .c file
#	should be specified on the same line, in this header section.
#	The filename extension for a template source file should be .c,
#	not .C (the case of the extension must match the case of the header
#	file defining the template).  This all is done because template
#	source code files are NOT to be compiled as normal, and should NOT
#	have dependencies generated for them.
VMD_H		= \
		Animation.h \
		ArtDisplayDevice.h \
		Atom.h \
		AtomColor.h \
		AtomParser.h \
		AtomRep.h \
		AtomSel.h \
		Axes.h \
		BabelConvert.h \
		BaseMolecule.h \
		Buttons.h \
		CmdAnimate.h \
		CmdColor.h \
		CmdDisplay.h \
		CmdLabel.h \
		CmdMenu.h \
		CmdMol.h \
		CmdMouse.h \
		CmdPick.h \
		CmdRender.h \
		CmdTool.h \
		CmdTracker.h \
		CmdTrans.h \
		CmdUser.h \
		CmdUtil.h \
		ColorList.h \
		ColorUser.h \
		Command.h \
		CommandQueue.h \
		ConfigList.h \
		CoorDCD.h \
		CoorFile.h \
		CoorFileData.h \
		CoorPDB.h \
		DLinkList.h 		DLinkList.c \
		DispCmds.h \
		DisplayDevice.h \
		Displayable.h \
		DrawMolecule.h \
		DrawMolItem.h \
		DrawForce.h \
		DrawPatch.h \
		Enterprise.h \
		FileRenderList.h \
		FileRenderer.h \
		Fragment.h \
		Geometry.h \
		GeometryAngle.h \
		GeometryAtom.h \
		GeometryBond.h \
		GeometryDihedral.h \
		GeometryList.h \
		GeometryMol.h \
		GeometryTug.h \
		Global.h \
		GrabTool.h \
		Grid.h			Grid.c \
		Inform.h \
		Light.h \
		LightList.h \
		Matrix4.h \
		MolAction.h \
		Molecule.h \
		MoleculeFile.h \
		MoleculeFileEDM.h \
		MoleculeFilePDB.h \
		MoleculeFilePSF.h \
		MoleculeFileRaster3D.h \
                MoleculeGraphics.h \
		MoleculeList.h \
		Mouse.h \
		MouseEvent.h \
		MoveTool.h \
		NameList.h		NameList.c \
		NormalScene.h \
		ParseTree.h \
		PickList.h \
		PickMode.h \
		PickModeAtomMove.h \
		PickModeCenter.h \
		PickModeMolLabel.h \
		PickModeQuery.h \
		Pickable.h \
		PointerTool.h \
		PopupMenu.h \
		POVDisplayDevice.h \
		RadianceDisplayDevice.h \
		RayShadeDisplayDevice.h \
		R3dDisplayDevice.h \
		ResizeArray.h		ResizeArray.c \
		ReadDCD.h \
		ReadEDM.h \
		ReadPDB.h \
		ReadPSF.h \
		Residue.h \
		RotateTool.h \
		Scene.h \
		Stack.h 		Stack.c \
		Stage.h \
		SymbolTable.h \
		TextTracker.h \
		Timer.h \
		Timestep.h \
		Tokenize.h \
		TokenDisplayDevice.h \
		Tool.h \
		ToolControl.h \
		Tracker.h \
		TrackerList.h \
		TransTool.h \
		TugTool.h \
		UIList.h \
		UIObject.h \
		UIText.h \
		UIVR.h \
		VButton.h \
		VMDTitle.h \
		VRegion.h \
		VRegionList.h \
		startup.h \
		utilities.h

# VMD yacc and lex files.  There is only one of each,
#  and they are used for the atom selection parser
VMD_YACC	= AtomParser.y

VMD_LEX		= AtomLexer.l

# summary of the above files
VMD_SRCS	= $(VMD_CCPP)		$(VMD_CC) \
		  $(VMD_YACC)		$(VMD_LEX)
VMD_OBJS	= $(VMD_CCPP:.C=.o)	$(VMD_CC:.c=.o) \
		  $(VMD_LEX:.l=.o)	$(VMD_YACC:.y=.o)

# data files, such as the .vmdrc and other files
VMD_DATA	= \
		vmd_help.html \
		.tracker \
		.vmdrc \
		.vmd_init

# utility scripts, i.e. the script to start up vmd
VMD_BIN		= vmd

# VMD 'extra' files
VMD_EXTRA	=

# other executable files to be included along with VMD
OTHER_EXE	= $(VMDLIBDIR)/LASSP/Det_$(ARCH)\
		$(VMDLIBDIR)/LASSP/Eigen_$(ARCH) \
		$(VMDLIBDIR)/LASSP/Invert_$(ARCH) \
		$(VMDLIBDIR)/stride/stride_$(ARCH)

OTHER_NAMES	= Det_$(ARCH) Eigen_$(ARCH) Invert_$(ARCH) stride_$(ARCH)

###############################
# all components ... includes optional files, defined in Makedata.options
###############################
ALL_CCPP_SRCS	= $(VMD_CCPP)		$(OPTIONS_CCPP)
ALL_CC_SRCS	= $(VMD_CC)		$(OPTIONS_CC)
ALL_YACC_SRCS	= $(VMD_YACC)		$(OPTIONS_YACC)
ALL_LEX_SRCS	= $(VMD_LEX)		$(OPTIONS_LEX)
ALL_SRCS	= $(VMD_SRCS)		$(OPTIONS_SRCS)
ALL_H		= $(VMD_H)		$(OPTIONS_H)
ALL_OBJS	= $(VMD_OBJS)		$(OPTIONS_OBJS)
EXTRA_FILES	= $(VMD_EXTRA)		$(OPTIONS_EXTRA)
DATA_FILES	= $(VMD_DATA)
BINARY_FILES	= 
SCRIPT_FILES	= $(INSTALLNAME)

# main directory utility files, such as this configure script and README
MAIN_DIR_FILES	= \
		Announcement \
		FEEDBACK \
		README \
		configure

###############################
# Documentation files ... all in directory DOCDIR
###############################
DOC_STYLE_FILES	= \
		graphic.sty \
		picinpar.sty

# files needed for the installation guide
MAIN_INST_DOC	= ig.tex
DOC_INST_FILES	= \
		ig_chapters.tex \
		ig_custom.tex \
		ig_install.tex \
		ig_intro.tex \
		ig_macros.tex \
		ig_make.tex \
		ig_unpack.tex
ALL_INST_FILES	= $(MAIN_INST_DOC) $(DOC_INST_FILES)

# files needed for the user's guide
MAIN_USER_DOC	= ug.tex
DOC_USER_FILES	= \
		ug_basics.tex \
		ug_chapters.tex \
		ug_exec_env.tex \
		ug_file_types.tex \
		ug_form_animate.tex \
		ug_form_color.tex \
		ug_form_display.tex \
		ug_form_edit.tex \
		ug_form_file.tex \
		ug_form_graphics.tex \
		ug_form_labels.tex \
		ug_form_main.tex \
		ug_form_mol.tex \
		ug_form_remote.tex \
		ug_form_render.tex \
		ug_form_tracker.tex \
		ug_forms.tex \
		ug_future.tex \
		ug_graphics.tex \
		ug_intro.tex \
		ug_mdcomm.tex \
		ug_misc.tex \
		ug_mol_colors.tex \
		ug_mol_reps.tex \
		ug_mol_selection.tex \
		ug_molecule_info.tex \
		ug_mouse_display.tex \
		ug_mouse_forms.tex \
		ug_other_ui.tex \
		ug_rendering.tex \
		ug_simulation.tex \
		ug_stereo.tex \
		ug_text_ui.tex \
		ug_tutorial.tex \
		ug_vectors.tex

ALL_USER_FILES	= $(MAIN_USER_DOC) $(DOC_USER_FILES)

# files needed for the programmer's guide
MAIN_PROG_DOC	= pg.tex
DOC_PROG_FILES	= \
		pg_chapters.tex \
		pg_codestyle.tex \
		pg_filestruct.tex \
		pg_intro.tex \
		pg_macros.tex \
		pg_make.tex \
		pg_objects.tex \
		pg_structure.tex \
		ColorList.tex \
		ColorUser.tex \
		Command.tex \
		CommandQueue.tex \
		Animation.tex \
		Atom.tex \
		BaseMolecule.tex \
		DLinkList.tex \
		DispCmd.tex \
		DisplayDevice.tex \
		Displayable.tex \
		DrawMolecule.tex \
		Inform.tex \
		Matrix4.tex \
		Molecule.tex \
		Mouse.tex \
		PopupMenu.tex \
		PopupMenuItem.tex \
		NameList.tex \
		ResizeArray.tex \
		Scene.tex \
		Stack.tex \
		Timer.tex \
		Timestep.tex \
		UIList.tex \
		UIObject.tex \
		UIText.tex

ALL_PROG_FILES	= $(MAIN_PROG_DOC) $(DOC_PROG_FILES)

# files needs by all the different guides, and for the book format
MAIN_ALL_DOC	= vmd.tex
DOC_ALL_FILES	= \
		vmd_authors.tex \
		vmd_begindoc.tex \
		vmd_configure.tex \
		vmd_macros.tex \
		vmd_moreinfo.tex \
		vmd_paramcomp.tex \
		vmd_paraminst.tex \
		vmd_ref.tex \
		vmd_style.tex \
		vmd_title.tex

ALL_MAIN_FILES	= $(MAIN_ALL_DOC) $(DOC_ALL_FILES)

DOC_FILES = \
		$(ALL_INST_FILES) \
		$(ALL_PROG_FILES) \
		$(ALL_USER_FILES) \
		$(ALL_MAIN_FILES) \
		$(DOC_STYLE_FILES)

DOC_DRIVER_FILES	= $(MAIN_INST_DOC) $(MAIN_PROG_DOC) $(MAIN_USER_DOC) \
				$(MAIN_ALL_DOC)
DOC_DVI_FILES		= $(DOC_DRIVER_FILES:.tex=.dvi)
DOC_PS_FILES		= $(DOC_DRIVER_FILES:.tex=.ps)

MAKEFILELISTTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

###############################
# Rest of makefile
###############################
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
cat << \MAKERULESTXT >> $mkfile
############################### 
# default rules 
###############################

.C.i:
	$(ECHO) "Preprocessing " $< " --> " $*.i " ..."; \
	$(CCPP) $(CPPFLAGS) -E $(SRCDIR)/$< > $*.i

.C..c:
	$(ECHO) "Translating " $< " --> " $*..c " ..."; \
	$(CCPP) $(CPPFLAGS) -Fc $(SRCDIR)/$< > $*..c

.C.o:
	$(ECHO) "Compiling " $< " --> " $*.o " ..."; \
	$(CCPP) $(CPPFLAGS) -c $(SRCDIR)/$<

.c.o:
	$(ECHO) "Compiling " $< " --> " $*.o " ..."; \
	$(CC) $(CFLAGS) -c $(SRCDIR)/$<

.y.o:
	$(ECHO) "Converting " $< " --> "$@ " ..."; \
	$(YACC) $(YFLAGS) $(SRCDIR)/$<
	$(MOVE) y.tab.c y.tab.C
	$(CCPP) $(CPPFLAGS) -I$(SRCDIR) -c y.tab.C
	$(MOVE) y.tab.o $@
	$(DELETE) y.tab.C y.tab.h

.l.o:
	$(ECHO) "Converting " $< " --> "$@ " ..."; \
	$(LEX) $(SRCDIR)/$<
	$(MOVE) lex.yy.c lex.yy.C
	$(CCPP) $(CPPFLAGS) -I$(SRCDIR) -c lex.yy.C
	$(MOVE) lex.yy.o $@
	$(DELETE) lex.yy.C


###############################
# main target rule
###############################

all default:	$(PROGNAME)

#### executables

$(PROGNAME): $(ALL_OBJS)
	$(ECHO) "Linking " $@ " ..."; \
	$(CCPP) $(CPPFLAGS) -o $@ $(ALL_OBJS) $(LFLAGS)

#### yacc headers

$(SRCDIR)/y.tab.h: $(SRCDIR)/AtomParser.y $(SRCDIR)/AtomParser.h
	$(ECHO) "Creating " $@ " ..."; \
	$(YACC) $(YFLAGS) $(SRCDIR)/AtomParser.y; \
	$(MOVE) y.tab.h $(SRCDIR); \
	$(DELETE) y.tab.c

#### configure include files for src and documentation

version: srcversion docversion

srcversion:
	$(ECHO) "Updating src/config.h ..."; \
	$(CD) $(SRCDIR); \
	if [ -f config.h ]; then $(DELETE) config.h; fi; \
	$(ECHO) \#ifndef CONFIG_OPTIONS_H >> config.h ; \
	$(ECHO) \#define CONFIG_OPTIONS_H >> config.h ; \
	$(ECHO) \#define VMDVERSION \"$(PROGVERSION)\" >> config.h ; \
	$(ECHO) \#define VERSION_MSG \"$(INSTALLNAME) for $(ARCH), version $(PROGVERSION) \(`date +'%B %e, %Y'`\)\" >> config.h ; \
	$(ECHO) \#define CMDLEN $(MAXSTRINGLEN) >> config.h ; \
	$(ECHO) \#define DEF_VMDHTMLVIEWER \"$(DEFHTMLVIEWER)\" >> config.h; \
	$(ECHO) \#define DEF_VMDBABELBIN \"$(DEFBABELBIN)\" >> config.h ; \
	$(ECHO) \#define DEF_VMDENVVAR \"$(INSTALLLIBDIR)\" >> config.h ; \
	$(ECHO) \#define DEF_VMDTMPDIR \"$(DEFTMPDIR)\" >> config.h ; \
	$(ECHO) \#define INIT_DEFDISPLAY DISPLAY_$(DEFDISPLAY) >> config.h ; \
	$(ECHO) \#define INIT_DEFTITLE   TITLE_$(DEFTITLE) >> config.h ; \
	$(ECHO) \#define INIT_DEFHEIGHT  $(DEFHEIGHT) >> config.h ; \
	$(ECHO) \#define INIT_DEFDIST    $(DEFDIST) >> config.h ; \
	$(ECHO) \#define VMD_AUTHORS   \"$(AUTHORS)\" >> config.h ; \
	$(ECHO) \#define VMD_INITFILE  \"$(INITFILENAME)\" >> config.h ; \
	$(ECHO) \#define VMD_STARTUP   \"$(STARTUPFILENAME)\" >> config.h ; \
	$(ECHO) \#define VMD_ARCH      \"$(VMD_ARCH)\" >> config.h ; \
	$(ECHO) \#define VMD_OPTIONS   \"$(VMD_OPTIONS)\" >> config.h ; \
	$(ECHO) \#define VMD_HOMEPAGE  \"$(VMD_HOMEPAGE)\" >> config.h ; \
	$(ECHO) \#define VMD_HELPPAGE  \"$(VMD_HELPPAGE)\" >> config.h ; \
	$(ECHO) \#define VMD_CMD_PROMPT \"$(PROMPTSTRING)\" >> config.h ; \
	$(ECHO) \#endif >> config.h; \
	if [ -d $(UNCDIR)/include ]; then \
	  $(COPY) config.h $(UNCDIR)/include; \
	fi

docversion:
	$(ECHO) "Updating doc/vmd_version.tex ..."; \
	$(CD) $(DOCDIR); \
	if [ -f vmd_version.tex ]; then $(DELETE) vmd_version.tex; fi; \
	$(ECHO) '\\'newcommand\{\\VMDNAME\} \{$(INSTALLNAME)\}>>vmd_version.tex ;\
	$(ECHO) '\\'newcommand\{\\VMDDATE\} \{`date +'%B %e, %Y'`\} >> vmd_version.tex ;\
	$(ECHO) '\\'newcommand\{\\VMDVER\} \{$(PROGVERSION)\}>>vmd_version.tex;\
	$(ECHO) '\\'newcommand\{\\VMDAUTHORS\} \{$(AUTHORS)\}>>vmd_version.tex

###############################
### latex the documentation
###############################
doc doc.all:	doc.ig doc.pg doc.ug

doc.ig:
	$(ECHO) "Creating the installation guide ..." ; \
	$(CD) $(DOCDIR); \
	$(LATEX) $(MAIN_INST_DOC) && \
		dvips -o -Z $(MAIN_INST_DOC:.tex=.dvi)

doc.pg:
	$(ECHO) "Creating the programmers guide ..." ; \
	$(CD) $(DOCDIR); \
	$(LATEX) $(MAIN_PROG_DOC) && \
		dvips -o -Z $(MAIN_PROG_DOC:.tex=.dvi)

doc.ug:
	$(ECHO) "Creating the users guide ..." ; \
	$(CD) $(DOCDIR); \
	$(LATEX) $(MAIN_USER_DOC) && \
		dvips -o -Z $(MAIN_USER_DOC:.tex=.dvi)

doc.book:
	$(ECHO) "Creating the complete documentation book ..." ;\
	$(CD) $(DOCDIR); \
	$(LATEX) $(MAIN_ALL_DOC) && \
		dvips -o -Z $(MAIN_ALL_DOC:.tex=.dvi)

###############################
### installation targets
###############################

### install everything
install.all: install install.doc

### install program and data files in proper directory (i.e. everything except docs)
install: install.exe install.scripts install.data install.mdcomm \
	install.surf install.other

### create installation directories
install.dir:
	if [ ! -d $(INSTALLLIBDIR) ]; then \
		$(MAKEDIR) $(INSTALLLIBDIR); \
	fi ; \
	if [ ! -d $(INSTALLLIBDIR)/doc ]; then \
		$(MAKEDIR) $(INSTALLLIBDIR)/doc; \
	fi

### install executable
install.exe: install.dir
	$(ECHO) "Installing executable(s) in $(INSTALLLIBDIR)"; \
	$(CD) $(SRCDIR); \
	if [ -f $(INSTALLLIBDIR)/$(PROGNAME) ]; then \
		$(COPY) $(INSTALLLIBDIR)/$(PROGNAME) \
			$(INSTALLLIBDIR)/$(PROGNAME)_old ; \
	fi; \
	$(COPY) $(PROGNAME)   $(INSTALLLIBDIR) ; \
	chmod u+w $(INSTALLLIBDIR)/$(PROGNAME)

### install executable and scripts and utilities
install.scripts: install.dir
	$(ECHO) "Installing scripts and utilities in $(INSTALLBINDIR)"; \
	$(CD) $(BINDIR); \
	if [ "$(BIN_FILES)" != "" ]; then \
	  $(COPY) $(BIN_FILES) $(INSTALLBINDIR) ; \
	fi ; \
	if [ -f run_vmd_tmp ]; then $(DELETE) run_vmd_tmp; fi ;\
	$(ECHO) '#!/bin/csh' >> run_vmd_tmp ; \
	$(ECHO) 'set defaultvmddir='$(INSTALLLIBDIR) >> run_vmd_tmp ; \
	$(ECHO) 'set vmdbasename='$(INSTALLNAME) >> run_vmd_tmp ; \
	$(ECHO) 'set consumer='$(REMOTE_CONSUMER) >> run_vmd_tmp ; \
	cat $(VMD_BIN) >> run_vmd_tmp ; \
	chmod +x run_vmd_tmp ; \
	$(COPY) run_vmd_tmp $(INSTALLBINDIR)/$(INSTALLNAME) ; \
	$(DELETE) run_vmd_tmp ; \
	$(ECHO) "Installing scripts.tar in $(INSTALLLIBDIR)"; \
	$(CD) $(SCRIPTLIBDIR) ; \
	cat scripts.tar | (cd $(INSTALLLIBDIR); $(TAR) -xf - )
	

### install data files in proper directory
install.data: install.dir
	$(ECHO) "Installing data files in $(INSTALLLIBDIR)"; \
	$(CD) $(DATADIR); \
	$(COPY) vmd_help.html .tracker $(INSTALLLIBDIR) ; \
	$(COPY) .vmd_init $(INSTALLLIBDIR)/$(INITFILENAME) ; \
	$(COPY) .vmdrc $(INSTALLLIBDIR)/$(STARTUPFILENAME) ; \
	$(CD) $(INSTALLLIBDIR) ; \
	chmod u+w .tracker vmd_help.html $(INITFILENAME) $(STARTUPFILENAME)

### install MDCOMM files (if necessary)
install.mdcomm: install.dir
	if [ "$(REMOTEDEF)" != "" ]; then \
	  $(ECHO) "Installing mdcomm files in $(INSTALLLIBDIR)/mdcomm"; \
	  $(COPYDIR) $(VMDLIBDIR)/mdcomm $(INSTALLLIBDIR) ; \
	fi

#	  if [ ! -d $(INSTALLLIBDIR)/mdcomm/$(REMOTE_CONFDIR) ]; then \
#	    $(MAKEDIR) $(INSTALLLIBDIR)/mdcomm/$(REMOTE_CONFDIR) ; \
#	  fi ; \
#	  if [ -f $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_CONSUMER) ]; then \
#	    $(COPY) $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_CONSUMER)  \
#		$(INSTALLLIBDIR)/mdcomm/$(REMOTE_CONSUMER)_$(ARCH) ; \
#	  fi; \
#	  if [ -f $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_APPDAEMON) ];then \
#	    $(COPY) $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_APPDAEMON)  \
#		$(INSTALLLIBDIR)/mdcomm/$(REMOTE_APPDAEMON)_$(ARCH) ; \
#	  fi; \
#	  if [ -f $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_DAEMON) ];then \
#	    $(COPY) $(VMDLIBDIR)/mdcomm/bin_$(ARCH)/$(REMOTE_DAEMON)  \
#		$(INSTALLLIBDIR)/mdcomm/$(REMOTE_DAEMON)_$(ARCH) ; \
#	  fi; \
#	  $(COPY) $(VMDLIBDIR)/mdcomm/$(REMOTE_CONFDIR)/* \
#		$(INSTALLLIBDIR)/mdcomm/$(REMOTE_CONFDIR); \
#	fi

### install surf files
install.surf: install.dir
	if [ "$(SURFDEF)" != "" ]; then \
	  $(ECHO) "Installing surf files in $(INSTALLLIBDIR)"; \
	  if [ -f $(VMDLIBDIR)/surf_$(ARCH) ]; then \
	    $(COPY) $(VMDLIBDIR)/surf_$(ARCH) $(INSTALLLIBDIR) ; \
          fi ; \
        fi

### install OTHER files
install.other: install.dir
	$(ECHO) "Installing other exe files in $(INSTALLLIBDIR)"; \
	cd $(VMDLIBDIR) ; \
	$(COPY) $(OTHER_NAMES) $(INSTALLLIBDIR) ;

### install documentation in proper directory
install.doc: install.dir
	$(ECHO) "Installing documentation in $(INSTALLLIBDIR)/doc"; \
	$(CD) $(DOCDIR); \
	if [ "$(DOC_PS_FILES)" != "" ]; then \
	  $(COPY) *.ps $(INSTALLLIBDIR)/doc ; \
	fi

###############################
### create distribution files
###############################

#### create the distribution directory
distrib.dir:
	if [ ! -d $(DISTRIBDIR) ]; then \
	  $(ECHO) "Creating source distribution dir $(DISTRIBDIR) ..."; \
	  $(MAKEDIR) $(DISTRIBDIR); \
	  $(CD) $(DISTRIBDIR); \
	  $(MAKEDIR) $(DISTRIBMAINDIRS) $(DISTRIBDOCDIRS); \
	fi

#### copy over the bin files
distrib.bin:	distrib.dir
	$(ECHO) "Copying distribution files from 'bin' ..." ; \
	$(CD) $(BINDIR) ; \
	$(COPY) $(VMD_BIN) $(BIN_FILES) $(DISTRIBDIR)/bin

#### create a tar file of all the script files (tcl, tclX, dp, and vmd)
distrib.scripts.tar: distrib.dir
	$(ECHO) "Creating script distribution tar file" ; \
	$(CD) $(SCRIPTLIBDIR) ; \
	if [ -f scripts.tar ] ; then $(DELETE) scripts.tar; fi; \
	$(TAR) cf scripts.tar scripts

#### copy the scripts tar file to the distrib lib dir
distrib.scripts: distrib.dir distrib.scripts.tar
	pwd
	$(ECHO) "Copying $(SCRIPTLIBDIR)/scripts.tar to '$(DISTRIBDIR)/lib'"; \
	$(COPY) $(SCRIPTLIBDIR)/scripts.tar $(DISTRIBDIR)/lib ;

#### copy over the data files
distrib.data:	distrib.dir
	$(ECHO) "Copying distribution files from 'data' ..." ; \
	$(CD) $(DATADIR) ; \
	$(COPY) $(DATA_FILES) $(DISTRIBDIR)/data

#### copy over the documentation files
distrib.doc:	distrib.dir
	$(ECHO) "Copying distribution files from 'doc' ..." ; \
	$(CD) $(DOCDIR) ; \
	$(COPY) ig.ps $(DISTRIBDIR)/doc ; \

###  used to be:  $(COPY) ig.ps pg.ps ug.ps $(DISTRIBDIR)/doc ; \

#### copy over the protein files
distrib.proteins:	distrib.dir
	$(ECHO) "Copying distribution files from 'proteins' ..." ; \
	$(COPY) $(DISTRIBPROTEINS) $(DISTRIBDIR)/proteins

#### create a tar file in the lib directory
distrib.lib.tar:
	$(ECHO) "Creating lib tar file ..." ; \
	$(CD) $(VMDLIBDIR) ; \
	if [ -f libtar.tar ] ; then $(DELETE) libtar.tar; fi ; \
	$(TAR) cf libtar.tar $(DISTRIBLIBS)

#### copy the tar file over to the distrib lib file, and untar it
distrib.lib:	distrib.dir distrib.lib.tar
	$(ECHO) "Copying distribution files from 'lib' ..." ; \
	$(MOVE) $(VMDLIBDIR)/libtar.tar $(DISTRIBDIR)/lib ; \
	$(CD) $(DISTRIBDIR)/lib ; \
	$(TAR) xf libtar.tar ; \
	$(DELETE) libtar.tar

#### copy over the source files, removing the revision history text
distrib.src:	distrib.dir
	$(ECHO) "Copying distribution files from 'src' ..." ; \
	$(CD) $(SRCDIR) ; \
	$(COPY) Makefile Makedata.depend $(DISTRIBDIR)/src ; \
	for i in `ls -1 *.C *.c *.h *.y *.l *.fd` ; do \
	  cat $$i | awk '{ while(1>0) { \
				if($$1!="/*" || $$2!="REVISION") { \
					print \
				} else { \
					break \
				} \
				if(getline < 1) { \
					break \
				} \
			   } \
			   exit \
			 }' > $(DISTRIBDIR)/src/$$i ; \
	done

#### copy over the vmd executable
distrib.exe:		distrib.dir
	$(ECHO) "Copying executable(s) to distribution directory ..." ; \
	$(CD) $(SRCDIR) ; \
	$(COPY) $(PROGNAME) $(DISTRIBDIR)/src ; \
	$(COPY) $(SURFDIR)/$(SURF_EXE) $(DISTRIBDIR)/lib ; \
	$(COPY) $(OTHER_EXE) $(DISTRIBDIR)/lib

#### create the configure.parameters file for distribution
distrib.conf.par:	distrib.dir
	$(ECHO) "Creating distribution configure.parameters ..." ; \
	cat ../configure | awk '{ if($$NF=="***STARTPARAMS***") { \
		  		 getline ; while($$NF!="***ENDPARAMS***") { \
					print ; getline \
		  		 } \
				} \
			}' > $(DISTRIBDIR)/configure.parameters

#### copy over the main files
distrib.top:	distrib.conf.par
	$(ECHO) "Copying top-level distribution files ..." ; \
	$(CD) .. ; \
	$(COPY) $(MAIN_DIR_FILES) configure.options src/$(DISTRIBDIR)/.

#### the main copying driver
distrib.copy:	distrib.bin distrib.data distrib.proteins distrib.lib \
			distrib.scripts distrib.src distrib.exe \
			distrib.doc distrib.top
	chmod -R u+w $(DISTRIBDIR)/. ; \
	chmod -R go-w $(DISTRIBDIR)/.

#### compress the distribution once is has been produced
distrib.compress:	distrib.copy
	$(CD) ../distrib ; \
	$(ECHO) "Creating and compressing $(BASEDISTRIBALLFILE).gz ..."; \
	if [ -f $(BASEDISTRIBALLFILE).gz ]; then \
	  $(MOVE) $(BASEDISTRIBALLFILE).gz $(BASEDISTRIBALLFILE).gz.old; \
	fi ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
	  $(GNUCOMPRESS) > $(BASEDISTRIBALLFILE).gz ; \
	$(ECHO) "Creating and compressing $(BASEDISTRIBALLFILE).Z ..."; \
	if [ -f $(BASEDISTRIBALLFILE).Z ]; then \
	  $(MOVE) $(BASEDISTRIBALLFILE).Z $(BASEDISTRIBALLFILE).Z.old; \
	fi ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
	  $(COMPRESS) > $(BASEDISTRIBALLFILE).Z ; \
	$(ECHO) "Removing extra files to create $(BASEDISTRIBBINFILE) ..." ; \
	$(CD) $(BASEDISTRIBFILE)/src ; \
	$(DELETE) *.C *.c *.h *.y *.l *.fd ; \
	$(CD) ../lib ; \
	$(DELETEDIR) $(DISTRIBLIBSEXTRA) ; \
	$(CD) ../.. ; \
	$(ECHO) "Creating and compressing $(BASEDISTRIBBINFILE).gz ..."; \
	if [ -f $(BASEDISTRIBBINFILE).gz ]; then \
	  $(MOVE) $(BASEDISTRIBBINFILE).gz $(BASEDISTRIBBINFILE).gz.old; \
	fi ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
	  $(GNUCOMPRESS) > $(BASEDISTRIBBINFILE).gz ; \
	$(ECHO) "Creating and compressing $(BASEDISTRIBBINFILE).Z ..."; \
	if [ -f $(BASEDISTRIBBINFILE).Z ]; then \
	  $(MOVE) $(BASEDISTRIBBINFILE).Z $(BASEDISTRIBBINFILE).Z.old; \
	fi ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
	  $(COMPRESS) > $(BASEDISTRIBBINFILE).Z

#### the main distribution creation target ... starts the whole chain ...
dist distribution distrib:	distrib.compress
	$(ECHO) "Deleting temporary distribution directory ..."; \
	#$(DELETEDIR) $(DISTRIBDIR)

#### put distrib file out for anon ftp
justftp ftp:
	$(ECHO) "Copying distribution to the FTP directory ..."; \
	$(CD) .. ; \
	$(COPY) README ChangeLog FEEDBACK $(FTPDIR) ; \
	$(CD) distrib ; \
	$(COPY) $(BASEDISTRIBALLFILE).gz $(BASEDISTRIBBINFILE).gz $(FTPDIR); \
	$(COPY) $(BASEDISTRIBALLFILE).Z  $(BASEDISTRIBBINFILE).Z  $(FTPDIR); \
	$(CD) $(FTPDIR) ; \
	chmod u+w README FEEDBACK ChangeLog ; \
	if [ -h $(LINKDISTRIBALLFILE).gz ]; then \
	  $(DELETE) $(LINKDISTRIBALLFILE).gz; \
	fi; \
	if [ -h $(LINKDISTRIBALLFILE).Z ]; then \
	  $(DELETE) $(LINKDISTRIBALLFILE).Z; \
	fi; \
	if [ -h $(LINKDISTRIBBINFILE).gz ]; then \
	  $(DELETE) $(LINKDISTRIBBINFILE).gz; \
	fi; \
	if [ -h $(LINKDISTRIBBINFILE).Z ]; then \
	  $(DELETE) $(LINKDISTRIBBINFILE).Z; \
	fi; \
	ln -s $(BASEDISTRIBALLFILE).gz $(LINKDISTRIBALLFILE).gz ; \
	ln -s $(BASEDISTRIBALLFILE).Z  $(LINKDISTRIBALLFILE).Z  ; \
	ln -s $(BASEDISTRIBBINFILE).gz $(LINKDISTRIBBINFILE).gz ; \
	ln -s $(BASEDISTRIBBINFILE).Z  $(LINKDISTRIBBINFILE).Z ; \
	chgrp -R vmd . ; \
	chmod -R g+w .

#### the whole show, do the distribution and put on ftp
ftpall: distrib justftp


###############################
### RCS checkout targets:
###############################

co.main:
	$(ECHO) "Checking out main directory files ..." ; \
	$(CD) $(MAINDIR); \
	$(COCMD) $(MAIN_DIR_FILES)

co.data:
	$(ECHO) "Checking out data files ..." ; \
	$(CD) $(DATADIR); \
	$(COCMD) $(DATA_FILES)

co.bin:
	$(ECHO) "Checking out scripts and utility files ..." ; \
	$(CD) $(BINDIR); \
	$(COCMD) $(BIN_FILES) $(SCRIPT_FILES)

co.doc:
	$(ECHO) "Checking out all documentation files ..." ; \
	$(CD) $(DOCDIR); \
	$(COCMD) $(DOC_FILES)

co.doc.ig:
	$(ECHO) "Checking out installation guide documentation files ..." ; \
	$(CD) $(DOCDIR); \
	$(COCMD) $(ALL_INST_FILES) $(ALL_MAIN_FILES) $(DOC_STYLE_FILES)

co.doc.pg:
	$(ECHO) "Checking out programmers guide documentation files ..." ; \
	$(CD) $(DOCDIR); \
	$(COCMD) $(ALL_PROG_FILES) $(ALL_MAIN_FILES) $(DOC_STYLE_FILES)

co.doc.ug:
	$(ECHO) "Checking out users guide documentation files ..." ; \
	$(CD) $(DOCDIR); \
	$(COCMD) $(ALL_USER_FILES) $(ALL_MAIN_FILES) $(DOC_STYLE_FILES)

co.src:
	$(ECHO) "Checking out source files ..."; \
	$(CD) $(SRCDIR); \
	$(COCMD) $(ALL_SRCS)

co.h co.include co.header:
	$(ECHO) "Checking out include files ..."; \
	$(CD) $(SRCDIR); \
	$(COCMD) $(ALL_H)

co.extra:
	$(ECHO) "Checking out all other needed files ..." ; \
	if [ "$(EXTRA_FILES)" != "" ]; then \
	  $(CD) $(SRCDIR); \
	  $(COCMD) $(EXTRA_FILES); \
	fi

co:	co.src co.h co.doc co.data co.bin co.extra co.main
	make depend

locks:
	$(ECHO) "Currently locked RCS files: " ; \
	$(CD) $(SRCDIR)/RCS; \
	if [ "`rlog -L -R *,v`" != "" ]; then \
	  ls -alF `rlog -L -R *,v`; \
	fi

###############################
# other useful make commands
###############################

### make Tcl autoloading index file
tclindex:
	echo 'auto_mkindex . *.tcl' | tcl

### reconfigure, based on latest options
configure config conf:
	$(ECHO) "Reconfiguring ..." ;\
	$(CD) .. ;\
	configure

### cleanup target

clean:
	$(DELETE) *.o *.i *.a *.bak *.depend.old *~ core

### dependencies files targets

# save the current dependencies list to rcs
savedepend:
	if [ -f $(DEPENDFILE) ]; then \
	  $(ECHO) "Saving current dependencies file ..."; \
	  $(COLOCKCMD) $(DEPENDFILE).rcs; \
	  $(COPY) $(DEPENDFILE) $(DEPENDFILE).rcs; \
	  $(CICMD) $(DEPENDFILE).rcs; \
	else \
	  $(ECHO) "No current dependencies file $(DEPENDFILE) found.";\
	fi

### automatic file checkout rules

$(ALL_SRCS) $(ALL_H) $(EXTRA_FILES):
	@if [ ! -f $(SRCDIR)/$@ ]; then \
	  $(ECHO) "  Retrieving $@ from RCS directory ..." ; \
	  $(CD) $(SRCDIR) ; \
	  $(COCMD) $@ ; \
	fi

$(DATA_FILES):
	@if [ ! -f $(DATADIR)/$@ ]; then \
	  $(ECHO) "  Retrieving $@ from RCS directory ..." ; \
	  $(CD) $(DATADIR) ; \
	  $(COCMD) $@ ; \
	fi

$(SCRIPT_FILES):
	@if [ ! -f $(BINDIR)/$@ ]; then \
	  $(ECHO) "  Retrieving $@ from RCS directory ..." ; \
	  $(CD) $(BINDIR) ; \
	  $(COCMD) $@ ;\
	fi

$(DOC_FILES):
	@if [ ! -f $(DOCDIR)/$@ ]; then \
	  $(ECHO) "  Retrieving $@ from RCS directory ..." ; \
	  $(CD) $(DOCDIR) ; \
	  $(COCMD) $@ ;\
	fi

config.h vmd_version.tex:
	true

###########################
# write out rules to create dependencies
# create dependencies file ... does not work on all architectures
# also, the yacc/lex dependencies must be done by hand
###########################
depend: $(SRCDIR)/y.tab.h version
	if [ "$(ARCH_DEP_FLAG)" != "" ]; then \
	  $(ECHO) "Creating " $(DEPENDFILE) " ..."; \
	  if [ -f $(DEPENDFILE) ]; then \
	    $(MOVE) -f $(DEPENDFILE) $(DEPENDFILE).old; \
	  fi; \
	  touch $(DEPENDFILE); \
	  for i in ZZZ $(ALL_CCPP_SRCS) ; do \
	    if [ "$$i" != "ZZZ" -a -f $(SRCDIR)/$$i ]; then \
	      $(ECHO) "checking dependencies for $$i ..."; \
	      $(CCPP) $(ARCH_DEP_FLAG) $(INCDIRS) \
		$(OPTIONSDEFS) $(ARCH_CPPOPTS) -DARCH_$(ARCH) $(SRCDIR)/$$i \
			| grep -v "/usr/include" >> $(DEPENDFILE); \
	    fi; \
	  done; \
	  for i in ZZZ $(ALL_CC_SRCS) ; do \
	    if [ "$$i" != "ZZZ" -a -f $(SRCDIR)/$$i ]; then \
	      $(ECHO) "checking dependencies for $$i ..."; \
	      $(CC) $(ARCH_DEP_FLAG) $(INCDIRS) \
		$(OPTIONSDEFS) $(ARCH_COPTS) -DARCH_$(ARCH) $(SRCDIR)/$$i \
			| grep -v "/usr/include" >> $(DEPENDFILE); \
	    fi; \
	  done; \
	  $(ECHO) "ParseTree.o AtomLexer.o AtomParser.o: $(SRCDIR)/y.tab.h" \
		>> $(DEPENDFILE); \
	else \
	  $(ECHO) "Cannot find dependencies; your compiler does not support dependency checking."; \
	fi

###########################
# includes dependencies
###########################
include $(DEPENDFILE)

MAKERULESTXT
#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


###########################
# finish up
###########################
# since we're here, the configuration was successful
###########################

# put new makefile in src and doc dir
echo "Copying new makefile to $myarch and doc dir ..."
cp $mkfile $myarch/Makefile
cp $mkfile doc/Makefile
cp $mkfile src/Makefile
touch $myarch/Makedata.depend
rm -f $mkfile

# put a copy of the configure script in these dirs for convenience
echo "Saving configuration options ..."
echo $myarch $myoptions > configure.options

# now go to the src dir and make afresh
if [ $opt_remake = true ]; then
  echo "Remaking $programname in directory $myarch ..."
  cd $myarch
  make clean
  make co
  make
fi

exit 0
