# DO NOT MODIFY THIS MAKEFILE.
# It was generated automatically by fixmake
# from input file makefile.gen and writing to makefile.
#
#
# Makefile for FLECS
#
# Author: Robert E. Bruccoleri
#         Bristol-Myers Squibb Pharmaceutical Research Institute
#
# Makefile macros for a Linux machine running gfortran and gcc.

# Flags -- note that common flags go on the binary definitions

CFLAGS        = -g
COPTFLAGS     = -g -O2 
CSPECOPTFLAGS = -g -O0
CPPFLAGS      = -DLANGUAGE_C -Dlinux -Dunix
FFLAGS        = -g
FOPTFLAGS     = -g -O2 
FSPECOPTFLAGS = -g -O0
FCPPFLAGS     = -Dlinux -Dunix 
ARFLAGS       = qs
LDFLAGS       = 
MAXPROCS      = 20

# Binaries

CC            = gcc44 -ffloat-store -pthread
CPP	      = gcc44 -E
FC            = gfortran44 -std=gnu -fno-second-underscore -fno-f2c -ffloat-store -pthread -fdump-core -fbacktrace 
FLECS         = $(CGBIN)/flecs
FCPP          = $(CGBIN)/fcpp -F
YACC          = $(CGBIN)/myacc
LEX           = flex
INSTALL	      = $(CGBIN)/install
MKPROTO	      = $(CGBIN)/mkproto
SHELL	      = /bin/sh


BIN = $(CGBIN)
INFO = $(CGD)/info

# SRCS gives all the primary source files from which everything else can be built,
# with the exception of the *.make files.

SRCS =  descrip.mms flclean.com flecs.flx flecs.txt flecsubs.flx \
	flifix.flx makefile.gen readme.txt flecsdoc.texinfo flecs.sh argc.f

all:    flecs port docs

# Construction of the normal translator.
flecs:	flecs.exe flecs.sh	
	case "$(CGPLATFORM)" in \
	  hpux ) cp flecs.sh flecs ;; \
	  * )    cp flecs.exe flecs ;; \
	esac

# Construction of the translator executable without command line processing.
flecs.exe:	flecs.o flecsubs.o argc.o
	case "$(CGPLATFORM)" in \
	  hpux ) $(FC) flecs.o flecsubs.o argc.o -o flecs.exe $(LDFLAGS) ;; \
	  * )    $(FC) flecs.o flecsubs.o -o flecs.exe $(LDFLAGS) ;; \
	esac

# Construction of profiling version of the translator on the Iris.
flecs.pc:	flecs.o flecsubs.o 
	$(FC) flecs.o flecsubs.o -o flecs.pc -p $(LDFLAGS)

# Construction of an alternate profiling version of the translator on the Iris.
flecs.pixie:	flecs
	pixie -o flecs.pixie flecs

# Suffixes are not used because they are not transitive.

flecs.o:	flecs.f
	$(FC) $(FSPECOPTFLAGS) -c flecs.f

argc.o:	argc.f
	$(FC) $(FSPECOPTFLAGS) -c argc.f

# Main program translation
flecs.f:	flecs.flx
	-flecs flecs.flx
	mv flecs.f flecs.fi
	$(FCPP) $(FCPPFLAGS) flecs.fi | egrep -v '^#' >flecs.f
	rm -f flecs.fi

flecsubs.o:	flecsubs.f
	$(FC) $(FSPECOPTFLAGS) -c flecsubs.f

# Subroutine library translation
flecsubs.f:	flecsubs.flx
	- flecs flecsubs.flx
	mv flecsubs.f flecsubs.fi
	$(FCPP) $(FCPPFLAGS) flecsubs.fi | egrep -v '^#' >flecsubs.f
	rm -f flecsubs.fi

install: flecs docs
	$(INSTALL) -m 555 -c  flecs $(BIN) 
	$(INSTALL) -m 555 -c  flecs.exe $(BIN)
	for f in flecsdoc.info ; do \
	    $(INSTALL) -m 444 -c $${f} $(INFO) ; \
	done
	cp flecsdoc.pdf flecsdoc.ps $(CGD)

# If Flecs is being installed fresh on a machine, then it has to be installed
# twice, one from the portable version, and then a second time with the C preprocessor.
# The following definition for prepare presumes that prepare will be called 
# before all.

prepare: clean
	cp flecsp.f flecs.f
	cp flecsbsp.f flecsubs.f
	$(MAKE) flecs
	rm -f $(BIN)/flecs
	rm -f $(BIN)/flecs.exe
	cp flecs $(BIN)
	cp flecs.exe $(BIN)
	touch flecs.flx flecsubs.flx

# Pieces needed for porting to other machines
port:   flecsp.f flecsbsp.f argc.f pflecs

# flecsp.f is a maximally portable version of the main program.
flecsp.f: pflecs flecs.flx  
	- rm -f flecsp.flx
	cat flecs.flx >flecsp.flx
	echo flecsp.flx | ./pflecs
	mv flecsp.f flecsp.fi
	$(FCPP) $(FCPPFLAGS) -DPORT flecsp.fi | egrep -v '^#' >flecsp.f
	rm -f flecsp.fi flecsp.flx flecsp.fli

# A maximally portable version of the subroutine library.
flecsbsp.f: pflecs flecsubs.flx
	- rm -f flecsbsp.flx
	cat flecsubs.flx >flecsbsp.flx
	echo flecsbsp.flx | ./pflecs
	mv flecsbsp.f flecsbsp.fi
	$(FCPP) $(FCPPFLAGS) -DPORT flecsbsp.fi | egrep -v '^#' >flecsbsp.f
	rm -f flecsbsp.fi flecsbsp.flx flecsbsp.fli

# An executable for FLECS that does not read the command line.
pflecs: flecs flecs.flx flecsubs.flx argc.f
	cat flecs.flx flecsubs.flx argc.f >pflecs.flx
	- ./flecs pflecs
	mv pflecs.f pflecs.fi
	$(FCPP) $(FCPPFLAGS) -DPORT pflecs.fi | egrep -v '^#' >pflecs.f
	rm -f pflecs.fi pflecs.flx pflecs.fli
	$(FC) $(FSPECOPTFLAGS) -o pflecs pflecs.f

clean:
	rm -f foo.* *.o *.fli flecs flecs.exe flecs.pixie flecs.Counts flecs.Addrs core \
	pflecs* flecsdoc.??s flecsdoc.aux flecsdoc.cp flecsdoc.fn flecsdoc.ky \
	flecsdoc.pg flecsdoc.toc flecsdoc.tp flecsdoc.vr flecsdoc flecsdoc-* \
        flecsdoc.log 

docs:	flecsdoc.pdf flecsdoc.info flecsdoc.html

flecsdoc.html: flecsdoc.texinfo
	-makeinfo --html --no-split --output=flecsdoc.html flecsdoc.texinfo

flecsdoc.info: flecsdoc.texinfo
	-makeinfo --no-split --output=flecsdoc.info flecsdoc.texinfo

flecsdoc.ps: flecsdoc.texinfo
	-rm -f flecsdoc.ps
	-tex flecsdoc.texinfo
	-texindex flecsdoc.??
	-tex flecsdoc.texinfo
	-texindex flecsdoc.??
	-tex flecsdoc.texinfo
	-dvips -f flecsdoc.dvi >flecsdoc.ps

flecsdoc.pdf: flecsdoc.ps
	ps2pdf14 flecsdoc.ps flecsdoc.pdf

# For copying to the local VAX at Bristol-Myers Squibb
tovax:  tovax.time

tovax.time: $(SRCS)
	cp $? dino
	(cd dino/; chmod u+w $?)
	touch tovax.time

# This gets the macros.
makefile: makefile.gen $(CG)/$(CGPLATFORM).make
	$(CGBIN)/fixmake $(CG)/$(CGPLATFORM) makefile.gen makefile

# Get all pieces into a shar file.
flecs.shar: all makefile
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  shar >flecs.shar \
	       $(SRCS) makefile $$makes flecs.f flecsubs.f flecsdoc.ps \
	       flecsp.f flecsubs.f flecsbsp.f pflecs.f; \
	  rm -f $$makes )

# Get all pieces into a tar file.
flecs.tar: all makefile
	( set +e; \
	  makes=`cd $(CG); /bin/ls *.make`; \
	  defdir=`pwd`; \
	  (cd $(CG); cp $$makes $$defdir); \
	  tar cvf flecs.tar \
	       $(SRCS) makefile $$makes flecs.f flecsubs.f flecsdoc.ps \
	       flecsp.f flecsubs.f flecsbsp.f pflecs.f; \
	  rm -f $$makes )

# Retrieval from the RCS directory
.DEFAULT: 
	co $<

