Blame src/openpa/confdb/aclocal_shl.m4

Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Definitions for creating shared libraries
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl The purpose of these definitions is to provide common support for 
Packit Service c5cf8c
dnl shared libraries, with *or without* the use of the GNU Libtool package.
Packit Service c5cf8c
dnl For many of our important platforms, the Libtool approach is overkill,
Packit Service c5cf8c
dnl and can be particularly painful for developers.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl To use libtool, you need macros that are defined by libtool for libtool
Packit Service c5cf8c
dnl Don't even think about the consequences of this for updating and for
Packit Service c5cf8c
dnl using user-versions of libtool :(
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl !!!!!!!!!!!!!!!!!!!!!
Packit Service c5cf8c
dnl libtool requires ac 2.50 !!!!!!!!!!!!!!!!!
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl builtin(include,libtool.m4)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl/*D
Packit Service c5cf8c
dnl PAC_ARG_SHAREDLIBS - Add --enable-sharedlibs=kind to configure.
Packit Service c5cf8c
dnl 
Packit Service c5cf8c
dnl Synopsis:
Packit Service c5cf8c
dnl PAC_ARG_SHAREDLIBS
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Output effects:
Packit Service c5cf8c
dnl Adds '--enable-sharedlibs=kind' to the command line.  If this is enabled,
Packit Service c5cf8c
dnl then based on the value of 'kind', programs are selected for the 
Packit Service c5cf8c
dnl names 'CC_SHL' and 'CC_LINK_SHL' that configure will substitute for in
Packit Service c5cf8c
dnl 'Makefile.in's.  These symbols are generated by 'simplemake' when
Packit Service c5cf8c
dnl shared library support is selected.
Packit Service c5cf8c
dnl The variable 'C_LINKPATH_SHL' is set to the option to specify the 
Packit Service c5cf8c
dnl path to search at runtime for libraries (-rpath in gcc/GNU ld).
Packit Service c5cf8c
dnl This can be turned off with --disable-rpath , which is appropriate
Packit Service c5cf8c
dnl for libraries and for executables that may be installed in different
Packit Service c5cf8c
dnl locations.
Packit Service c5cf8c
dnl The variable 'SHLIB_EXT' is set to the extension used by shared 
Packit Service c5cf8c
dnl libraries; under most forms of Unix, this is 'so'; under Mac OS/X, this
Packit Service c5cf8c
dnl is 'dylib', and under Windows (including cygwin), this is 'dll'.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Supported values of 'kind' include \:
Packit Service c5cf8c
dnl+    gcc - Use gcc to create both shared objects and libraries
Packit Service c5cf8c
dnl.    osx-gcc - Use gcc on Mac OS/X to create both shared objects and
Packit Service c5cf8c
dnl               libraries
Packit Service c5cf8c
dnl.    solaris-cc - Use native Solaris cc to create shared objects and 
Packit Service c5cf8c
dnl               libraries
Packit Service c5cf8c
dnl.    cygwin-gcc - Use gcc on Cygwin to create shared objects and libraries
Packit Service c5cf8c
dnl-    none - The same as '--disable-sharedlibs'
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Others will be added as experience dictates.  Likely names are
Packit Service c5cf8c
dnl + libtool - For general GNU libtool
Packit Service c5cf8c
dnl - linux-pgcc - For Portland group under Linux
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Notes:
Packit Service c5cf8c
dnl Shared libraries are only partially implemented.  Additional symbols
Packit Service c5cf8c
dnl will probably be defined, including symbols to specify how shared library
Packit Service c5cf8c
dnl search paths are specified and how shared library names are set.
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_ARG_SHAREDLIBS],[
Packit Service c5cf8c
Packit Service c5cf8c
AC_ARG_ENABLE(shared,
Packit Service c5cf8c
	AC_HELP_STRING([--enable-shared], [Enable shared library builds]),,
Packit Service c5cf8c
	enable_shared=no)
Packit Service c5cf8c
Packit Service c5cf8c
AC_ARG_ENABLE(rpath,
Packit Service c5cf8c
	AC_HELP_STRING([--enable-rpath],
Packit Service c5cf8c
		[Determine whether the rpath is set when programs are
Packit Service c5cf8c
		compiled and linked when shared libraries are built.
Packit Service c5cf8c
		The default is yes; use --disable-rpath to turn this
Packit Service c5cf8c
		feature off; in that case, shared libraries will be
Packit Service c5cf8c
		found according to the rules for your system (e.g., in
Packit Service c5cf8c
		LD_LIBRARY_PATH)]),,enable_rpath=yes)
Packit Service c5cf8c
Packit Service c5cf8c
AC_ARG_ENABLE(sharedlibs,
Packit Service c5cf8c
[  --enable-sharedlibs=kind - Enable shared libraries.  kind may be
Packit Service c5cf8c
        gcc     - Standard gcc and GNU ld options for creating shared libraries
Packit Service c5cf8c
        osx-gcc - Special options for gcc needed only on OS/X
Packit Service c5cf8c
        solaris-cc - Solaris native (SPARC) compilers for 32 bit systems
Packit Service c5cf8c
        cygwin-gcc - Special options for gcc needed only for cygwin
Packit Service c5cf8c
        none    - same as --disable-sharedlibs
Packit Service c5cf8c
      Only gcc, osx-gcc, and solaris-cc are currently supported
Packit Service c5cf8c
],,enable_sharedlibs=default)
Packit Service c5cf8c
Packit Service c5cf8c
if test "$enable_sharedlibs" = "default" ; then
Packit Service c5cf8c
   if test "$enable_shared" = "yes" ; then
Packit Service c5cf8c
      AS_CASE([$host],
Packit Service c5cf8c
	      [*-*-darwin*], [enable_sharedlibs=gcc-osx],
Packit Service c5cf8c
	      [*-*-cygwin*|*-*-mingw*|*-*-pw32*|*-*-cegcc*], [enable_sharedlibs=cygwin-gcc],
Packit Service c5cf8c
	      [*-*-sunos*], [enable_sharedlibs=solaris-gcc],
Packit Service c5cf8c
	      [enable_sharedlibs=gcc])
Packit Service c5cf8c
   else
Packit Service c5cf8c
      enable_sharedlibs=none
Packit Service c5cf8c
   fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
# If --enable-sharedlibs is given, but --enable-shared is not, throw
Packit Service c5cf8c
# an error
Packit Service c5cf8c
if test "$enable_sharedlibs" != "no" -a "$enable_sharedlibs" != "none" ; then
Packit Service c5cf8c
   if test "$enable_shared" = "no" ; then
Packit Service c5cf8c
      AC_MSG_ERROR([--enable-sharedlibs cannot be used without --enable-shared])
Packit Service c5cf8c
   fi
Packit Service c5cf8c
fi
Packit Service c5cf8c
Packit Service c5cf8c
CC_SHL=true
Packit Service c5cf8c
C_LINK_SHL=true
Packit Service c5cf8c
C_LINKPATH_SHL=""
Packit Service c5cf8c
SHLIB_EXT=unknown
Packit Service c5cf8c
SHLIB_FROM_LO=no
Packit Service c5cf8c
SHLIB_INSTALL='$(INSTALL_PROGRAM)'
Packit Service c5cf8c
case "$enable_sharedlibs" in 
Packit Service c5cf8c
    no|none)
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    gcc-osx|osx-gcc)
Packit Service c5cf8c
    AC_MSG_RESULT([Creating shared libraries using GNU for Mac OSX])
Packit Service c5cf8c
    C_LINK_SHL='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace'
Packit Service c5cf8c
    CC_SHL='${CC} -fPIC'
Packit Service c5cf8c
    # No way in osx to specify the location of the shared libraries at link
Packit Service c5cf8c
    # time (see the code in createshlib in mpich/src/util)
Packit Service c5cf8c
    # As of 10.5, -Wl,-rpath,dirname should work .  The dirname 
Packit Service c5cf8c
    # must be a single directory, not a colon-separated list (use multiple
Packit Service c5cf8c
    # -Wl,-rpath,path for each of the paths in the list).  However, os x
Packit Service c5cf8c
    # apparently records the library full path, so rpath isn't as useful
Packit Service c5cf8c
    # as it is on other systems
Packit Service c5cf8c
    C_LINKPATH_SHL=""
Packit Service c5cf8c
    SHLIB_EXT="dylib"
Packit Service c5cf8c
    enable_sharedlibs="osx-gcc"
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    gcc)
Packit Service c5cf8c
    AC_MSG_RESULT([Creating shared libraries using GNU])
Packit Service c5cf8c
    # Not quite right yet.  See mpich/util/makesharedlib
Packit Service c5cf8c
    # Use syntax that works in both Make and the shell
Packit Service c5cf8c
    #C_LINK_SHL='${CC} -shared -Wl,-r'
Packit Service c5cf8c
    C_LINK_SHL='${CC} -shared'
Packit Service c5cf8c
    # For example, include the libname as ${LIBNAME_SHL}
Packit Service c5cf8c
    #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>'
Packit Service c5cf8c
    # May need -fPIC .  Test to see which one works.
Packit Service c5cf8c
    for sh_arg in "-fPIC" "-fpic" "-KPIC" ; do
Packit Service c5cf8c
        PAC_C_CHECK_COMPILER_OPTION($sh_arg,works=yes,works=no)
Packit Service c5cf8c
        if test "$works" = "yes" ; then
Packit Service c5cf8c
           CC_SHL="${CC} ${sh_arg}"
Packit Service c5cf8c
	   break
Packit Service c5cf8c
	fi
Packit Service c5cf8c
    done
Packit Service c5cf8c
    if test "$works" != "yes"; then
Packit Service c5cf8c
       AC_MSG_ERROR([Cannot build shared libraries with this compiler])
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    # This used to have -Wl,-rpath earlier, but that causes problems
Packit Service c5cf8c
    # on many systems.
Packit Service c5cf8c
    if test $enable_rpath = "yes" ; then
Packit Service c5cf8c
        C_LINKPATH_SHL="-Wl,-rpath,"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    SHLIB_EXT=so
Packit Service c5cf8c
    # We need to test that this isn't osx.  The following is a 
Packit Service c5cf8c
    # simple hack
Packit Service c5cf8c
    osname=`uname -s`
Packit Service c5cf8c
    case $osname in 
Packit Service c5cf8c
        *Darwin*|*darwin*)
Packit Service c5cf8c
	AC_MSG_ERROR([You must specify --enable-sharedlibs=osx-gcc for Mac OS/X])
Packit Service c5cf8c
        ;;	
Packit Service c5cf8c
        *CYGWIN*|*cygwin*)
Packit Service c5cf8c
	AC_MSG_ERROR([You must specify --enable-sharedlibs=cygwin-gcc for Cygwin])
Packit Service c5cf8c
	;;
Packit Service c5cf8c
	*SunOS*)
Packit Service c5cf8c
	AC_MSG_ERROR([You must specify --enable-sharedlibs=solaris-gcc for Solaris with gcc])
Packit Service c5cf8c
	;;
Packit Service c5cf8c
    esac
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
Packit Service c5cf8c
    cygwin|cygwin-gcc|gcc-cygwin)
Packit Service c5cf8c
    AC_MSG_RESULT([Creating shared libraries using GNU under CYGWIN])
Packit Service c5cf8c
    C_LINK_SHL='${CC} -shared'
Packit Service c5cf8c
    CC_SHL='${CC}'
Packit Service c5cf8c
    # DLL Libraries need to be in the user's path (!)
Packit Service c5cf8c
    C_LINKPATH_SHL=""
Packit Service c5cf8c
    SHLIB_EXT="dll"
Packit Service c5cf8c
    enable_sharedlibs="cygwin-gcc"
Packit Service c5cf8c
    ;;	
Packit Service c5cf8c
Packit Service c5cf8c
    libtool)
Packit Service c5cf8c
    # set TRY_LIBTOOL to yes to experiment with libtool.  You are on your
Packit Service c5cf8c
    # own - only send fixes, not bug reports.
Packit Service c5cf8c
    if test "$TRY_LIBTOOL" != yes ; then
Packit Service c5cf8c
        AC_MSG_ERROR([Creating shared libraries using libtool not yet supported])
Packit Service c5cf8c
    else
Packit Service c5cf8c
    # Using libtool requires a heavy-weight process to test for 
Packit Service c5cf8c
    # various stuff that libtool needs.  Without this, you'll get a
Packit Service c5cf8c
    # bizarre error message about libtool being unable to find
Packit Service c5cf8c
    # configure.in or configure.ac (!)
Packit Service c5cf8c
        # Libtool expects to see at least enable-shared.
Packit Service c5cf8c
        if test "X$enable_shared" = "X" ; then enable_shared=yes ; fi
Packit Service c5cf8c
	# Initialize libtool
Packit Service c5cf8c
	# This works, but libtool version 2 places the object files
Packit Service c5cf8c
	# in a different place, making it harder to integrate with
Packit Service c5cf8c
	# our base approach.  Disabling for now
Packit Service c5cf8c
	dnl LT_PREREQ([2.2.6])
Packit Service c5cf8c
        dnl LT_INIT([disable-shared])
Packit Service c5cf8c
	AC_MSG_ERROR([To use this test verison, edit aclocal_shl.m4])
Packit Service c5cf8c
        # Likely to be
Packit Service c5cf8c
        # either CC or CC_SHL is libtool $cc
Packit Service c5cf8c
        CC_SHL='${LIBTOOL} --mode=compile ${CC}'
Packit Service c5cf8c
        # CC_LINK_SHL includes the final installation path
Packit Service c5cf8c
        # For many systems, the link may need to include *all* libraries
Packit Service c5cf8c
        # (since many systems don't allow any unsatisfied dependencies)
Packit Service c5cf8c
        # We need to give libtool the .lo file, not the .o files
Packit Service c5cf8c
        SHLIB_FROM_LO=yes
Packit Service c5cf8c
        # We also need to add -no-undefined when the compiler is gcc and
Packit Service c5cf8c
        # we are building under cygwin
Packit Service c5cf8c
        sysname=`uname -s | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`
Packit Service c5cf8c
        isCygwin=no
Packit Service c5cf8c
        case "$sysname" in 
Packit Service c5cf8c
 	*CYGWIN*) isCygwin=yes ;;
Packit Service c5cf8c
        esac
Packit Service c5cf8c
        if test "$isCygwin" = yes ; then
Packit Service c5cf8c
            C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -no-undefined -rpath ${libdir}'
Packit Service c5cf8c
        else
Packit Service c5cf8c
            C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -rpath ${libdir}'
Packit Service c5cf8c
        fi
Packit Service c5cf8c
	if test $enable_rpath = "yes" ; then
Packit Service c5cf8c
            C_LINKPATH_SHL="-rpath "
Packit Service c5cf8c
        fi
Packit Service c5cf8c
        # We also need a special install process with libtool.  Note that this
Packit Service c5cf8c
        # will also install the static libraries
Packit Service c5cf8c
        SHLIB_INSTALL='$(LIBTOOL) --mode=install $(INSTALL_PROGRAM)'
Packit Service c5cf8c
        # Note we may still need to add
Packit Service c5cf8c
        #'$(LIBTOOL) --mode=finish $(libdir)'
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Other, such as solaris-cc
Packit Service c5cf8c
    solaris|solaris-cc)
Packit Service c5cf8c
    AC_MSG_RESULT([Creating shared libraries using Solaris])
Packit Service c5cf8c
    # pic32 is appropriate for both 32 and 64 bit Solaris
Packit Service c5cf8c
    C_LINK_SHL='${CC} -G -xcode=pic32'
Packit Service c5cf8c
    CC_SHL='${CC} -xcode=pic32'
Packit Service c5cf8c
    if test $enable_rpath = "yes" ; then
Packit Service c5cf8c
        C_LINKPATH_SHL="-R"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    SHLIB_EXT=so
Packit Service c5cf8c
    enable_sharedlibs="solaris-cc"
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
Packit Service c5cf8c
    solaris-gcc)
Packit Service c5cf8c
    # This is the same as gcc, except for the C_LINKPATH_SHL
Packit Service c5cf8c
    AC_MSG_RESULT([Creating shared libraries using Solaris with gcc])
Packit Service c5cf8c
    C_LINK_SHL='${CC} -shared'
Packit Service c5cf8c
    CC_SHL='${CC} -fPIC'
Packit Service c5cf8c
    if test $enable_rpath = "yes" ; then
Packit Service c5cf8c
        C_LINKPATH_SHL="-R"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    SHLIB_EXT=so
Packit Service c5cf8c
    enable_sharedlibs="solaris-gcc"
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
Packit Service c5cf8c
    linuxppc-xlc)
Packit Service c5cf8c
    # This is only the beginning of xlc support, thanks to andy@vpac.org
Packit Service c5cf8c
    CC_SHL='${CC} -qmkshrobj'
Packit Service c5cf8c
    # More recent versions allow multiple args, separated by commas
Packit Service c5cf8c
    if test $enable_rpath = "yes" ; then
Packit Service c5cf8c
        C_LINKPATH_SHL="-Wl,-rpath,"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    #C_LINKPATH_SHL="-Wl,-rpath -Wl,"
Packit Service c5cf8c
    C_LINK_SHL='${CC} -shared -qmkshrobj'
Packit Service c5cf8c
    SHLIB_EXT=so
Packit Service c5cf8c
    # Note that the full line should be more like
Packit Service c5cf8c
    # $CLINKER -shared -qmkshrobj -Wl,-h,$libbase.$slsuffix -o ../shared/$libbase.$slsuffix *.o $OtherLibs
Packit Service c5cf8c
    # for the appropriate values of $libbase and $slsuffix
Packit Service c5cf8c
    # The -h name sets the name of the object; this is necessary to
Packit Service c5cf8c
    # ensure that the dynamic linker can find the proper shared library.
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
Packit Service c5cf8c
    *)
Packit Service c5cf8c
    AC_MSG_ERROR([Unknown value $enable_sharedlibs for enable-sharedlibs.  Values should be gcc or osx-gcc])
Packit Service c5cf8c
    enable_sharedlibs=no
Packit Service c5cf8c
    ;;  
Packit Service c5cf8c
esac
Packit Service c5cf8c
# Check for the shared-library extension
Packit Service c5cf8c
PAC_CC_SHLIB_EXT
Packit Service c5cf8c
dnl
Packit Service c5cf8c
AC_SUBST(CC_SHL)
Packit Service c5cf8c
AC_SUBST(C_LINK_SHL)
Packit Service c5cf8c
AC_SUBST(C_LINKPATH_SHL)
Packit Service c5cf8c
AC_SUBST(SHLIB_EXT)
Packit Service c5cf8c
AC_SUBST(SHLIB_FROM_LO)
Packit Service c5cf8c
AC_SUBST(SHLIB_INSTALL)
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl /*D
Packit Service c5cf8c
dnl PAC_xx_SHAREDLIBS - Get compiler and linker for shared libraries
Packit Service c5cf8c
dnl These routines may be used to determine the compiler and the
Packit Service c5cf8c
dnl linker to be used in creating shared libraries
Packit Service c5cf8c
dnl Rather than set predefined variable names, they set an argument 
Packit Service c5cf8c
dnl (if provided)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Synopsis
Packit Service c5cf8c
dnl PAC_CC_SHAREDLIBS(type,CCvar,CLINKvar)
Packit Service c5cf8c
dnl D*/
Packit Service c5cf8c
AC_DEFUN([PAC_CC_SHAREDLIBS],
Packit Service c5cf8c
[
Packit Service c5cf8c
pac_kinds=$1
Packit Service c5cf8c
ifelse($1,,[
Packit Service c5cf8c
    pac_prog=""
Packit Service c5cf8c
    AC_CHECK_PROG(pac_prog,gcc,yes,no)
Packit Service c5cf8c
    # If we are gcc but OS X, set the special type
Packit Service c5cf8c
    # We need a similar setting for cygwin
Packit Service c5cf8c
    if test "$pac_prog" = yes ; then 
Packit Service c5cf8c
        osname=`uname -s`
Packit Service c5cf8c
    	case $osname in 
Packit Service c5cf8c
             *Darwin*|*darwin*) pac_kinds=gcc-osx
Packit Service c5cf8c
             ;;				
Packit Service c5cf8c
	     *) pac_kinds=gcc
Packit Service c5cf8c
	     ;;
Packit Service c5cf8c
	esac
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    pac_prog=""
Packit Service c5cf8c
    AC_CHECK_PROG(pac_prog,libtool,yes,no)
Packit Service c5cf8c
    if test "$pac_prog" = yes ; then pac_kinds="$pac_kinds libtool" ; fi
Packit Service c5cf8c
])
Packit Service c5cf8c
for pac_arg in $pac_kinds ; do
Packit Service c5cf8c
    case $pac_arg in 
Packit Service c5cf8c
    gcc)
Packit Service c5cf8c
    # For example, include the libname as ${LIBNAME_SHL}
Packit Service c5cf8c
    #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>'
Packit Service c5cf8c
    pac_cc_sharedlibs='gcc -shared'
Packit Service c5cf8c
    # Make sure we select the correct fpic option
Packit Service c5cf8c
    PAC_C_CHECK_COMPILER_OPTION(-fPIC,fPIC_OK=yes,fPIC_OK=no)
Packit Service c5cf8c
    if test "$fPIC_OK" != yes ; then
Packit Service c5cf8c
        PAC_C_CHECK_COMPILER_OPTION(-fpic,fpic_ok=yes,fpic_ok=no)
Packit Service c5cf8c
        if test "$fpic_ok" != yes ; then
Packit Service c5cf8c
	     AC_MSG_ERROR([Neither -fpic nor -fPIC accepted by $CC])
Packit Service c5cf8c
        else
Packit Service c5cf8c
	     pac_cc_sharedlibs="$pac_cc_sharedlibs -fpic"
Packit Service c5cf8c
        fi
Packit Service c5cf8c
    else
Packit Service c5cf8c
        pac_cc_sharedlibs="$pac_cc_sharedlibs -fPIC"
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    pac_clink_sharedlibs='gcc -shared'
Packit Service c5cf8c
    pac_type_sharedlibs=gcc
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    gcc-osx|osx-gcc)
Packit Service c5cf8c
    pac_clink_sharedlibs='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace'
Packit Service c5cf8c
    pac_cc_sharedlibs='${CC} -fPIC'
Packit Service c5cf8c
    pac_type_sharedlibs=gcc-osx
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    libtool)
Packit Service c5cf8c
    AC_CHECK_PROGS(LIBTOOL,libtool,false)
Packit Service c5cf8c
    if test "$LIBTOOL" = "false" ; then
Packit Service c5cf8c
	AC_MSG_WARN([Could not find libtool])
Packit Service c5cf8c
    else
Packit Service c5cf8c
        # Likely to be
Packit Service c5cf8c
        # either CC or CC_SHL is libtool $cc
Packit Service c5cf8c
        pac_cc_sharedlibs'${LIBTOOL} -mode=compile ${CC}'
Packit Service c5cf8c
        pac_clink_sharedlibs='${LIBTOOL} -mode=link ${CC} -rpath ${libdir}'
Packit Service c5cf8c
	pac_type_sharedlibs=libtool
Packit Service c5cf8c
    fi
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    *)
Packit Service c5cf8c
    ;;
Packit Service c5cf8c
    esac
Packit Service c5cf8c
    if test -n "$pac_cc_sharedlibs" ; then break ; fi
Packit Service c5cf8c
done
Packit Service c5cf8c
if test -z "$pac_cc_sharedlibs" ; then pac_cc_sharedlibs=true ; fi
Packit Service c5cf8c
if test -z "$pac_clink_sharedlibs" ; then pac_clink_sharedlibs=true ; fi
Packit Service c5cf8c
ifelse($2,,CC_SHL=$pac_cc_sharedlibs,$2=$pac_cc_sharedlibs)
Packit Service c5cf8c
ifelse($3,,C_LINK_SHL=$pac_clink_sharedlibs,$3=$pac_clink_sharedlibs)
Packit Service c5cf8c
ifelse($4,,SHAREDLIB_TYPE=$pac_type_sharedlibs,$4=$pac_type_sharedlibs)
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl This macro ensures that all of the necessary substitutions are 
Packit Service c5cf8c
dnl made by any subdirectory configure (which may simply SUBST the
Packit Service c5cf8c
dnl necessary values rather than trying to determine them from scratch)
Packit Service c5cf8c
dnl This is a more robust (and, in the case of libtool, only 
Packit Service c5cf8c
dnl managable) method.
Packit Service c5cf8c
AC_DEFUN([PAC_CC_SUBDIR_SHLIBS],[
Packit Service c5cf8c
	AC_SUBST(CC_SHL)
Packit Service c5cf8c
        AC_SUBST(C_LINK_SHL)
Packit Service c5cf8c
        AC_SUBST(LIBTOOL)
Packit Service c5cf8c
        AC_SUBST(ENABLE_SHLIB)
Packit Service c5cf8c
        AC_SUBST(SHLIB_EXT)
Packit Service c5cf8c
	if test "$ENABLE_SHLIB" = "libtool" ; then
Packit Service c5cf8c
	    if test -z "$LIBTOOL" ; then
Packit Service c5cf8c
		AC_MSG_WARN([libtool selected for shared library support but LIBTOOL is not defined])
Packit Service c5cf8c
            fi
Packit Service c5cf8c
	    # Libtool needs master_top_builddir
Packit Service c5cf8c
	    if test "X$master_top_builddir" = "X" ; then
Packit Service c5cf8c
	        AC_MSG_ERROR([Libtool requires master_top_builddir - check configure.ac sources])
Packit Service c5cf8c
	    fi
Packit Service c5cf8c
	    AC_SUBST(master_top_builddir)
Packit Service c5cf8c
	fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl PAC_CC_SHLIB_EXT - get the extension for shared libraries
Packit Service c5cf8c
dnl Set the variable SHLIB_EXT if it is other than unknown.
Packit Service c5cf8c
AC_DEFUN([PAC_CC_SHLIB_EXT],[
Packit Service c5cf8c
# Not all systems use .so as the extension for shared libraries (cygwin
Packit Service c5cf8c
# and OSX are two important examples).  If we did not set the SHLIB_EXT,
Packit Service c5cf8c
# then try and determine it.  We need this to properly implement
Packit Service c5cf8c
# clean steps that look for libfoo.$SHLIB_EXT .
Packit Service c5cf8c
if test "$SHLIB_EXT" = "unknown" ; then
Packit Service c5cf8c
    osname=`uname -s`
Packit Service c5cf8c
    case $osname in 
Packit Service c5cf8c
        *Darwin*|*darwin*) SHLIB_EXT=dylib
Packit Service c5cf8c
        ;;	
Packit Service c5cf8c
        *CYGWIN*|*cygwin*) SHLIB_EXT=dll
Packit Service c5cf8c
        ;;
Packit Service c5cf8c
	*Linux*|*LINUX*|*SunOS*) SHLIB_EXT=so
Packit Service c5cf8c
	;;
Packit Service c5cf8c
   esac
Packit Service c5cf8c
fi
Packit Service c5cf8c
])
Packit Service c5cf8c
Packit Service c5cf8c
dnl PAC_COMPILER_SHLIB_FLAGS(compiler-var,output-file)
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Uses confdb/config.rpath to determine important linking flags and
Packit Service c5cf8c
dnl information.  This is mainly intended to support the compiler wrapper
Packit Service c5cf8c
dnl scripts in MPICH ("mpicc" and friends) which cannot directly use libtool to
Packit Service c5cf8c
dnl handle linking.  MPICH's compiler wrappers attempt to link executables with
Packit Service c5cf8c
dnl an rpath by default.  The resulting variable assignment statements will be
Packit Service c5cf8c
dnl placed into "output-file", which is then suitable for AC_SUBST_FILE or
Packit Service c5cf8c
dnl sourcing in a shell script (including configure itself).
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl This macro assumes that the basic tests associated with "compiler-var" have
Packit Service c5cf8c
dnl been run already, but does not AC_REQUIRE them in order to prevent problems
Packit Service c5cf8c
dnl with "expanded before required" when requiring the AC_PROG_{CC,F77,FC,CXX}
Packit Service c5cf8c
dnl macros.
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl Example usage:
Packit Service c5cf8c
dnl
Packit Service c5cf8c
dnl ----8<----
Packit Service c5cf8c
dnl # compute flags for linking executables against shared libraries when using
Packit Service c5cf8c
dnl # the modern Fortran compiler ($FC).
Packit Service c5cf8c
dnl PAC_COMPILER_SHLIB_FLAGS([FC],[src/env/fc_shlib.conf])
Packit Service c5cf8c
dnl ----8<----
Packit Service c5cf8c
AC_DEFUN([PAC_COMPILER_SHLIB_FLAGS],[
Packit Service c5cf8c
AC_REQUIRE_AUX_FILE([config.rpath])
Packit Service c5cf8c
AC_REQUIRE([AC_CANONICAL_HOST])
Packit Service c5cf8c
Packit Service c5cf8c
# It appears that the libtool dynamic linking strategy on Darwin is this:
Packit Service c5cf8c
# 1. Link all shared libs with "-install_name /full/path/to/libfoo.dylib"
Packit Service c5cf8c
# 2. Don't do anything special when linking programs, since it seems that the
Packit Service c5cf8c
# darwin dynamic linker will always use the "install_name" field from the lib
Packit Service c5cf8c
# that was found at program link-time.  (CONFIRMED) This is in opposition to
Packit Service c5cf8c
# the way that Linux does it, where specifying a "-rpath" argument at program
Packit Service c5cf8c
# link-time is important.
Packit Service c5cf8c
#
Packit Service c5cf8c
# There is an alternative darwin strategy for versions
Packit Service c5cf8c
# >= 10.5, see this: http://www.cmake.org/pipermail/cmake/2010-August/038970.html
Packit Service c5cf8c
# (goodell@ 2011-06-17)
Packit Service c5cf8c
Packit Service c5cf8c
AC_MSG_CHECKING([for shared library (esp. rpath) characteristics of $1])
Packit Service c5cf8c
Packit Service c5cf8c
# unfortunately, config.rpath expects the compiler in question is always CC and
Packit Service c5cf8c
# uses several other environment variables as input
Packit Service c5cf8c
PAC_PUSH_FLAG([CC])
Packit Service c5cf8c
PAC_PUSH_FLAG([GCC])
Packit Service c5cf8c
PAC_PUSH_FLAG([LD])
Packit Service c5cf8c
# these two don't currently get overridden, but we push/pop them for safety in
Packit Service c5cf8c
# case they do in the future
Packit Service c5cf8c
PAC_PUSH_FLAG([LDFLAGS])
Packit Service c5cf8c
PAC_PUSH_FLAG([with_gnu_ld])
Packit Service c5cf8c
Packit Service c5cf8c
# set the temporary override values (if any)
Packit Service c5cf8c
m4_case([$1],
Packit Service c5cf8c
[CC],
Packit Service c5cf8c
    [:], dnl do nothing special for CC, values are already correct
Packit Service c5cf8c
[F77],
Packit Service c5cf8c
    [CC="$$1"
Packit Service c5cf8c
     GCC="$G77"
Packit Service c5cf8c
     LD="$LD_F77"],
Packit Service c5cf8c
[FC],
Packit Service c5cf8c
    [CC="$$1"
Packit Service c5cf8c
     GCC="$GCC_FC"
Packit Service c5cf8c
     LD="$LD_FC"],
Packit Service c5cf8c
[CXX],
Packit Service c5cf8c
    [CC="$$1"
Packit Service c5cf8c
     GCC="$GXX"
Packit Service c5cf8c
     LD="$LD_CXX"],
Packit Service c5cf8c
[m4_fatal([unknown compiler argument "$1"])])
Packit Service c5cf8c
Packit Service c5cf8c
# ensure the values are available to the script
Packit Service c5cf8c
export CC
Packit Service c5cf8c
export GCC
Packit Service c5cf8c
export LDFLAGS
Packit Service c5cf8c
export LD
Packit Service c5cf8c
export with_gnu_ld
Packit Service c5cf8c
Packit Service c5cf8c
AS_IF([$ac_aux_dir/config.rpath "$host" > $2],[:],[AC_MSG_ERROR([unable to execute $ac_aux_dir/config.rpath])])
Packit Service c5cf8c
Packit Service c5cf8c
C_LINKPATH_SHL=""
Packit Service c5cf8c
AC_SUBST([C_LINKPATH_SHL])
Packit Service c5cf8c
Packit Service c5cf8c
rm -f conftest.out
Packit Service c5cf8c
Packit Service c5cf8c
# restore the old values
Packit Service c5cf8c
PAC_POP_FLAG([with_gnu_ld])
Packit Service c5cf8c
PAC_POP_FLAG([LD])
Packit Service c5cf8c
PAC_POP_FLAG([LDFLAGS])
Packit Service c5cf8c
PAC_POP_FLAG([GCC])
Packit Service c5cf8c
PAC_POP_FLAG([CC])
Packit Service c5cf8c
Packit Service c5cf8c
AC_MSG_RESULT([done (results in $2)])
Packit Service c5cf8c
])