
##################################################
#
# SEISAN 8.0
#
# May 2003
#
# Makefile for SEISAN LIB directory
#
# changes:
#   05 10 99 lo: cleanup distribution
#   24 03 00 jh: add wave
#   05 05 00 lo: check if any include file is changed
#   15 05 00 jh: remove ttlsub
#    7 01 01 jh: add auto_amp
#   30 01 01 jh : add sig_spec
#   19 02 01 lo : add hypo71sub make_hypoc_brief 
#   14 10 01 jh : remove continuous.for
#   04 03 02 lo : added focmec_exe_sub
#   05 03 02 jh : added gmt.for
#   23 08 02 je : add quarrycheck, and getenv2
#   14 01 03 lo : add platform dependency
#   26 08 03 ds : add dependencies for macosx (Mac OS X) 
#                 (dstoll@lennartz-electronic.de)
#   27 10 04 jh : add seed.for
#
##################################################

##################################################
# THE ARCHITECTURE IS EXPECTED TO BE GIVEN BY
# THE ENVIRONMENTAL VARIABLE SEISARCH, WHICH
# CAN BE: solaris or linux or macosx
##################################################

##################################################
# PATH TO WHICH OUTPUT FILES ARE WRIITEN,
# THIS CAN BE SET TO $(SEISARCH) IF 
# SEVERAL OPERATING SYSTEMS COMPILE 
# SOURCE ON SHARED DISKS,
# OBVIOUSLY OUTPATH CAN BE USED TO WRITE
# OBJECTS TO ANY OTHER PLACE
##################################################
# OUTPATH = $(SEISARCH)
OUTPATH = .

##################################################
# COMPILERS AND FALGS
fc_solaris = f77 -g -c -I../INC -o $@
cc_solaris = cc -c -I../INC -o $@							# RL
fc_linux = g77 -g -c -I../INC -fdollar-ok -fugly-complex \
              -fno-automatic -o $@
fc_macosx = g77 -g -c -I../INC -fdollar-ok -fugly-complex \
              -fno-automatic -o $@
cc_linux = gcc -g -c -I../INC -o $@
cc_macosx = gcc -g -c -I../INC -I/usr/X11R6/include -o $@
fc = $(fc_$(SEISARCH))
cc = $(cc_$(SEISARCH))

##################################################
# SUFFIX FOR OBJECT FILES AND ARCHIVE
osuf_solaris = o
osuf_linux = o
osuf_macosx = o
osuf_windows = obj
osuf = $(osuf_$(SEISARCH))
asuf_solaris = a
asuf_linux = a
asuf_macosx = a
asuf_windows = lib
asuf = $(asuf_$(SEISARCH))

##################################################
# FILES SPECFIC TO PLATFORM
solaris_ONLY = $(OUTPATH)/comp_sun.o 
#$(OUTPATH)/xview_lib.o
linux_ONLY = $(OUTPATH)/comp_linux.o
#
#  Since OS X runs on a big endian processor, we pretend this is
#  a Sun system.
#
macosx_ONLY = $(OUTPATH)/comp_sun.o

PLATFORM_DEP_OBJ = $($(SEISARCH)_ONLY)

##################################################
# NAME OF ARCHIVE
archive = seisan.$(asuf)

# not included hypinv2.for

#
# LIST OF OBJECTS THAT ARE COMMON ON ALL PLATFORMS
# AND THAT ARE PART OF THE ARCHIVE
#
SUBS = $(OUTPATH)/abstim.$(osuf) $(OUTPATH)/auto_tr.$(osuf) \
  $(OUTPATH)/auto_amp.$(osuf) $(OUTPATH)/autocoda.$(osuf) \
  $(OUTPATH)/autofil.$(osuf) $(OUTPATH)/azibazi.$(osuf) \
  $(OUTPATH)/bcd.$(osuf) $(OUTPATH)/bndpas.$(osuf) \
  $(OUTPATH)/check_s.$(osuf) \
  $(OUTPATH)/compdecomp.$(osuf) $(OUTPATH)/codecoutil.$(osuf)  \
  $(OUTPATH)/comp_unix.$(osuf) $(OUTPATH)/componen.$(osuf) \
  $(OUTPATH)/conv_def.$(osuf) $(OUTPATH)/fft.$(osuf)  \
  $(OUTPATH)/eev_sub.$(osuf) $(OUTPATH)/err_ellipse.$(osuf) \
  $(OUTPATH)/filename.$(osuf) $(OUTPATH)/findchan.$(osuf) \
  $(OUTPATH)/findevin.$(osuf) $(OUTPATH)/focmec_exe_sub.$(osuf) \
  $(OUTPATH)/ga_lib.$(osuf) $(OUTPATH)/get_baz.$(osuf) \
  $(OUTPATH)/gmt.$(osuf) $(OUTPATH)/gse_io.$(osuf) \
  $(OUTPATH)/gserespl.$(osuf) $(OUTPATH)/gsesei_lib.$(osuf) \
  $(OUTPATH)/hypoloc.$(osuf) $(OUTPATH)/hypoloc1.$(osuf) \
  $(OUTPATH)/hyposub1.$(osuf) $(OUTPATH)/hyposub2.$(osuf) \
  $(OUTPATH)/hyposub3.$(osuf) $(OUTPATH)/hyposub4.$(osuf) \
  $(OUTPATH)/hyposub6.$(osuf) \
  $(OUTPATH)/hypo71sub.$(osuf) $(OUTPATH)/make_hypoc_brief.$(osuf) \
  $(OUTPATH)/iscloc_wrap.$(osuf) \
  $(OUTPATH)/iscloc.$(osuf) \
  $(OUTPATH)/inc_id.$(osuf) $(OUTPATH)/indata.$(osuf) \
  $(OUTPATH)/isf_isc.$(osuf) \
  $(OUTPATH)/libsei.$(osuf) $(OUTPATH)/lsqlin.$(osuf) \
  $(OUTPATH)/lgstr.$(osuf) \
  $(OUTPATH)/maxlik.$(osuf) $(OUTPATH)/mb_att.$(osuf) \
  $(OUTPATH)/merge_f.$(osuf)  $(OUTPATH)/mfhead.$(osuf) \
  $(OUTPATH)/mul_spec.$(osuf) \
  $(OUTPATH)/nortype.$(osuf) $(OUTPATH)/picsub.$(osuf) \
  $(OUTPATH)/polos.$(osuf) $(OUTPATH)/quarrycheck.$(osuf) \
  $(OUTPATH)/recfil.$(osuf) \
  $(OUTPATH)/rea.$(osuf) \
  $(OUTPATH)/rea2.$(osuf) \
  $(OUTPATH)/removedc.$(osuf) \
  $(OUTPATH)/sei_mes.$(osuf) $(OUTPATH)/seiplot.$(osuf) \
  $(OUTPATH)/seisinc.$(osuf) $(OUTPATH)/sfilname.$(osuf) \
  $(OUTPATH)/seed.$(osuf) $(OUTPATH)/seed.$(osuf) \
  $(OUTPATH)/shead.$(osuf) $(OUTPATH)/sheads.$(osuf) \
  $(OUTPATH)/sacsei_lib.$(osuf) $(OUTPATH)/sig_spec.$(osuf) \
  $(OUTPATH)/sacsubf.$(osuf) \
  $(OUTPATH)/spec_dist.$(osuf) $(OUTPATH)/stat_loc.$(osuf) \
  $(OUTPATH)/swap.$(osuf) $(OUTPATH)/syntsel.$(osuf) \
  $(OUTPATH)/sys_resp.$(osuf) $(OUTPATH)/systime.$(osuf) \
  $(OUTPATH)/svd.$(osuf) $(OUTPATH)/timerout.$(osuf) \
  $(OUTPATH)/xy_plot.$(osuf) $(OUTPATH)/respfil.$(osuf) \
  $(OUTPATH)/seis_unix.$(osuf) $(OUTPATH)/sfil.$(osuf) \
  $(OUTPATH)/tau.$(osuf) $(OUTPATH)/text_sort.$(osuf) \
  $(OUTPATH)/volcano.$(osuf) $(OUTPATH)/wave.$(osuf) \
  $(OUTPATH)/xlib.$(osuf) 

#
# OBJECTS THAT WILL NOT BE PART OF THE ARCHIVE
# 
# NON_ARCHIVE_SUBS = $(OUTPATH)/sac_dummy.$(osuf) 

#
# INCLUDE FILES
#
INCS = ../INC/*.inc ../INC/*.f ../INC/*INC 

info:
	@echo --------------------------------------------------
	@echo "SEISAN Makefile FOR LIB DIRETORY, OPTIONS ARE:"
	@echo " "
	@echo "   all - compiles all, and creates archive"
	@echo "   $(OUTPATH)/<object> - create object"
	@echo "   $(OUTPATH)/$(archive) - create archive"
	@echo "   clean - remove executables"
	@echo " "
	@echo "OUTPUT PATH IS SET TO $(OUTPATH) "
	@echo --------------------------------------------------
	@echo "$(test)"

all: output $(OUTPATH) $(PLATFORM_DEP_OBJ) $(SUBS) $(NON_ARCHIVE_SUBS) \
     $(OUTPATH)/$(archive) 

output:
	@echo -------------------------------------------------
	@echo ---- COMPILING SEISAN 8 LIBRARIES ----------------
	@echo -------------------------------------------------

solaris: 
	mkdir solaris

linux: 
	mkdir linux
macosx:
	mkdir macosx


#
# fortran object files
#

$(OUTPATH)/abstim.$(osuf): abstim.for $(INCS)
	$(fc) abstim.for 

$(OUTPATH)/auto_tr.$(osuf): auto_tr.for $(INCS)
	$(fc) auto_tr.for 

$(OUTPATH)/auto_amp.$(osuf): auto_amp.for $(INCS)
	$(fc) auto_amp.for

$(OUTPATH)/autocoda.$(osuf): autocoda.for $(INCS)
	$(fc) autocoda.for

$(OUTPATH)/autofil.$(osuf): autofil.for $(INCS)
	$(fc) autofil.for

$(OUTPATH)/azibazi.$(osuf): azibazi.for $(INCS)
	$(fc) azibazi.for

$(OUTPATH)/bcd.$(osuf): bcd.for $(INCS)
	$(fc) bcd.for

$(OUTPATH)/bndpas.$(osuf): bndpas.for $(INCS)
	$(fc) bndpas.for

$(OUTPATH)/check_s.$(osuf): check_s.for $(INCS)
	$(fc) check_s.for

$(OUTPATH)/codecoutil.$(osuf): codecoutil.for $(INCS)
	$(fc) codecoutil.for

$(OUTPATH)/compdecomp.$(osuf): compdecomp.for $(INCS)
	$(fc) compdecomp.for

$(OUTPATH)/comp_linux.$(osuf): comp_linux.for $(INCS)
	$(fc) comp_linux.for

$(OUTPATH)/comp_sun.$(osuf): comp_sun.for $(INCS)
	$(fc) comp_sun.for

$(OUTPATH)/comp_unix.$(osuf): comp_unix.for $(INCS)
	$(fc) comp_unix.for

$(OUTPATH)/componen.$(osuf): componen.for $(INCS)
	$(fc) componen.for

$(OUTPATH)/conv_def.$(osuf): conv_def.for $(INCS)
	$(fc) conv_def.for

$(OUTPATH)/err_ellipse.$(osuf): err_ellipse.for $(INCS)
	$(fc) err_ellipse.for

$(OUTPATH)/eev_sub.$(osuf): eev_sub.for $(INCS)
	$(fc) eev_sub.for

$(OUTPATH)/fft.$(osuf): fft.for $(INCS)
	$(fc) fft.for

$(OUTPATH)/filename.$(osuf): filename.for $(INCS)
	$(fc) filename.for

$(OUTPATH)/findchan.$(osuf): findchan.for $(INCS)
	$(fc) findchan.for

$(OUTPATH)/findevin.$(osuf): findevin.for $(INCS)
	$(fc) findevin.for

$(OUTPATH)/focmec_exe_sub.$(osuf): focmec_exe_sub.for
	$(fc) focmec_exe_sub.for

$(OUTPATH)/ga_lib.$(osuf): ga_lib.for $(INCS)
	$(fc) ga_lib.for

$(OUTPATH)/get_baz.$(osuf): get_baz.for $(INCS)
	$(fc) get_baz.for
	
$(OUTPATH)/gmt.$(osuf): gmt.for $(INCS)
	$(fc) gmt.for

$(OUTPATH)/getenv2.$(osuf): getenv2.for
	$(fc) getenv2.for
	
$(OUTPATH)/gse_io.$(osuf): gse_io.for $(INCS)
	$(fc) gse_io.for

$(OUTPATH)/gsesei_lib.$(osuf): gsesei_lib.for $(INCS)
	$(fc) gsesei_lib.for

$(OUTPATH)/gserespl.$(osuf): gserespl.for $(INCS)
	$(fc) gserespl.for

$(OUTPATH)/hypinv1.$(osuf): hypinv1.for $(INCS)
	$(fc) hypinv1.for

$(OUTPATH)/hypinv2.$(osuf): hypinv2.for $(INCS)
	$(fc) hypinv2.for

$(OUTPATH)/hypinv3.$(osuf): hypinv3.for $(INCS)
	$(fc) hypinv3.for

$(OUTPATH)/hypoloc.$(osuf): hypoloc.for $(INCS)
	$(fc) hypoloc.for

$(OUTPATH)/hypoloc1.$(osuf): hypoloc1.for $(INCS)
	$(fc) hypoloc1.for

$(OUTPATH)/hyposub1.$(osuf): hyposub1.for $(INCS)
	$(fc) hyposub1.for

$(OUTPATH)/hyposub2.$(osuf): hyposub2.for $(INCS)
	$(fc) hyposub2.for

$(OUTPATH)/hyposub3.$(osuf): hyposub3.for $(INCS)
	$(fc) hyposub3.for

$(OUTPATH)/hyposub4.$(osuf): hyposub4.for $(INCS)
	$(fc) hyposub4.for

$(OUTPATH)/hyposub6.$(osuf): hyposub6.for $(INCS)
	$(fc) hyposub6.for

$(OUTPATH)/hypo71sub.$(osuf): hypo71sub.for
	$(fc) hypo71sub.for

$(OUTPATH)/iscloc_wrap.$(osuf): iscloc_wrap.for $(INCS)
	$(fc) iscloc_wrap.for

$(OUTPATH)/inc_id.$(osuf): inc_id.for $(INCS)
	$(fc) inc_id.for

$(OUTPATH)/indata.$(osuf): indata.for $(INCS)
	$(fc) indata.for

$(OUTPATH)/isf_isc.$(osuf): isf_isc.for $(INCS)
	$(fc) isf_isc.for

$(OUTPATH)/libsei.$(osuf): libsei.for $(INCS)
	$(fc) libsei.for

$(OUTPATH)/lgstr.$(osuf): lgstr.for $(INCS)
	$(fc) lgstr.for

$(OUTPATH)/lsqlin.$(osuf): lsqlin.for $(INCS)
	$(fc) lsqlin.for

$(OUTPATH)/make_hypoc_brief.$(osuf): make_hypoc_brief.for $(INCS)
	$(fc) make_hypoc_brief.for

$(OUTPATH)/maxlik.$(osuf): maxlik.for $(INCS)
	$(fc) maxlik.for

$(OUTPATH)/mb_att.$(osuf): mb_att.for $(INCS)
	$(fc) mb_att.for

$(OUTPATH)/merge_f.$(osuf): merge_f.for $(INCS)
	$(fc) merge_f.for

$(OUTPATH)/mfhead.$(osuf): mfhead.for $(INCS)
	$(fc) mfhead.for

$(OUTPATH)/mul_spec.$(osuf): mul_spec.for $(INCS)
	$(fc) mul_spec.for

$(OUTPATH)/nortype.$(osuf): nortype.for $(INCS)
	$(fc) nortype.for

$(OUTPATH)/picsub.$(osuf): picsub.for $(INCS)
	$(fc) picsub.for

$(OUTPATH)/polos.$(osuf): polos.for $(INCS)
	$(fc) polos.for

$(OUTPATH)/quarrycheck.$(osuf): quarrycheck.for
	$(fc) quarrycheck.for
	
$(OUTPATH)/rea.$(osuf): rea.for $(INCS)
	$(fc) rea.for

$(OUTPATH)/rea2.$(osuf): rea2.for $(INCS)
	$(fc) rea2.for

$(OUTPATH)/recfil.$(osuf): recfil.for $(INCS)
	$(fc) recfil.for

$(OUTPATH)/removedc.$(osuf): removedc.for $(INCS)
	$(fc) removedc.for

#$(OUTPATH)/sac_dummy.$(osuf): sac_dummy.for
#	$(fc) sac_dummy.for

$(OUTPATH)/sacsei_lib.$(osuf): sacsei_lib.for $(INCS)
	$(fc) sacsei_lib.for

$(OUTPATH)/sacsubf.$(osuf): sacsubf.for $(INCS)
	$(fc) sacsubf.for

$(OUTPATH)/seed.$(osuf): seed.for $(INCS)
	$(fc) seed.for

$(OUTPATH)/sei_mes.$(osuf): sei_mes.for $(INCS)
	$(fc) sei_mes.for

$(OUTPATH)/sig_spec.$(osuf): sig_spec.for $(INCS)
	$(fc) sig_spec.for

$(OUTPATH)/seiplot.$(osuf): seiplot.for $(INCS)
	$(fc) seiplot.for

$(OUTPATH)/seisinc.$(osuf): seisinc.for $(INCS)
	$(fc) seisinc.for

$(OUTPATH)/sfilname.$(osuf): sfilname.for $(INCS)
	$(fc) sfilname.for

$(OUTPATH)/shead.$(osuf): shead.for $(INCS)
	$(fc) shead.for

$(OUTPATH)/sheads.$(osuf): sheads.for $(INCS)
	$(fc) sheads.for

$(OUTPATH)/spec_dist.$(osuf): spec_dist.for $(INCS)
	$(fc) spec_dist.for

$(OUTPATH)/stat_loc.$(osuf): stat_loc.for $(INCS)
	$(fc) stat_loc.for

$(OUTPATH)/svd.$(osuf): svd.for $(INCS)
	$(fc) svd.for

$(OUTPATH)/swap.$(osuf): swap.for $(INCS)
	$(fc) swap.for

$(OUTPATH)/syntsel.$(osuf): syntsel.for $(INCS)
	$(fc) syntsel.for

$(OUTPATH)/sys_resp.$(osuf): sys_resp.for $(INCS)
	$(fc) sys_resp.for

$(OUTPATH)/systime.$(osuf): systime.for $(INCS)
	$(fc) systime.for

$(OUTPATH)/tau.$(osuf): tau.for $(INCS)
	$(fc) tau.for

$(OUTPATH)/text_sort.$(osuf): text_sort.for $(INCS)
	$(fc) text_sort.for

$(OUTPATH)/timerout.$(osuf): timerout.for $(INCS)
	$(fc) timerout.for

$(OUTPATH)/volcano.$(osuf): volcano.for $(INCS)
	$(fc) volcano.for

$(OUTPATH)/wave.$(osuf): wave.for $(INCS)
	$(fc) wave.for

$(OUTPATH)/xy_plot.$(osuf): xy_plot.for $(INCS)
	$(fc) xy_plot.for

 
#
# c object files
#


$(OUTPATH)/respfil.$(osuf): respfil.c
	$(cc) respfil.c

$(OUTPATH)/seis_unix.$(osuf): seis_unix.c
	$(cc) seis_unix.c

$(OUTPATH)/sfil.$(osuf): sfil.c
	$(cc) sfil.c

$(OUTPATH)/xlib.$(osuf):xlib.c
	$(cc) xlib.c 

$(OUTPATH)/iscloc.$(osuf): iscloc.c $(INCS) \
    ../INC/iscloc.h  ../INC/iscloc_jb_model.h  ../INC/iscloc_jb_tables.h 
	$(cc) iscloc.c

#$(OUTPATH)/xview_lib.$(osuf): xview_lib.c
#	$(cc) -g -c xview_lib.c -I/usr/openwin/include/

#
# make archive
#
$(OUTPATH)/$(archive): $(SUBS) $(INCS)
	ar cr $(OUTPATH)/$(archive) $(SUBS) $(PLATFORM_DEP_OBJ)
	ranlib $(OUTPATH)/$(archive)

# 
# delete object files with option clean
#
clean:
	rm -f $(OUTPATH)/*.$(osuf)
	rm -f $(OUTPATH)/seisan.$(asuf) 

