# Makefile makefile_spur0301_sgi for spurion program using f77 under SGI
# Makefile makefile_spur0301_g77 for spurion program using g77 under Linux
# By commenting out SGI specific parts and uncommenting in
# parts for Linux g77, should work under linux g77 right away. 

# OS 
 OS = g77
#g77 THISOS = g77
 OS = sgi
#DECUNIX OS = decunix

# version = year-month 
VERS = 0301
DAY = 15
 
# Relative directory tree
BINDIR = ../bin/
SRCDIR = ../src_$(VERS)/

# Definitions needed by all
# Now Year-month of version (0112) included in the executable name
BINSPUR = $(BINDIR)spur_$(VERS)$(DAY)_$(OS)

# Object file names, conveniently clumped together
fsources0 = spurion_main.o spurion_bits.o spurion_routines.o spurion_mod.o
fsources1 = spurion_structmenu.o operations.o generate.o transform.o 
fsources2 = plotspur.o calcki.o calclattice.o fsqlattice.o plotlattice.o 
fsources3 = logscale.o label.o calcincoh.o plotincoh.o alewald.o pg_lib.o
## removed help.o from fsources3
fsources4 = lazy.o functions.o burz.o printequiv.o conditions.o 
fsources5 = multf.o pulverix.o extinc.o structfac.o subroutines.o
fsources6 = ellipse.o hdiag.o
fsources7 = io.o indexsort.o spurion_scan.o spur_qbuf.o spurion_grid.o
 fsources_os = datestamp_sgi.o
#g77fsources_os = datestamp_g77.o
csources = help-paul-unx.o
fsources_obsolete =  qbufin.o qbufout.o

# g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 
#g77 DIALECT =  
#g77 BKSLSH = -fno-backslash
#g77 WARN= -Wall -W
#g77 DEBUG = -g
#g77 FC=g77
#g77 OPTLINKER=-o
#g77 CC=gcc
#g77 CFLAGS =-c -g -Wall -W
#####moved####g77 OS = g77
#g77 LK_GENERAL = -lc -lm -L/usr/local/share/pgplot -lpgplot \
#g77	-lX11 -L/usr/X11R6/lib -lreadline -ltermcap
#g77## IO_OBJ = $(SAN_IO_LOCAL).o characters.o
#g77 all: $(fsources0) $(fsources1) $(fsources2) $(fsources3) $(fsources4) \
#g77 		$(fsources5) $(fsources6) $(fsources7) $(csources) \
#g77		$(fsources_os) \
#g77		$(BINSPUR)
#g77_doc		$(BINSPUR) make_tex make_html
# g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 g77 

#sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi
#Sgi don't know what option +E1, +e, or why use +O3 or + rather than -.
#sgi Don't know why -u works on linking but not used on object compiles.
#sgi Skipping +O3 (too fast). Skipping +E1; since don't know what it is.
 DIALECT = 
#sgi# -C range checking, -u default to undefined type.
 WARN= -listing
 DEBUG = -g
 BKSLSH = -backslash
#sgi FC=f77
####moved#### OS = sgi
### OPTLINKER= -o
 OPTLINKER=-show -o
 CC=cc
 CFLAGS =-c -I/usr/local/include -Dnoreadline
 RANLIB=ranlib
 LK_GENERAL =  -L/usr/local/lib -lpgplot_n32 -lX11
#  LK_GENERAL = -L/usr/user2/toby/pgplot -lpgplot -lX11_s
## LK_GENERAL = -L/usr/user2/cpadams/pgplot -lpgplot -lX11_s
##### LK_GENERAL = -lc -lm -L/usr/user5/local/toby/pgplot -lpgplot -lX11_s
 all: $(fsources0) $(fsources1) $(fsources2) $(fsources3) $(fsources4) \
	$(fsources5) $(fsources6) $(fsources7) $(csources) \
	$(fsources_os)\
	$(BINSPUR)
#sgi### setenv PGPLOT_DIR /usr/user5/local/toby/pgplot
#sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi #sgi

# DEC unix fortran DEC unix fortran DEC unix fortran DEC unix fortran
#DECUNIX
#DECUNIX DIALECT= -assume backslash
#DECUNIX WARN= -warn general -show include -show xref -v -V
#DECUNIX DEBUG= 
#DECUNIX FC=f77 -old_f77
#DECUNIX OPTLINKER=-o
#DECUNIX CC=cc
#DECUNIX CFLAGS =-c 
###Moved#####DECUNIX OS = decunix
#DECUNIX... gplot library in place of readline on psw283.psi.ch
#DECUNIX GPLOTPATH=/usr/local/triumf/programs/
#DECUNIX LKGPLOT=$(GPLOTPATH)gplot.a
#DECUNIX LK_GENERAL = -lc -lm -lpgplot -lX11
#
#DECUNIX SAN_IO_LOCAL = san_io_$(OS)_01may
#DECUNIX IO_OBJ = $(SAN_IO_LOCAL).o characters.o
#DECUNIX all: $(SAN_OBJ) $(RISO_OBJ) $(FITU_OBJ) $(IO_OBJ) \
#DECUNIX$(BINSAN01_GPLOT) $(BINSAN01_STUPID) \
#DECUNIX$(HELPDIR)sanonly.hlp $(HELPDIR)san.hlp 
# DEC unix fortran DEC unix fortran DEC unix fortran DEC unix fortran

#
# Fortran flags for all operating systems
 FFLAGS =-c $(DIALECT) $(WARN) $(DEBUG)

# -u make default fortran type UNDEFINED for SGI
$(BINSPUR) : $(fsources0) $(fsources1) $(fsources2) $(fsources3) \
		$(fsources4) $(fsources5) $(fsources6) $(fsources7) \
		$(csources)  $(fsources_os)
	$(FC) $(OPTLINKER) $(BINSPUR) \
		$(fsources0) $(fsources1) $(fsources2) $(fsources3) \
		$(fsources4) $(fsources5) $(fsources6) $(fsources7) \
		$(csources) $(fsources_os)\
		$(LK_GENERAL)
####	f77 -u -backslash -o		for SGI
	
spurion_main.o : $(SRCDIR)spurion_main.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)io_files.inc  $(SCRDIR)spur_color.inc $(SCRDIR)spur_menu.inc \
	$(SCRDIR)spur_layout.inc $(SCRDIR)spur_scan.inc  $(SRCDIR)spur_warn.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_main.f
spurion_routines.o : $(SRCDIR)spurion_routines.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)io_files.inc  $(SCRDIR)spur_color.inc $(SRCDIR)spur_layout.inc\
	$(SCRDIR)spur_menu.inc $(SCRDIR)spur_modmenu.inc $(SCRDIR)spur_scan.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_routines.f
spurion_bits.o : $(SRCDIR)spurion_bits.f \
	$(SRCDIR)arraysize.inc $(SRCDIR)io_files.inc $(SRCDIR)spur_layout.inc \
	$(SRCDIR)spur_warn.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_bits.f
spurion_mod.o : $(SRCDIR)spurion_mod.f $(SCRDIR)spur_modmenu.inc\
	$(SRCDIR)arraysize.inc $(SRCDIR)io_files.inc $(SCRDIR)spur_buf.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_mod.f
spurion_structmenu.o : $(SRCDIR)spurion_structmenu.f \
	$(SCRDIR)spur_structmenu.inc\
	$(SRCDIR)arraysize.inc $(SRCDIR)io_files.inc $(SCRDIR)spur_buf.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_structmenu.f
spurion_scan.o : $(SRCDIR)spurion_scan.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)io_files.inc  $(SCRDIR)spur_color.inc \
	$(SCRDIR)spur_scan.inc  $(SCRDIR)spur_data.inc $(SRCDIR)spur_warn.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_scan.f
spurion_grid.o : $(SRCDIR)spurion_grid.f $(SRCDIR)arraysize.inc \
	$(SCRDIR)spur_color.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)spurion_grid.f
spur_qbuf.o : $(SRCDIR)spur_qbuf.f $(SRCDIR)io_files.inc $(SRCDIR)spur_buf.inc
	$(FC) $(FFLAGS)  $(SRCDIR)spur_qbuf.f
#obsolete qbufin.o : $(SRCDIR)qbufin.f $(SRCDIR)io_files.inc  
#obsolete	$(FC) $(FFLAGS)  $(SRCDIR)qbufin.f
#obsoleteqbufout.o : $(SRCDIR)qbufout.f $(SRCDIR)io_files.inc  
#obsolete	$(FC) $(FFLAGS)  $(SRCDIR)qbufout.f
operations.o : $(SRCDIR)operations.f
	$(FC) $(FFLAGS)  $(SRCDIR)operations.f
generate.o : $(SRCDIR)generate.f
	$(FC) $(FFLAGS)  $(SRCDIR)generate.f
transform.o : $(SRCDIR)transform.f
	$(FC) $(FFLAGS)  $(SRCDIR)transform.f
plotspur.o : $(SRCDIR)plotspur.f \
	$(SRCDIR)arraysize.inc $(SCRDIR)spur_color.inc\
	$(SRCDIR)spur_scan.inc $(SRCDIR)io_files.inc
	$(FC) $(FFLAGS)  $(SRCDIR)plotspur.f
calcki.o : $(SRCDIR)calcki.f $(SRCDIR)spur_warn.inc $(SCRDIR)spur_scan.inc
	$(FC) $(FFLAGS)  $(SRCDIR)calcki.f
#
# Time-of-flight (constant A3, A4) code, add back to sources if necessary
#calckitof.o : calckitof.f
#	$(FC) $(FFLAGS)  calckitof.f
#
calclattice.o : $(SRCDIR)calclattice.f $(SRCDIR)arraysize.inc
	$(FC) $(FFLAGS)  $(SRCDIR)calclattice.f
fsqlattice.o : $(SRCDIR)fsqlattice.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)io_files.inc  
	$(FC) $(FFLAGS)  $(SRCDIR)fsqlattice.f
indexsort.o : $(SRCDIR)indexsort.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)spur_layout.inc
	$(FC) $(FFLAGS)  $(SRCDIR)indexsort.f
plotlattice.o : $(SRCDIR)plotlattice.f $(SRCDIR)arraysize.inc \
	$(SRCDIR)io_files.inc  $(SCRDIR)spur_color.inc \
	$(SRCDIR)spur_layout.inc $(SRCDIR)spur_scan.inc 
	$(FC) $(FFLAGS)  $(SRCDIR)plotlattice.f
logscale.o : $(SRCDIR)logscale.f
	$(FC) $(FFLAGS)  $(SRCDIR)logscale.f
calcincoh.o : $(SRCDIR)calcincoh.f
	$(FC) $(FFLAGS)  $(SRCDIR)calcincoh.f
plotincoh.o : $(SRCDIR)plotincoh.f $(SRCDIR)arraysize.inc\
	$(SRCDIR)io_files.inc  $(SCRDIR)spur_color.inc $(SCRDIR)spur_scan.inc
	$(FC) $(FFLAGS)  $(SRCDIR)plotincoh.f
alewald.o : $(SRCDIR)alewald.f $(SRCDIR)arraysize.inc $(SCRDIR)spur_scan.inc
	$(FC) $(FFLAGS)  $(SRCDIR)alewald.f
label.o : $(SRCDIR)label.f $(SCRDIR)spur_color.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)label.f

#Adams help.o : $(SRCDIR)help.f
#Adams	$(FC) $(FFLAGS)  $(SRCDIR)help.f

help-paul-unx.o : $(SRCDIR)help-paul-unx.c
	$(CC) $(CFLAGS) $(SRCDIR)help-paul-unx.c

lazy.o : $(SRCDIR)lazy.f $(SRCDIR)arraysize.inc $(SRCDIR)io_files.inc 
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)lazy.f
functions.o : $(SRCDIR)functions.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)functions.f
burz.o : $(SRCDIR)burz.f $(SRCDIR)io_files.inc 
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)burz.f
printequiv.o : $(SRCDIR)printequiv.f $(SRCDIR)io_files.inc 
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)printequiv.f
multf.o : $(SRCDIR)multf.f $(SRCDIR)arraysize.inc\
	$(SRCDIR)io_files.inc 
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)multf.f
conditions.o : $(SRCDIR)conditions.f $(SRCDIR)io_files.inc 
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)conditions.f
pulverix.o : $(SRCDIR)pulverix.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)pulverix.f
extinc.o : $(SRCDIR)extinc.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)extinc.f
ellipse.o : $(SRCDIR)ellipse.f $(SCRDIR)spur_color.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)ellipse.f
# to be used with reselp.f
##tasin.o : $(SRCDIR)tasin.f
##	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)tasin.f
# future resolution routine.
##reselp.o : $(SRCDIR)reselp.f
##	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)reselp.f
hdiag.o : $(SRCDIR)hdiag.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)hdiag.f
structfac.o : $(SRCDIR)structfac.f $(SRCDIR)arraysize.inc
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)structfac.f
subroutines.o : $(SRCDIR)subroutines.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)subroutines.f
io.o : $(SRCDIR)io.f
	$(FC) $(FFLAGS) $(BKSLSH) $(SRCDIR)io.f
	
pg_lib.o : $(SRCDIR)pg_lib.f $(SRCDIR)io_files.inc $(SRCDIR)spur_layout.inc \
	$(SRCDIR)spur_color.inc $(SRCDIR)spur_scan.inc $(SRCDIR)spur_warn.inc
	$(FC) $(FFLAGS) $(SRCDIR)pg_lib.f

datestamp_g77.o : $(SRCDIR)datestamp_g77.f  
	$(FC) $(FFLAGS) $(SRCDIR)datestamp_g77.f
datestamp_sgi.o : $(SRCDIR)datestamp_sgi.f  
	$(FC) $(FFLAGS) $(SRCDIR)datestamp_sgi.f

# Don't know what -e option is
#f77 +E1 +O3 +e -c pg_lib.f


#### Don't update the help for now.
#### Uncomment if need to compile the help routine 
make_tex:
	(cp h2l_$(THISOS).path h2l.path)
	(ls -1 ../help > h2l.dat)
	(../bin/h2l_auto)
	(mv Makefile_tex. makefile_tex)

#### remove since help has not changed
#### Uncomment if need to convert spurion.hlp to other formats
make_html:
	(make -f makefile_tex)


