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