###########################################################################
#                             RasMol 2.7.3.1                              #
#                                                                         #
#                                 RasMol                                  #
#                 Molecular Graphics Visualisation Tool                   #
#                              14 April 2006                              #
#                                                                         #
#                   Based on RasMol 2.6 by Roger Sayle                    #
# Biomolecular Structures Group, Glaxo Wellcome Research & Development,   #
#                      Stevenage, Hertfordshire, UK                       #
#         Version 2.6, August 1995, Version 2.6.4, December 1998          #
#                   Copyright (C) Roger Sayle 1992-1999                   #
#                                                                         #
#                          and Based on Mods by                           #
#Author             Version, Date             Copyright                   #
#Arne Mueller       RasMol 2.6x1   May 98     (C) Arne Mueller 1998       #
#Gary Grossman and  RasMol 2.5-ucb Nov 95     (C) UC Regents/ModularCHEM  #
#Marco Molinaro     RasMol 2.6-ucb Nov 96         Consortium 1995, 1996   #
#                                                                         #
#Philippe Valadon   RasTop 1.3     Aug 00     (C) Philippe Valadon 2000   #
#                                                                         #
#Herbert J.         RasMol 2.7.0   Mar 99     (C) Herbert J. Bernstein    # 
#Bernstein          RasMol 2.7.1   Jun 99         1998-2001               #
#                   RasMol 2.7.1.1 Jan 01                                 #
#                   RasMol 2.7.2   Aug 00                                 #
#                   RasMol 2.7.2.1 Apr 01                                 #
#                   RasMol 2.7.2.1.1 Jan 04                               #
#                   RasMol 2.7.3   Feb 05                                 #
#                   RasMol 2.7.3.1 Apr 06                                 #
#                                                                         #
#                    and Incorporating Translations by                    #
#  Author                               Item                     Language #
#  Isabel Serván Martínez,                                                #
#  José Miguel Fernández Fernández      2.6   Manual              Spanish #
#  José Miguel Fernández Fernández      2.7.1 Manual              Spanish #
#  Fernando Gabriel Ranea               2.7.1 menus and messages  Spanish #
#  Jean-Pierre Demailly                 2.7.1 menus and messages  French  #
#  Giuseppe Martini, Giovanni Paolella, 2.7.1 menus and messages          #
#  A. Davassi, M. Masullo, C. Liotto    2.7.1 help file           Italian #
#                                                                         #
#                             This Release by                             #
# Herbert J. Bernstein, Bernstein + Sons, P.O. Box 177, Bellport, NY, USA #
#                       yaya@bernstein-plus-sons.com                      #
#               Copyright(C) Herbert J. Bernstein 1998-2001               #
#                                                                         #
# Please read the file NOTICE for important notices which apply to this   #
# package. If you are not going to make changes to RasMol, you are not    # 
# only permitted to freely make copies and distribute them, you are       # 
# encouraged to do so, provided you do the following:                     #
#   * 1. Either include the complete documentation, especially the file   #
#     NOTICE, with what you distribute or provide a clear indication      #
#     where people can get a copy of the documentation; and               #
#   * 2. Please give credit where credit is due citing the version and    # 
#     original authors properly; and                                      #  
#   * 3. Please do not give anyone the impression that the original       #   
#     authors are providing a warranty of any kind.                       #
#                                                                         #
# If you would like to use major pieces of RasMol in some other program,  #
# make modifications to RasMol, or in some other way make what a lawyer   #
# would call a "derived work", you are not only permitted to do so, you   #
# are encouraged to do so. In addition to the things we discussed above,  #
# please do the following:                                                #
#   * 4. Please explain in your documentation how what you did differs    #
#     from this version of RasMol; and                                    #
#   * 5. Please make your modified source code available.                 #
#                                                                         #
# This version of RasMol is not in the public domain, but it is given     #
# freely to the community in the hopes of advancing science. If you make  #
# changes, please make them in a responsible manner, and please offer us  #
# the opportunity to include those changes in future versions of RasMol.  #
###########################################################################
#
# Makefile.in
# RasMol2 Molecular Graphics
# Roger Sayle, March 1995
# Version 2.6.4
# Roger Sayle, December 1998
#
# Version 2.6.9
# Herbert J. Bernstein, March 1999
# yaya at bernstein-plus-sons dot com
#
# Version 2.7.3.1
# Herbert J. Bernstein, Septemmber 2006
# yaya at bernstein-plus-sons dot com

# Simply edit CC and CFLAGS for your local compiler/system
# For Sun OpenWindows, add "-I/usr/openwin/include" to CFLAGS

CC = gcc
CFLAGS = -g -O2 -finline-functions -D_USE_RASMOL_H_ -I$(CBFLIBDIR)/include


#CFLAGS_sun4     = -O4 -I$(CBFLIBDIR)/include
#CFLAGS_sun3     = -O4 -f68881 -I$(CBFLIBDIR)/include
#CFLAGS_hp9000   = -O +bfpa -I$(CBFLIBDIR)/include
#CFLAGS_sequent  = -O -f1167 -I$(CBFLIBDIR)/include
#CFLAGS_mips     = -O2 -Olimit 800 -I$(CBFLIBDIR)/include
#CFLAGS_gcc2.0   = -O2 -funroll-all-loops -I$(CBFLIBDIR)/include
#CFLAGS_esv      = -O2 -Olimit 800 -systype bsd43 -I$(CBFLIBDIR)/include
#CFLAGS_hpux9    = -Ae +O2 +Onolimit -I$(CBFLIBDIR)/include
#CFLAGS_hpux9new = -Ae +O4 +Onolimit +Oconservative +ESlit -I/usr/include/X11R5 -I$(CBFLIBDIR)/include
#CFLAGS_sgi      = -O2 -xansi -DFUNCPROTO -I$(CBFLIBDIR)/include
#CFLAGS_gcc      = -O -fomit-frame-pointer -fstrength-reduce -finline-functions -I$(CBFLIBDIR)/include

# For Debugging use LFLAGS = 
LFLAGS = -s

# -lXi required if using DIALBOX
EXTLIBS = -lm -lXi -lXext -lX11

# Library path required for HPUX
# LIBS = -lm -L/usr/lib/X11R5 -lXext -lX11
# -lXextSam required by MITSHM on RS600 AIX
# LIBS = -lm -lXextSam -lXext -lX11

# -lmmioc required for MMIO
# -L. -lXext -lX11 -lmmioc -lm

# On SUN Solaris systems when compiling RasMol with the SOCKETS option
# LIBS = -lm -lsocket -lnsl 

# Normal Libraries
LIBS = -lm
X11LIBS =  -lXext -lX11 $(LIBS)

INCS = abstree.h cmndline.h command.h font.h graphics.h infile.h \
       molecule.h outfile.h pixutils.h rasmol.h render.h repres.h \
       script.h tokens.h transfor.h cif.h cif_ctonum.h \
       multiple.h vector.h wbrotate.h

SRCS = abstree.c cmndline.c command.c infile.c molecule.c outfile.c \
       pixutils.c render.c repres.c script.c transfor.c tokens.c \
       cif_fract.c cif.c cif_ctonum.c cif_stx.c \
       multiple.c vector.c wbrotate.c

OBJS = abstree.o cmndline.o command.o infile.o molecule.o outfile.o \
       pixutils.o render.o repres.o script.o transfor.o tokens.o \
       cif_fract.o cif.o cif_ctonum.o cif_stx.o \
       multiple.o vector.o wbrotate.o

TOBJS = abstree.to cmndline.to command.to infile.to molecule.to outfile.to \
       pixutils.to render.to repres.to script.to transfor.to tokens.to \
       cif_fract.to cif.to cif_ctonum.to cif_stx.to \
       multiple.to vector.o wbrotate.to


X11INCS = $(INCS) bitmaps.h
X11SRCS = rasmol.c x11win.c $(SRCS)
X11OBJS = rasmol.o x11win.o $(OBJS)

TXTINCS = $(INCS)
TXTSRCS = rastxt.c $(SRCS)
TXTOBJS = rastxt.to $(TOBJS)

$(CBFLIBDIR):
		(cd $(CBFLIB_TARBALLDIR);\
		  wget $(CBFLIB_TARBALL_URL);\
		  gunzip < $(CBFLIB_TARBALL) | tar xvf -)
		  
$(CBFLIBDIR)/lib/libcbf.a: $(CBFLIBDIR)
		(cd $(CBFLIB_TARBALLDIR); make lib/libcbf.a)
		  
		  

all:		postdownload rasmol rastxt

rasmol:		postdownload $(X11OBJS) $(CBFLIBDIR)/lib/libcbf.a
		$(CC) -o rasmol $(LFLAGS) $(X11OBJS) $(X11LIBS)
		chmod 755 rasmol

rasmol.o:	rasmol.c rasmol.h molecule.h transfor.h command.h infile.h \
		abstree.h render.h graphics.h pixutils.h outfile.h repres.h \
		multiple.h langsel.h
		$(CC) -c $(CFLAGS) rasmol.c

rastxt:		$(TXTOBJS)
		$(CC) -o rastxt $(LFLAGS) $(TXTOBJS) $(LIBS)
		chmod 755 rastxt

rastxt.o:	rastxt.c rasmol.h molecule.h transfor.h cmndline.h \
		command.h abstree.h render.h graphics.h pixutils.h \
		outfile.h script.h
		$(CC) -c $(CFLAGS) rastxt.c

rastxt.to:	rastxt.c rasmol.h molecule.h transfor.h cmndline.h \
		command.h abstree.h render.h graphics.h pixutils.h \
		outfile.h script.h
		$(CC) -c $(CFLAGS)  -I- -I./txt -I. rastxt.c -o rastxt.to

molecule.o:	molecule.c molecule.h rasmol.h cmndline.h command.h abstree.h \
		transfor.h render.h
		$(CC) -c $(CFLAGS) molecule.c

molecule.to:	molecule.c molecule.h rasmol.h cmndline.h command.h abstree.h \
		transfor.h render.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. molecule.c -o molecule.to

infile.o:	infile.c rasmol.h infile.h molecule.h abstree.h command.h \
		transfor.h cif.h cif_fract.h
		$(CC) -c $(CFLAGS) infile.c

infile.to:	infile.c rasmol.h infile.h molecule.h abstree.h command.h \
		transfor.h cif.h cif_fract.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. infile.c -o infile.to

transfor.o:	transfor.c transfor.h rasmol.h molecule.h cmndline.h \
		command.h abstree.h render.h graphics.h repres.h \
		multiple.h vector.h wbrotate.h
		$(CC) -c $(CFLAGS) transfor.c

transfor.to:	transfor.c transfor.h rasmol.h molecule.h cmndline.h \
		command.h abstree.h render.h graphics.h repres.h \
		multiple.h vector.h wbrotate.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. transfor.c -o transfor.to

command.o:	command.c cmndline.h command.h rasmol.h tokens.h abstree.h \
		molecule.h transfor.h render.h graphics.h pixutils.h \
		outfile.h infile.h script.h multiple.h langsel.h
		$(CC) -c $(CFLAGS) command.c

command.to:	command.c cmndline.h command.h rasmol.h tokens.h abstree.h \
		molecule.h transfor.h render.h graphics.h pixutils.h \
		outfile.h infile.h script.h multiple.h langsel.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. command.c -o command.to

abstree.o:	abstree.c abstree.h rasmol.h molecule.h
		$(CC) -c $(CFLAGS) abstree.c

abstree.to:	abstree.c abstree.h rasmol.h molecule.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. abstree.c -o abstree.to

cmndline.o:	cmndline.c cmndline.h rasmol.h molecule.h command.h \
		render.h graphics.h
		$(CC) -c $(CFLAGS) cmndline.c

cmndline.to:	cmndline.c cmndline.h rasmol.h molecule.h command.h \
		render.h graphics.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. cmndline.c -o cmndline.to

render.o:	render.c render.h rasmol.h molecule.h transfor.h \
		command.h abstree.h graphics.h pixutils.h \
		outfile.h infile.h script.h multiple.h
		$(CC) -c $(CFLAGS) render.c

render.to:	render.c render.h rasmol.h molecule.h transfor.h \
		command.h abstree.h graphics.h pixutils.h \
		outfile.h infile.h script.h multiple.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. render.c -o render.to

repres.o:	repres.c repres.h molecule.h graphics.h render.h \
		command.h cmndline.h abstree.h transfor.h pixutils.h \
		infile.h rasmol.h
		$(CC) -c $(CFLAGS) repres.c

repres.to:	repres.c repres.h molecule.h graphics.h render.h \
		command.h cmndline.h abstree.h transfer.h pixutils.h \
		infile.h rasmol.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. repres.c -o repres.to

x11win.o:	x11win.c graphics.h rasmol.h bitmaps.h command.h render.h
		$(CC) -c $(CFLAGS) x11win.c

pixutils.o:	pixutils.c pixutils.h rasmol.h font.h molecule.h \
		transfor.h render.h graphics.h abstree.h repres.h
		$(CC) -c $(CFLAGS) pixutils.c

pixutils.to:	pixutils.c pixutils.h rasmol.h font.h molecule.h \
		transfor.h render.h graphics.h abstree.h repres.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. pixutils.c -o pixutils.to

outfile.o:	outfile.c outfile.h rasmol.h molecule.h command.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		script.h repres.h cmndline.h
		$(CC) -c $(CFLAGS) outfile.c

outfile.to:	outfile.c outfile.h rasmol.h molecule.h command.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		script.h repres.h cmndline.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. outfile.c -o outfile.to

script.o:	script.c script.h rasmol.h molecule.h command.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		repres.h cmndline.h
		$(CC) -c $(CFLAGS) script.c

script.to:	script.c script.h rasmol.h molecule.h command.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		repres.h cmndline.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. script.c -o script.to

tokens.o:	tokens.c tokens.h
		$(CC) -c $(CFLAGS) tokens.c

tokens.to:	tokens.c tokens.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. tokens.c -o tokens.to

cif_fract.o:	cif_fract.c rasmol.h
		$(CC) -c $(CFLAGS) cif_fract.c

cif_fract.to:	cif_fract.c rasmol.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. cif_fract.c -o cif_fract.to

cif.o:		cif.c cif.h rasmol.h molecule.h
		$(CC) -c $(CFLAGS) cif.c

cif.to:		cif.c cif.h rasmol.h molecule.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. cif.c -o cif.to

cif_ctonum.o:	cif_ctonum.c cif_ctonum.h rasmol.h
		$(CC) -c $(CFLAGS) cif_ctonum.c

cif_ctonum.to:	cif_ctonum.c cif_ctonum.h rasmol.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. cif_ctonum.c -o cif_ctonum.to

cif_stx.o: 	cif_stx.c cif.h
		$(CC) -c $(CFLAGS) cif_stx.c

cif_stx.to: 	cif_stx.c cif.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. cif_stx.c -o cif_stx.to

vector.o:	vector.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h vector.h multiple.h
		$(CC) -c $(CFLAGS) vector.c

vector.to:	vector.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h vector.h multiple.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. vector.c -o script.to

multiple.o:	multiple.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		multiple.h outfile.h script.h vector.h wbrotate.h
		$(CC) -c $(CFLAGS) multiple.c

multiple.to:	multiple.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h render.h graphics.h pixutils.h \
		multiple.h outfile.h script.h vector.h wbrotate.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. vector.c -o script.to

wbrotate.o:	wbrotate.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h vector.h multiple.h render.h \
		repres.h graphics.h wbrotate.h
		$(CC) -c $(CFLAGS) wbrotate.c

wbrotate.to:	wbrotate.c rasmol.h command.h tokens.h molecule.h \
		abstree.h transfor.h vector.h multiple.h render.h \
		repres.h graphics.h wbrotate.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. wbrotate.c -o script.to

langsel.o:	langsel.c rasmol.h graphics.h langsel.h
		$(CC) -c $(CFLAGS) langsel.c

langsel.to:	langsel.c rasmol.h graphics.h langsel.h
		$(CC) -c $(CFLAGS) -I- -I./txt -I. langsel.c -o langsel.to


esv:		$(X11SRCS) $(X11INCS)
		cc -systype bsd43 -O3 -Olimit 600 -s -o rasmol \
		-I/bsd43/usr/include -I/usr/include $(X11SRCS) $(EXTLIBS)
		rm *.u

cflow:
		cflow -I/usr/local/include $(X11SRCS)

clean:
		rm -f rasmol rasmol.o x11win.o
		rm -f rastxt rastxt.o
		rm -f $(OBJS)
		rm -f $(TOBJS)

distclean:	clean unpostdownload
		../.undosymlinks

unpostdownload:	postdowndownload
		-@rm -f postdownload
		touch unpostdownload

postdownload:
		touch postdownload
		-@rm f unpostdownload
		../.symlinks
		
