# $Id: base,v 1.16 1998/04/26 00:58:42 balay Exp $ 


#
#
#  If you are not using the Gnu C compiler then replace the compiler name 
# gcc with your own and remove the -D__USE_FIXED_PROTOTYPES__ and the -fPIC.
#
#  Setup to use the NAG Fortran 90 compiler.
#
PARCH    = sun4
CC       = gcc -D__USE_FIXED_PROTOTYPES__ -fPIC
#
#  Indicates the version of the compiler you are using; if you do not know
#  how to get the version number then use: unknown
#
CCV      = ${CC} --version
#
FC       = f90 -f77 -mismatch -free
AR       = ar
RM       = rm -f
OMAKE    = make
RANLIB   = ranlib
SHELL    = /bin/sh
CLINKER  = gcc ${COPTFLAGS}
FLINKER  = f90 -f77 ${FOPTFLAGS}

include ${PETSC_DIR}/bmake/common

libc: ${LIBNAME}(${OBJSC})
libf: ${LIBNAME}(${OBJSF})

#############

#
#   These are alternative rules for Fortran compilers that 
#   do not understand the .F suffix

.F.f:
	-${RM} __$*.f
	-${CC} -E -P -traditional-cpp -x c ${CPPFLAGS} $*.F | grep -v '^C' > __$*.f
.F.o:
	-${RM} __$*.f
	-${CC} -E -P -traditional-cpp -x c ${CPPFLAGS} $*.F | grep -v '^C' > __$*.f
	-${FC} -c ${FOPTFLAGS} ${FFLAGS} __$*.f -o $*.o
	-${RM} __$*.f

.F.a:
	-${RM} __$*.f
	-${CC} -E -P -traditional-cpp -x c ${CPPFLAGS} $*.F |grep -v '^C' > __$*.f
	-${FC} -c ${FOPTFLAGS} ${FFLAGS} __$*.f -o $*.o
	-${AR} cr ${LIBNAME} $*.o
	-${RM} __$*.f

SLSUFFIX = so.1.0 
shared: chkopts_basic
	-@ echo making shared libraries in ${LDIR} ;\
	cd ${LDIR}; \
	${RM} -rf tmp; \
	mkdir tmp; \
	cd tmp; \
	for LIBNAME in ${SHLIBS} ; \
	do \
	  flag=""; \
	  if [ -f ${LDIR}/$$LIBNAME.${SLSUFFIX} ]; then \
              flag=`find ${LDIR} -type f -name $$LIBNAME.a -newer ${LDIR}/$$LIBNAME.${SLSUFFIX} -print`; \
	  else \
	      flag="true"; \
	  fi; \
          if [ "$$flag" != "" ]; then \
	    echo "building $$LIBNAME.${SLSUFFIX}"; \
	    ${AR} x ../$$LIBNAME.a ;\
	    gcc ${COPTFLAGS} -fPIC -shared  *.o  -o ../$$LIBNAME.${SLSUFFIX} ; \
	    ${RM} -f * ; \
	  fi; \
	done; \
	cd ../ ; \
	${RM} -rf tmp
