# Makefile for annie
#
# History:  95/08/28 kmflynn

# pathname
WrdA = /usr/opt/wrdapp

# gks graphics library, set LGks to appropriate library
# add -L[directory] if library directories are not in the search path
XGks     = -lxgks -lX11
PriorGks = -lfgks -lhdl -lgks -lX11
LGks     = $(PriorGks)

# Compiler flags (Fortran - Green Hills):
#    C - check subranges and array bounds
#    u - default data type for undeclareds is undefined
#    g - generate source level symbolic debug information
#   OM - optimization
# (NOTE: set OptDbg to: OptM to generate optimized code
#                       DbgF to generate debug code)
DbgF   = -g
OptM   = -OM
OptDbg =
FFLAGS = -C -u $(OptDbg)

# Compiler name
F77 = f77

# this description file uses the Bourne shell
SHELL = /bin/sh
shCmd = sh

#*******************************************************************
#***** You should not need to modify anything below this line. *****
#*******************************************************************

# library directory
library = $(WrdA)/lib3.0
libwdm  = $(library)/lib_data
libmsg  = $(library)/msg
LibDir  = $(library)/lib

program = annie
msgFile = anmess.wdm

Objects = annie.o
message = $(libwdm)/message.wdm       \
          ../msg/annie.seq            \
          $(libmsg)/ann/atwork.seq    $(libmsg)/ann/atdisp.seq   \
          $(libmsg)/ann/dswork.seq    $(libmsg)/ann/dsbld.seq    \
          $(libmsg)/ann/qtdate.seq    $(libmsg)/ann/prwarc.seq   \
          $(libmsg)/ann/wdplot.seq    $(libmsg)/ann/tswork.seq   \
          $(libmsg)/ann/pgener.seq    $(libmsg)/ann/qtprnt.seq   \
          $(libmsg)/waide/agplot.seq  $(libmsg)/waide/tbltmp.seq \
          $(libmsg)/waide/tslist.seq  $(libmsg)/waide/tstabl.seq \
          ../msg/wdimex.sh
Libs    = $(LibDir)/annlib.a   $(LibDir)/waidelib.a \
          $(LibDir)/graphlib.a $(LibDir)/statslib.a $(LibDir)/aidelib.a \
          $(LibDir)/wdmlib.a   $(LibDir)/adwdmlib.a $(LibDir)/utillib.a

BINDIR  = ../bin
binary  = ../bin
binMake = $(binary)/$(program)
binInst = $(BINDIR)/$(program)
binData = ../bin_data
msgMake = $(binData)/$(msgFile)

# Rules
all:  first $(binMake) $(msgMake) install
	@echo "\n"Done making all, files are now up to date."\n"

# program dependencies
$(binMake):  $(Objects) $(Libs)
	$(F77) $(Objects) $(Libs) $(LGks) -o $@

$(msgMake):  $(message)
	rm -f $(msgMake)
	cd ../msg ; rm -f wdimex.out ; $(shCmd) ./wdimex.sh > wdimex.out

first:
	@if [ ! -d $(binary) ]   ; then        \
	   mkdir $(binary)  ;                  \
	   echo Created directory $(binary) ;  \
	fi
	@if [ ! -d $(binData) ]  ; then        \
	   mkdir $(binData) ;                  \
	   echo Created directory $(binData) ; \
	fi
install:
# Create directory for binary file, if necessary
	@if [ ! -d $(BINDIR) ]   ; then        \
	   mkdir $(BINDIR) ;                   \
	   echo  Created directory $(BINDIR) ; \
	fi
# Link executable to BINDIR if installing elsewhere
	@if [ ! -s $(binMake) ] ; then                              \
	   echo program $(binMake) does not exist, ;                \
	   echo use one of the following commands to generate it:;  \
	   echo "     make" ;  echo "     make all" ;               \
	else                                                        \
	   if [ $(BINDIR) != $(binary) ] ; then                     \
	      rm -f $(binInst) ;                               \
	      cd .. ; ln -s `pwd`/bin/$(program) $(binInst);   \
	      chmod 644 $(binInst) ;                           \
	      echo "\n"Program $(binInst) has been updated.;   \
	   fi ; \
	fi
clean:
	@if [ $(BINDIR) != $(binary) ] ; then rm -f $(binInst) ; fi
	rm -f *.o $(binMake) $(msgMake)
	@echo Removed files generated by make."\n"

# Define object file dependencies:
annie.o:  fanmes.inc  pmesfl.inc 

# end of make
