# $Id: base,v 1.36 1998/04/25 23:42:51 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.
#
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       = f77 
AR       = ar
RM       = rm -f
OMAKE    = make
RANLIB   = ranlib
SHELL    = /bin/sh
CLINKER  = gcc ${COPTFLAGS}
FLINKER  = f77 ${FOPTFLAGS}


include ${PETSC_DIR}/bmake/common

libc: ${LIBNAME}(${OBJSC} ${SOBJSC})
libadic: ${LIBNAME}(${OBJSADIC})
libf: ${LIBNAME}(${OBJSF})

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

.F.o:
	-${FC} -c ${FOPTFLAGS} ${FFLAGS} ${CPPFLAGS} $*.F

.F.a: 
	-${FC} -c ${FOPTFLAGS} ${FFLAGS} ${CPPFLAGS} $*.F
	-${AR} cr ${LIBNAME} $*.o
	-${RM} $*.o

#
#   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} ${FFLAGS} $*.F | grep -v '^C' > __$*.f
#.F.o:
#	-${RM} __$*.f
#	-${CC} -E -P -traditional-cpp -x c ${CPPFLAGS} ${FFLAGS} $*.F | grep -v '^C' > __$*.f
#	-${FC} -c ${FOPTFLAGS} __$*.f -o $*.o
#	-${RM} __$*.f
#
#.F.a:
#	-${RM} __$*.f
#	-${CC} -E -P -traditional-cpp -x c ${CPPFLAGS} ${FFLAGS} $*.F | grep -v '^C' > __$*.f
#	-${FC} -c ${FOPTFLAGS} __$*.f -o $*.o
#	-${AR} cr ${LIBNAME} $*.o
#	-${RM} __$*.f
#
SLSUFFIX = so.1.0 
shared: chkopts_basic
	-@ if [ "${BOPT}" != "Opg" ] && [ "${BOPT}" != "Opg_c++" ] \
	&&  [ "${BOPT}" != "Opg_complex" ] ; then \
	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; \
	fi
