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

############################################################################
# DESCRIPTION:
#
# 			main Makefile, generated by configure
#		
############################################################################

# machine to compile for, program name, and version
ARCH			= IRIX5
OPTIMIZEFLAG		= -O
INSTALLNAME		= vmd
INSTALLLIBDIR		= /usr/local/lib/vmd
INSTALLBINDIR		= /usr/local/bin
INSTALLFTPDIR		= /Net/lisboa/usr/ftp/pub/mdscope/vmd
DEFDISPLAY		= WIN
DEFTITLE		= ON
DEFHEIGHT		= 6.0
DEFDIST			= -2.0
INITFILENAME		= .vmd_init
MAXSTRINGLEN		= 6
PROGNAME		= vmd_IRIX5
PROGVERSION		= 0.96
PROMPTSTRING		= "vmd > "
STARTUPFILENAME		= .vmdrc
AUTHORS			= "William Humphrey and Andrew Dalke"

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

# makefile configuration
SHELL 			= /bin/sh
.SILENT:

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

# where to put the object files
OBJDIR			= objfiles/$(ARCH)

# 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
VMDLIBDIR		= ../lib
DATADIR			= ../data
BINDIR			= ../bin
DOCDIR			= ../doc
PROTEINSDIR		= ../proteins
BASEDISTRIBDIR		= ../distrib
BASEDISTRIBFILE		= $(INSTALLNAME)-$(PROGVERSION)
DISTRIBDIR		= $(BASEDISTRIBDIR)/$(BASEDISTRIBFILE)

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

# dirs for extra includes (except for OPTIONS, must have -I appended in front)
INCDIRS	= -I. $(OPTIONSINCDIRS) 

# dir for extra libs (except for OPTIONS, must have -l & -L appended in front)
LIBDIRS	= -L. $(OPTIONSLIBDIRS)
LIBS	= -lm $(OPTIONSLIBS)

# compiler and linker options
CFLAGS		= $(ARCH_COPTS)	$(OPTIMIZEFLAG) $(INCDIRS) \
			-DARCH_$(ARCH)	$(OPTIONSDEFS)
CPPFLAGS	= $(ARCH_CPPOPTS)	$(OPTIMIZEFLAG) $(INCDIRS) \
			-DARCH_$(ARCH)	$(OPTIONSDEFS)
LFLAGS		= $(LIBDIRS) 	$(LIBS)	$(ARCH_LOPTS)

#################################################################
# architecture-specific declarations:
#################################################################
# definitions for IRIX5 architecture
#####
# specific names of programs used in make commands
#####
CCPP		= CC
CC		= cc
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
#####
ARCH_COPTS	=
ARCH_CPPOPTS	= +e1
ARCH_LOPTS      = -lc_s -lsphere -lfm_s -lgl_s -lm -lmalloc

#################################################################
# optional components
#################################################################
# options included:  FORMS REMOTE CAVE UNC EXTERNAL OPTIMIZE

#######################
# OPTIONAL COMPONENT: GUI library to use.
#	Exactly one version of the following sets of items must be uncommented.
#	This specifies the libraries used for the on-screen GUI with buttons,
#	menus, etc.
#######################

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


#######################
# 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
REMOTELIBDIR		= -L$(REMOTEDIR)/lib_$(ARCH)
REMOTELIB		= -lmdcomm
REMOTE_CCPP		= \
				CmdRemote.C \
				MoleculeRemote.C \
				Remote.C \
				RemoteList.C
REMOTE_CC		=
REMOTE_H		= \
				CmdRemote.h \
				MoleculeRemote.h \
				Remote.h \
				RemoteList.h
REMOTE_EXTRA		=
REMOTE_OBJS		= $(REMOTE_CCPP:.C=.o)	$(REMOTE_CC:.c=.o)


#######################
# 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)
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)

# cave library to use
CAVELIB			= -lcave

#######################
# 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)


#######################
# OPTIONAL COMPONENT: External interface
#	This may be commented out if not required.
#	This allows other programs to communicate with vmd via a PVM
#	message.  Currently this is experimental and is not included
#	by default
#######################

EXTERNALDEF		= -DVMDEXTERNAL
EXTERNALDIR		= $(HOME)/pvm3/
EXTERNALINCDIR		= -I$(EXTERNALDIR)/include
EXTERNALARCH            = `$(HOME)/pvm3/lib/pvmgetarch`
EXTERNALLIBDIR		= -L$(EXTERNALDIR)/lib/$(EXTERNALARCH)
EXTERNALLIB		= -lpvm3 -lgpvm3
EXTERNAL_CCPP		= \
				CmdExternal.C \
				UIExternal.C
EXTERNAL_CC		=
EXTERNAL_H		= \
				CmdExternal.h \
				UIExternal.h

EXTERNAL_EXTRA		=
EXTERNAL_OBJS		= $(EXTERNAL_CCPP:.C=.o)	$(EXTERNAL_CC:.c=.o)


OPTIONSDEFS	= $(GUIDEF)	$(REMOTEDEF)	$(UNCDEF)	$(CAVEDEF) \
			$(EXTERNALDEF)	$(DEBUGDEF)
OPTIONSINCDIRS	= $(GUIINCDIR)	$(REMOTEINCDIR)	$(UNCINCDIR)	$(CAVEINCDIR)\
			$(EXTERNALINCDIR)
OPTIONSLIBDIRS	= $(GUILIBDIR)	$(REMOTELIBDIR)	$(UNCLIBDIR)	$(CAVELIBDIR)\
			$(EXTERNALLIBDIR)
OPTIONSLIBS	= $(GUILIB)	$(REMOTELIB)	$(UNCLIB)	$(CAVELIB)\
			$(EXTERNALLIB)
OPTIONS_CCPP	= $(GUI_CCPP)	$(REMOTE_CCPP)	$(UNC_CCPP)	$(CAVE_CCPP)\
			$(EXTERNAL_CCPP)
OPTIONS_CC	= $(GUI_CC)	$(REMOTE_CC)	$(UNC_CC)	$(CAVE_CC)\
			$(EXTERNAL_CC)
OPTIONS_H	= $(GUI_H)	$(REMOTE_H)	$(UNC_H)	$(CAVE_H)\
			$(EXTERNAL_H)
OPTIONS_EXTRA	= $(GUI_EXTRA)	$(REMOTE_EXTRA)	$(UNC_EXTRA)	$(CAVE_EXTRA)\
			$(EXTERNAL_EXTRA)
OPTIONS_OBJS	= $(GUI_OBJS)	$(REMOTE_OBJS)	$(UNC_OBJS)	$(CAVE_OBJS)\
			$(EXTERNAL_OBJS)

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


# VMD source files
VMD_CCPP	= \
		Animation.C \
		AtomColor.C \
		AtomRep.C \
		AtomSel.C \
		Axes.C \
		BaseMolecule.C \
		Buttons.C \
		CmdAnimate.C \
		CmdColor.C \
		CmdDisplay.C \
		CmdLabel.C \
		CmdMol.C \
		CmdPick.C \
		CmdRender.C \
		CmdTool.C \
		CmdTracker.C \
		CmdTrans.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 \
		DrawPatch.C \
		Enterprise.C \
		Geometry.C \
		GeometryAngle.C \
		GeometryAtom.C \
		GeometryBond.C \
		GeometryDihedral.C \
		GeometryList.C \
		GeometryMol.C \
		Global.C \
		GrabTool.C \
		Inform.C \
		Light.C \
		LightList.C \
		Matrix4.C \
		MolAction.C \
		Molecule.C \
		MoleculeList.C \
		MoleculeFile.C \
		MoleculeFileEDM.C \
		MoleculeFileGraph.C \
		MoleculeFilePDB.C \
		MoleculeFilePSF.C \
		MoleculeFileRaster3D.C \
		Mouse.C \
		NormalScene.C \
		PickList.C \
		PickMode.C \
		PickModeMolLabel.C \
		PickModeQuery.C \
		Pickable.C \
		PointerTool.C \
		ReadDCD.C \
		ReadEDM.C \
		ReadPDB.C \
		ReadPSF.C \
		Scene.C \
		Stage.C \
		Timer.C \
		Timestep.C \
		Tokenize.C \
		Tool.C \
		ToolControl.C \
		Tracker.C \
		TrackerList.C \
		UIList.C \
		UIObject.C \
		UIText.C \
		UIText2.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 \
		Atom.h \
		AtomColor.h \
		AtomRep.h \
		AtomSel.h \
		Axes.h \
		BaseMolecule.h \
		Buttons.h \
		CmdAnimate.h \
		CmdColor.h \
		CmdDisplay.h \
		CmdLabel.h \
		CmdMol.h \
		CmdPick.h \
		CmdRender.h \
		CmdTool.h \
		CmdTracker.h \
		CmdTrans.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 \
		DrawPatch.h \
		Enterprise.h \
		Fragment.h \
		GeometryAngle.h \
		GeometryAtom.h \
		GeometryBond.h \
		GeometryDihedral.h \
		GeometryList.h \
		GeometryMol.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 \
		MoleculeFileGraph.h \
		MoleculeFilePDB.h \
		MoleculeFilePSF.h \
		MoleculeFileRaster3D.h \
		MoleculeList.h \
		Mouse.h \
		NameList.h		NameList.c \
		NormalScene.h \
		PickList.h \
		PickMode.h \
		PickModeQuery.h \
		Pickable.h \
		PointerTool.h \
		ResizeArray.h		ResizeArray.c \
		ReadDCD.h \
		ReadEDM.h \
		ReadPDB.h \
		ReadPSF.h \
		Residue.h \
		Scene.h \
		Stack.h 		Stack.c \
		Stage.h \
		Timer.h \
		Timestep.h \
		Tokenize.h \
		Tool.h \
		ToolControl.h \
		Tracker.h \
		TrackerList.h \
		Tree.h \
		UIList.h \
		UIObject.h \
		UIText.h \
		UIVR.h \
		VButton.h \
		VMDTitle.h \
		VRegion.h \
		VRegionList.h \
		startup.h \
		utilities.h

# summary of the above files
VMD_SRCS	= $(VMD_CCPP)		$(VMD_CC)
VMD_OBJS	= $(VMD_CCPP:.C=.o)	$(VMD_CC:.c=.o)

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

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

# VMD 'extra' files
VMD_EXTRA	=

###############################
# all components ... includes optional files, defined in Makedata.options
###############################
ALL_CCPP_SRCS	= $(VMD_CCPP)		$(OPTIONS_CCPP)
ALL_CC_SRCS	= $(VMD_CC)		$(OPTIONS_CC)
ALL_SRCS	= $(ALL_CCPP_SRCS)	$(ALL_CC_SRCS)
ALL_H		= $(VMD_H)		$(OPTIONS_H)
ALL_OBJS	= $(VMD_OBJS)		$(OPTIONS_OBJS)
EXTRA_FILES	= $(VMD_EXTRA)		$(OPTIONS_EXTRA)
DATA_FILES	= $(VMD_DATA)
BIN_FILES	=
SCRIPT_FILES	= $(INSTALLNAME)

# main directory utility files, such as this configure script and README
MAIN_DIR_FILES	= \
		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_chapters.tex \
		ug_intro.tex \
		ug_macros.tex \
		quickstart.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 \
		Timer.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)

############################### 
# default rules 
###############################

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

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

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

all default:	$(PROGNAME)

#### executables

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

#### 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 VERSION_MSG \"$(INSTALLNAME) for $(ARCH), version $(PROGVERSION) \(`date`\)\" >> config.h ; \
	$(ECHO) \#define CMDLEN $(MAXSTRINGLEN) >> config.h ; \
	$(ECHO) \#define VMDENVVAR \"VMDDIR\" >> config.h ; \
	$(ECHO) \#define DEF_VMDENVVAR \"$(INSTALLLIBDIR)\" >> config.h ; \
	$(ECHO) \#define VMD_INITFILE  \"$(INITFILENAME)\" >> config.h ; \
	$(ECHO) \#define VMD_STARTUP   \"$(STARTUPFILENAME)\" >> config.h ; \
	$(ECHO) \#define VMD_CMD_PROMPT \"$(PROMPTSTRING)\" >> 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) \#endif >> config.h

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`\} >> 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.exe install.doc

# install program and data files in proper directory
install install.exe:
	$(ECHO) "Installing executables and data files in $(INSTALLLIBDIR)"; \
	if [ ! -d $(INSTALLLIBDIR) ]; then mkdir $(INSTALLLIBDIR); fi; \
	$(CD) $(SRCDIR); \
	  $(COPY) $(PROGNAME)   $(INSTALLLIBDIR) ; \
	  chmod u+w $(INSTALLLIBDIR)/$(PROGNAME)  ; \
	$(CD) $(DATADIR); \
	  $(COPY) .tracker $(INSTALLLIBDIR) ; \
	  chmod u+w $(INSTALLLIBDIR)/.tracker  ; \
	  $(COPY) .vmd_init $(INSTALLLIBDIR)/$(INITFILENAME) ; \
	  chmod u+w $(INSTALLLIBDIR)/$(INITFILENAME)  ; \
	  $(COPY) .vmdrc $(INSTALLLIBDIR)/$(STARTUPFILENAME) ; \
	  chmod u+w $(INSTALLLIBDIR)/$(STARTUPFILENAME)  ; \
	$(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 ; \
	cat $(VMD_BIN) >> run_vmd_tmp ; \
	chmod +x run_vmd_tmp ; \
	$(COPY) run_vmd_tmp $(INSTALLBINDIR)/$(INSTALLNAME) ; \
	$(DELETE) run_vmd_tmp ; \
	if [ "$(REMOTEDEF)" != "" ]; then \
	  $(ECHO) "Installing mdcomm files"; \
	  if [ ! -d $(INSTALLLIBDIR)/mdcomm ]; then \
	    mkdir $(INSTALLLIBDIR)/mdcomm ; \
	  fi ; \
	  $(COPY) $(VMDLIBDIR)/mdcomm/lib_$(ARCH)/md_consumer \
	  	$(INSTALLLIBDIR)/mdcomm/md_consumer_$(ARCH) ; \
	  $(COPY) $(VMDLIBDIR)/mdcomm/lib_$(ARCH)/chemd \
	  	$(INSTALLLIBDIR)/mdcomm/chemd_$(ARCH) ; \
	fi

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

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

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

#### copy the files necessary for the distribution into a temporary dir
distrib.copy:	distrib.dir
	$(ECHO) "Copying files ..." ; \
	$(CD) .. ; \
	$(TAR) cf - RCS/. READ* config* bin/. data/. doc/. lib/. \
		proteins/. src/. | (cd distrib/$(DISTRIBDIR); $(TAR) xvf -); \
	$(DELETE) distrib/$(DISTRIBDIR)/src/*.o ; \
	strip distrib/$(DISTRIBDIR)/src/$(PROGNAME) ; \
	if [ -d distrib/$(DISTRIBDIR)/src/ptrepository ]; then \
	  $(DELETEDIR) distrib/$(DISTRIBDIR)/src/ptrepository; \
	fi ; \
	$(DELETE) distrib/$(DISTRIBDIR)/doc/pictures ; \
	$(MAKEDIR) distrib/$(DISTRIBDIR)/doc/pictures ; \
	$(COPY) doc/pictures/*.eps doc/pictures/*.ps \
		distrib/$(DISTRIBDIR)/doc/pictures

#### 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

#### compress the distribution once is has been produced
distrib.compress:	distrib.dir
	$(ECHO) "  Creating and compressing $(BASEDISTRIBFILE).tar ..."; \
	$(CD) ../distrib ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
		$(GNUCOMPRESS) > $(BASEDISTRIBFILE).tar.gz ; \
	$(TAR) cf - $(BASEDISTRIBFILE) | \
		$(COMPRESS) > $(BASEDISTRIBFILE).tar.Z

#### create the distribution .tar.Z file completely
distrib:
	make distrib.copy ; \
	make distrib.conf.par ; \
	make distrib.compress ; \
	$(DELETEDIR) $(DISTRIBDIR)

#### put distrib file out for anon ftp
ftp:
	$(ECHO) "Copying distribution to the FTP directory ..."; \
	$(CD) .. ; \
	$(COPY) README $(FTPDIR) ; \
	$(COPY) distrib/$(BASEDISTRIBFILE).tar.* $(FTPDIR) ; \
	$(CD) $(FTPDIR) ; \
	if [ -h $(INSTALLNAME).tar.Z ]; then \
	  $(DELETE) $(INSTALLNAME).tar.Z; \
	fi; \
	ln -s $(BASEDISTRIBFILE).tar.Z $(INSTALLNAME).tar.Z ; \
	if [ -h $(INSTALLNAME).tar.gz ]; then \
	  $(DELETE) $(INSTALLNAME).tar.gz; \
	fi; \
	ln -s $(BASEDISTRIBFILE).tar.gz $(INSTALLNAME).tar.gz

###############################
### 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) RCS; \
	if [ "`rlog -L -R *,v`" != "" ]; then \
	  ls -alF `rlog -L -R *,v`; \
	fi

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

### reconfigure, based on latest options
configure:
	$(ECHO) "Reconfiguring, using last configuration options ..." ;\
	$(CD) .. ;\
	$(COCMD) configure ;\
	configure

### cleanup target

clean:
	$(DELETE) *.o *.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

# create dependencies file ... does not work on all architectures
depend: version
	echo "Creating " $(DEPENDFILE) " ..."; \
	if [ -f $(DEPENDFILE) ]; \
	  then $(MOVE) -f $(DEPENDFILE) $(DEPENDFILE).old; \
	fi; \
	touch $(DEPENDFILE); \
	if [ "$(ALL_CCPP_SRCS) " != " " ]; \
	  then $(CCPP) -M $(INCDIRS) -DARCH_$(ARCH) $(OPTIONSDEFS) \
	  	$(ALL_CCPP_SRCS) $(ALL_CC_SRCS) \
	    		| grep -v "/usr/include" >> $(DEPENDFILE); \
	fi

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

