# $Id: rules,v 1.12 2001/08/22 17:58:22 balay Exp $ 

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


#############
shared: chkopts_basic
	-@echo making shared libraries in ${INSTALL_LIB_DIR} ;\
	cd ${INSTALL_LIB_DIR}; \
	${RM} -rf tmp; \
	mkdir tmp; \
	cd tmp; \
	for LIBNAME in ${SHLIBS} ; \
	do \
          if [ -f ${INSTALL_LIB_DIR}/$$LIBNAME.a ]; then \
	    flag=""; \
	    if [ -f ${INSTALL_LIB_DIR}/$$LIBNAME.${SLSUFFIX} ]; then \
              flag=`find ${INSTALL_LIB_DIR} -type f -name $$LIBNAME.a -newer ${INSTALL_LIB_DIR}/$$LIBNAME.${SLSUFFIX} -print`; \
	    else \
	      flag="true"; \
	    fi; \
            if [ "$$flag" != "" ]; then \
	      echo "building $$LIBNAME.${SLSUFFIX}"; \
	      ${AR} x ../$$LIBNAME.a ;\
	      ${LD} -G  -h $$LIBNAME.${SLSUFFIX} *.o  -o ../$$LIBNAME.${SLSUFFIX} ; \
	      ${RM} -f * ; \
	    fi; \
	  fi; \
	done ;\
	cd ../ ; \
	${RM} -rf tmp
#
#  Generates a shared library from any .a library; not just the PETSc ones
#  This is to allow any user to generate his or her own shared library
#
#  The ${PETSC_LIB} -lC is too tell the linker the location of the libC.a 
#  library and force it to include those symbols into the shared library.
#  Since there is no .so version of the libC.a it must be done this way.

oshared: 
	-@${RM} -rf tmp; \
	mkdir tmp; \
	cd tmp; \
        echo "building ${LIBNAME}.${SLSUFFIX}"; \
	${AR} x ../${LIBNAME}.a ;\
	${LD} -G  -h ${LIBNAME}.${SLSUFFIX} *.o  -o ../${LIBNAME}.${SLSUFFIX} \
               ${C_SYS_LIB} -lC ; \
	cd ../ ; \
	${RM} -rf tmp

