###############################################
# This makefile makes standard macro definitions
# for builds, and system dependent ones from 
# include files in subdir systems.  
#
# Terry Clark, 11-16-99, twclark@cs.uchicago.edu
###############################################

# Can override this set of macros in the following,
# system-dependent section.
ECHO	 = echo
CPP      = /usr/lib/cpp -P
INSTALL  = @$(ECHO) $@ is built
MKDIR    = mkdir
MOVE	 = mv -f
GZIP	 = gzip
PFBINDIR = $(PLANGROOT)/bin
PCBINDIR = $(PLANGROOT)/bin
PCC	 = $(PCBINDIR)/pcc
PFC	 = $(PFBINDIR)/pfc
RM	 = /bin/rm -f
CP	 = cp -f
CD	 = cd
TOUCH	 = touch
DATE	 = date
RMDIR	 = /bin/rm -rf
YACC     = yacc
CC	 = gcc
FC	 = f77
LATEX	 = latex
TEX	 = tex
DVIPS	 = dvips
BIBTEX	 = bibtex
LGRIND	 = lgrind
LGRINDFLAGS =  -i

# CFLAGS   :  flags to the C compiler.
# COPTFLAGS:  C optimization flags.
# CPP      :  the preprocessor (used for .C, .F and .PF)
# CPPFLAG  :  flags to the preprocessor.
# DEFINES  :
# FFLAGS   :  flags to provide the Fortran compiler.
# FOPTFLAGS:  Fortran optimization flags.
# INCDIRS  :  look in dirs for include files, prior to usual places.
# INSTALL  :  print a confirmation.
# LDFLAGS  :  flags for the link step.
# LIBDIRS  :  directories to be searched for libraries; -L<dirname>
# LIBS     :  libraries to be linked against;  -l<libname>


# System-dependent macros.
#
include $(PLANGROOT)/include/system.h

CPPFLAGS = $(INCDIRS) $(DEFINES) 
CFLAGS 	 = $(INCDIRS) $(DEFINES) $(COPTFLAGS) $(COPTIONS) $(CDEBUG)
FFLAGS   = $(INCDIRS)  $(FOPTFLAGS) $(FOPTIONS) $(FDEBUG) 
LDFLAGS  := $(LDFLAGS) $(LDOPTIONS) $(LIBDIRS)


ifdef EXPLICITF
   FCONVERT = $(CPP) $(CPPFLAGS) $*.F > $*.f
endif
PFCONVERT = $(CPP) $(CPPFLAGS) $*.PF > $*.pf
#PFCONVERT = $(CPP) $(CPPFLAGS) $< > $*.pf


# suffix rules
#
.SUFFIXES:      .pf .PF .F .f .pc .c .s .o .tex .dvi .ps
.c.o:; $(CC) $(CFLAGS) -c $*.c
.f.o:;	$(FC) $(FFLAGS) -c $*.f
	@$(RM) $*.f
.pf.f:; @echo Converting $*.pf '->' $*.f
	@$(PFCONVERT)
	@echo "    with PFFLAGS = " $(PFFLAGS)
	$(PFC) $(PFFLAGS) $*.pf
.pc.c:; $(PCC) $(PCFLAGS) $*.pc
.pf.o:; @echo Converting $*.pf '->' $*.o
	@$(PFCONVERT)
	$(PFC) $(PFFLAGS) $*.pf
	$(FC) $(FFLAGS) -c $*.f
	@$(RM) $*.f
.pc.o:; @echo Converting $*.pc '->' $*.o
	$(PCC) $(PCFLAGS) $*.pc

ifdef EXPLICITF
# needed on machines where FCC does not preprocess .F files
#
.F.o:;  @echo Converting $*.F '->' $*.o
	@$(FCONVERT)
	$(FC) $(FFLAGS) -c  $*.f
	@$(RM) $*.f

.F.f:; @echo Converting $*.F '->' $*.f
	@$(FCONVERT)
endif

.PF.pf:;@echo Converting $*.PF '->' $*.pf
	@echo "    with CPPFLAGS = " $(CPPFLAGS)
	@$(PFCONVERT)
.PF.f:; @echo Converting $*.PF '->' $*.f
	@echo "    with CPPFLAGS = " $(CPPFLAGS)
	@$(PFCONVERT)
	@echo "    with PFFLAGS = " $(PFFLAGS)
	$(PFC) $(PFFLAGS) $*.pf
	@$(RM) $*.pf
.PF.o:; @echo Converting $*.PF '->' $*.o
	@echo "    with CPPFLAGS = " $(CPPFLAGS)
	@$(PFCONVERT)
	@echo "    with PFFLAGS = " $(PFFLAGS)
	$(PFC) $(PFFLAGS) $*.pf
	$(PFC) $(PFFLAGS) $*.pf
	$(FC) $(FFLAGS) -c $*.f
	@$(RM) $*.f $*.pf

.tex.dvi:
	$(LATEX) $*.tex
.dvi.ps:
	$(DVIPS) $*.dvi -o $*.ps

# The following line has a tab to make an empty rule.
(%.o):	%.o
 
