PARCH    = sun4
CC       = gcc -DPARCH_sun4 -fPIC
FC       = f77
AR       = ar
RM       = rm -f
OMAKE    = make
RANLIB   = ranlib
SHELL    = /bin/sh
CLINKER  = gcc $(COPTFLAGS)
FLINKER  = f77 $(FOPTFLAGS)

FCONF    = -DHAVE_FORTRAN_UNDERSCORE 
CONF     = -DHAVE_PETSCCONF_H $(FCONF) 

include $(PETSC_DIR)/bmake/common

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

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

.F.o: 
	$(FC)  -c $(FFLAGS)  $(FOPTFLAGS) $(CFLAGS) $*.F
.F.a: 
	$(FC)  -c $(FFLAGS)  $(FOPTFLAGS) $(CFLAGS) $*.F
	$(AR) clr $(LIBNAME) $*.o
	$(RM) $*.o
#
#   These are alternative rules for Fortran compilers that 
#  do not understand the .F suffix
#
#   Note: it is not possible to use the NAG F90 compiler with 
#  PETSc and a Fortran main problem. This is because the NAG
#  compiler actually generates a C main program while MPICH and
#  PETSc naturally expect the command line arguments to be 
#  handled in the Fortran manner, so MPICH crashes on initializing
#  the command line arguments.
#
#.F.o:
#	-$(RM) $*.f
#	-cpp $(CFLAGS) $< | grep -v '^ *#' > $*.f
#	-$(FC) -c $(FFLAGS) $(FOPTFLAGS) $*.f
#	-$(RM) $*.f
#.F.a:
#	-$(RM) $*.f
#	-cpp $(CFLAGS)  $< | grep -v '^ *#' > $*.f
#	-$(FC) -c $(FFLAGS) $(FOPTFLAGS) $*.f
#	-$(AR) cr $(LIBNAME) $*.o
#	-$(RM) $*.o	$*.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 \
	  $(AR) x ../$$LIBNAME.a ;\
	  gcc $(COPTFLAGS) -fPIC -shared  *.o  -o ../$$LIBNAME.$(SLSUFFIX) ; \
	  $(RM) -f * ; \
	done ;\
	cd ../ ; \
	$(RM) -rf tmp
