root/mpich2/branches/dev/kumudb/confdb/aclocal_shl.m4
@
4870
| Revision 4870, 11.3 KB (checked in by kumudb, 5 months ago) |
|---|
| Line | |
|---|---|
| 1 | dnl |
| 2 | dnl Definitions for creating shared libraries |
| 3 | dnl |
| 4 | dnl The purpose of these definitions is to provide common support for |
| 5 | dnl shared libraries, with *or without* the use of the GNU Libtool package. |
| 6 | dnl For many of our important platforms, the Libtool approach is overkill, |
| 7 | dnl and can be particularly painful for developers. |
| 8 | dnl |
| 9 | dnl To use libtool, you need macros that are defined by libtool for libtool |
| 10 | dnl Don't even think about the consequences of this for updating and for |
| 11 | dnl using user-versions of libtool :( |
| 12 | dnl |
| 13 | dnl !!!!!!!!!!!!!!!!!!!!! |
| 14 | dnl libtool requires ac 2.50 !!!!!!!!!!!!!!!!! |
| 15 | dnl |
| 16 | dnl builtin(include,libtool.m4) |
| 17 | dnl |
| 18 | dnl/*D |
| 19 | dnl PAC_ARG_SHAREDLIBS - Add --enable-sharedlibs=kind to configure. |
| 20 | dnl |
| 21 | dnl Synopsis: |
| 22 | dnl PAC_ARG_SHAREDLIBS |
| 23 | dnl |
| 24 | dnl Output effects: |
| 25 | dnl Adds '--enable-sharedlibs=kind' to the command line. If this is enabled, |
| 26 | dnl then based on the value of 'kind', programs are selected for the |
| 27 | dnl names 'CC_SHL' and 'CC_LINK_SHL' that configure will substitute for in |
| 28 | dnl 'Makefile.in's. These symbols are generated by 'simplemake' when |
| 29 | dnl shared library support is selected. |
| 30 | dnl The variable 'C_LINKPATH_SHL' is set to the option to specify the |
| 31 | dnl path to search at runtime for libraries (-rpath in gcc/GNU ld). |
| 32 | dnl The variable 'SHLIB_EXT' is set to the extension used by shared |
| 33 | dnl libraries; under most forms of Unix, this is 'so'; under Mac OS/X, this |
| 34 | dnl is 'dylib', and under Windows (including cygwin), this is 'dll'. |
| 35 | dnl |
| 36 | dnl Supported values of 'kind' include \: |
| 37 | dnl+ gcc - Use gcc to create both shared objects and libraries |
| 38 | dnl. osx-gcc - Use gcc on Mac OS/X to create both shared objects and |
| 39 | dnl libraries |
| 40 | dnl. solaris-cc - Use native Solaris cc to create shared objects and |
| 41 | dnl libraries |
| 42 | dnl. cygwin-gcc - Use gcc on Cygwin to create shared objects and libraries |
| 43 | dnl- none - The same as '--disable-sharedlibs' |
| 44 | dnl |
| 45 | dnl Others will be added as experience dictates. Likely names are |
| 46 | dnl + libtool - For general GNU libtool |
| 47 | dnl - linux-pgcc - For Portland group under Linux |
| 48 | dnl |
| 49 | dnl Notes: |
| 50 | dnl Shared libraries are only partially implemented. Additional symbols |
| 51 | dnl will probably be defined, including symbols to specify how shared library |
| 52 | dnl search paths are specified and how shared library names are set. |
| 53 | dnl D*/ |
| 54 | AC_DEFUN([PAC_ARG_SHAREDLIBS],[ |
| 55 | AC_ARG_ENABLE(sharedlibs, |
| 56 | [--enable-sharedlibs=kind - Enable shared libraries. kind may be |
| 57 | gcc - Standard gcc and GNU ld options for creating shared libraries |
| 58 | osx-gcc - Special options for gcc needed only on OS/X |
| 59 | solaris-cc - Solaris native (SPARC) compilers for 32 bit systems |
| 60 | cygwin-gcc - Special options for gcc needed only for cygwin |
| 61 | none - same as --disable-sharedlibs |
| 62 | Only gcc, osx-gcc, and solaris-cc are currently supported], |
| 63 | ,enable_sharedlibs=none;enable_shared=no) |
| 64 | dnl |
| 65 | CC_SHL=true |
| 66 | C_LINK_SHL=true |
| 67 | SHLIB_EXT=unknown |
| 68 | SHLIB_FROM_LO=no |
| 69 | SHLIB_INSTALL='$(INSTALL_PROGRAM)' |
| 70 | case "$enable_sharedlibs" in |
| 71 | no|none) |
| 72 | ;; |
| 73 | gcc-osx|osx-gcc) |
| 74 | AC_MSG_RESULT([Creating shared libraries using GNU for Mac OSX]) |
| 75 | C_LINK_SHL='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace' |
| 76 | CC_SHL='${CC} -fPIC' |
| 77 | # No way in osx to specify the location of the shared libraries at link |
| 78 | # time (see the code in createshlib in mpich2/src/util) |
| 79 | C_LINKPATH_SHL="" |
| 80 | SHLIB_EXT="dylib" |
| 81 | enable_sharedlibs="osx-gcc" |
| 82 | ;; |
| 83 | gcc) |
| 84 | AC_MSG_RESULT([Creating shared libraries using GNU]) |
| 85 | # Not quite right yet. See mpich/util/makesharedlib |
| 86 | # Use syntax that works in both Make and the shell |
| 87 | #C_LINK_SHL='${CC} -shared -Wl,-r' |
| 88 | C_LINK_SHL='${CC} -shared' |
| 89 | # For example, include the libname as ${LIBNAME_SHL} |
| 90 | #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>' |
| 91 | # May need -fPIC |
| 92 | CC_SHL='${CC} -fpic' |
| 93 | #C_LINKPATH_SHL="-Wl,-rpath -Wl," |
| 94 | # More recent versions allow multiple args, separated by commas |
| 95 | C_LINKPATH_SHL="-Wl,-rpath," |
| 96 | SHLIB_EXT=so |
| 97 | # We need to test that this isn't osx. The following is a |
| 98 | # simple hack |
| 99 | osname=`uname -s` |
| 100 | case $osname in |
| 101 | *Darwin*|*darwin*) |
| 102 | AC_MSG_ERROR([You must specify --enable-sharedlibs=osx-gcc for Mac OS/X]) |
| 103 | ;; |
| 104 | *CYGWIN*|*cygwin*) |
| 105 | AC_MSG_ERROR([You must specify --enable-sharedlibs=cygwin-gcc for Cygwin]) |
| 106 | ;; |
| 107 | *SunOS*) |
| 108 | AC_MSG_ERROR([You must specify --enable-sharedlibs=solaris-gcc for Solaris with gcc]) |
| 109 | ;; |
| 110 | esac |
| 111 | ;; |
| 112 | |
| 113 | cygwin|cygwin-gcc|gcc-cygwin) |
| 114 | AC_MSG_RESULT([Creating shared libraries using GNU under CYGWIN]) |
| 115 | C_LINK_SHL='${CC} -shared' |
| 116 | CC_SHL='${CC}' |
| 117 | # DLL Libraries need to be in the user's path (!) |
| 118 | C_LINKPATH_SHL="" |
| 119 | SHLIB_EXT="dll" |
| 120 | enable_sharedlibs="cygwin-gcc" |
| 121 | ;; |
| 122 | |
| 123 | libtool) |
| 124 | AC_MSG_ERROR([Creating shared libraries using libtool not yet supported]) |
| 125 | dnl dnl Using libtool requires a heavy-weight process to test for |
| 126 | dnl dnl various stuff that libtool needs. Without this, you'll get a |
| 127 | dnl dnl bizarre error message about libtool being unable to find |
| 128 | dnl dnl configure.in or configure.ac (!) |
| 129 | dnl AC_PROG_LIBTOOL |
| 130 | dnl # Likely to be |
| 131 | dnl # either CC or CC_SHL is libtool $cc |
| 132 | dnl CC_SHL='${LIBTOOL} --mode=compile ${CC}' |
| 133 | dnl # CC_LINK_SHL includes the final installation path |
| 134 | dnl # For many systems, the link may need to include *all* libraries |
| 135 | dnl # (since many systems don't allow any unsatisfied dependencies) |
| 136 | dnl # We need to give libtool the .lo file, not the .o files |
| 137 | dnl SHLIB_FROM_LO=yes |
| 138 | dnl # We also need to add -no-undefined when the compiler is gcc and |
| 139 | dnl # we are building under cygwin |
| 140 | dnl sysname=`uname -s | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ` |
| 141 | dnl isCygwin=no |
| 142 | dnl case "$sysname" in |
| 143 | dnl *CYGWIN*) isCygwin=yes;; |
| 144 | dnl esac |
| 145 | dnl if test "$isCygwin" = yes ; then |
| 146 | dnl C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -no-undefined -rpath ${libdir}' |
| 147 | dnl else |
| 148 | dnl C_LINK_SHL='${LIBTOOL} --mode=link ${CC} -rpath ${libdir}' |
| 149 | dnl fi |
| 150 | dnl C_LINKPATH_SHL="-rpath " |
| 151 | dnl # We also need a special install process with libtool. Note that this |
| 152 | dnl # will also install the static libraries |
| 153 | dnl SHLIB_INSTALL='$(LIBTOOL) --mode=install $(INSTALL_PROGRAM)' |
| 154 | dnl # Note we may still need to add |
| 155 | dnl #'$(LIBTOOL) --mode=finish $(libdir)' |
| 156 | ;; |
| 157 | dnl |
| 158 | dnl Other, such as solaris-cc |
| 159 | solaris|solaris-cc) |
| 160 | AC_MSG_RESULT([Creating shared libraries using Solaris]) |
| 161 | # pic32 is appropriate for both 32 and 64 bit Solaris |
| 162 | C_LINK_SHL='${CC} -G -xcode=pic32' |
| 163 | CC_SHL='${CC} -xcode=pic32' |
| 164 | C_LINKPATH_SHL="-R" |
| 165 | SHLIB_EXT=so |
| 166 | enable_sharedlibs="solaris-cc" |
| 167 | ;; |
| 168 | |
| 169 | solaris-gcc) |
| 170 | # This is the same as gcc, except for the C_LINKPATH_SHL |
| 171 | AC_MSG_RESULT([Creating shared libraries using Solaris with gcc]) |
| 172 | C_LINK_SHL='${CC} -shared' |
| 173 | CC_SHL='${CC} -fPIC' |
| 174 | C_LINKPATH_SHL="-R" |
| 175 | SHLIB_EXT=so |
| 176 | enable_sharedlibs="solaris-gcc" |
| 177 | ;; |
| 178 | |
| 179 | linuxppc-xlc) |
| 180 | # This is only the beginning of xlc support, thanks to andy@vpac.org |
| 181 | CC_SHL='${CC} -qmkshrobj' |
| 182 | # More recent versions allow multiple args, separated by commas |
| 183 | C_LINKPATH_SHL="-Wl,-rpath," |
| 184 | #C_LINKPATH_SHL="-Wl,-rpath -Wl," |
| 185 | C_LINK_SHL='${CC} -shared -qmkshrobj' |
| 186 | SHLIB_EXT=so |
| 187 | # Note that the full line should be more like |
| 188 | # $CLINKER -shared -qmkshrobj -Wl,-h,$libbase.$slsuffix -o ../shared/$libbase.$slsuffix *.o $OtherLibs |
| 189 | # for the appropriate values of $libbase and $slsuffix |
| 190 | # The -h name sets the name of the object; this is necessary to |
| 191 | # ensure that the dynamic linker can find the proper shared library. |
| 192 | ;; |
| 193 | |
| 194 | *) |
| 195 | AC_MSG_ERROR([Unknown value $enable_sharedlibs for enable-sharedlibs. Values should be gcc or osx-gcc]) |
| 196 | enable_sharedlibs=no |
| 197 | ;; |
| 198 | esac |
| 199 | # Check for the shared-library extension |
| 200 | PAC_CC_SHLIB_EXT |
| 201 | dnl |
| 202 | AC_SUBST(CC_SHL) |
| 203 | AC_SUBST(C_LINK_SHL) |
| 204 | AC_SUBST(C_LINKPATH_SHL) |
| 205 | AC_SUBST(SHLIB_EXT) |
| 206 | AC_SUBST(SHLIB_FROM_LO) |
| 207 | AC_SUBST(SHLIB_INSTALL) |
| 208 | ]) |
| 209 | |
| 210 | dnl /*D |
| 211 | dnl PAC_xx_SHAREDLIBS - Get compiler and linker for shared libraries |
| 212 | dnl These routines may be used to determine the compiler and the |
| 213 | dnl linker to be used in creating shared libraries |
| 214 | dnl Rather than set predefined variable names, they set an argument |
| 215 | dnl (if provided) |
| 216 | dnl |
| 217 | dnl Synopsis |
| 218 | dnl PAC_CC_SHAREDLIBS(type,CCvar,CLINKvar) |
| 219 | dnl D*/ |
| 220 | AC_DEFUN([PAC_CC_SHAREDLIBS], |
| 221 | [ |
| 222 | pac_kinds=$1 |
| 223 | ifelse($1,,[ |
| 224 | pac_prog="" |
| 225 | AC_CHECK_PROG(pac_prog,gcc,yes,no) |
| 226 | # If we are gcc but OS X, set the special type |
| 227 | # We need a similar setting for cygwin |
| 228 | if test "$pac_prog" = yes ; then |
| 229 | osname=`uname -s` |
| 230 | case $osname in |
| 231 | *Darwin*|*darwin*) pac_kinds=gcc-osx |
| 232 | ;; |
| 233 | *) pac_kinds=gcc |
| 234 | ;; |
| 235 | esac |
| 236 | fi |
| 237 | pac_prog="" |
| 238 | AC_CHECK_PROG(pac_prog,libtool,yes,no) |
| 239 | if test "$pac_prog" = yes ; then pac_kinds="$pac_kinds libtool" ; fi |
| 240 | ]) |
| 241 | for pac_arg in $pac_kinds ; do |
| 242 | case $pac_arg in |
| 243 | gcc) |
| 244 | # For example, include the libname as ${LIBNAME_SHL} |
| 245 | #C_LINK_SHL='${CC} -shared -Wl,-h,<finallibname>' |
| 246 | pac_cc_sharedlibs='gcc -shared -fpic' |
| 247 | pac_clink_sharedlibs='gcc -shared' |
| 248 | pac_type_sharedlibs=gcc |
| 249 | ;; |
| 250 | gcc-osx|osx-gcc) |
| 251 | pac_clink_sharedlibs='${CC} -dynamiclib -undefined suppress -single_module -flat_namespace' |
| 252 | pac_cc_sharedlibs='${CC} -fPIC' |
| 253 | pac_type_sharedlibs=gcc-osx |
| 254 | ;; |
| 255 | libtool) |
| 256 | AC_CHECK_PROGS(LIBTOOL,libtool,false) |
| 257 | if test "$LIBTOOL" = "false" ; then |
| 258 | AC_MSG_WARN([Could not find libtool]) |
| 259 | else |
| 260 | # Likely to be |
| 261 | # either CC or CC_SHL is libtool $cc |
| 262 | pac_cc_sharedlibs'${LIBTOOL} -mode=compile ${CC}' |
| 263 | pac_clink_sharedlibs='${LIBTOOL} -mode=link ${CC} -rpath ${libdir}' |
| 264 | pac_type_sharedlibs=libtool |
| 265 | fi |
| 266 | ;; |
| 267 | *) |
| 268 | ;; |
| 269 | esac |
| 270 | if test -n "$pac_cc_sharedlibs" ; then break ; fi |
| 271 | done |
| 272 | if test -z "$pac_cc_sharedlibs" ; then pac_cc_sharedlibs=true ; fi |
| 273 | if test -z "$pac_clink_sharedlibs" ; then pac_clink_sharedlibs=true ; fi |
| 274 | ifelse($2,,CC_SHL=$pac_cc_sharedlibs,$2=$pac_cc_sharedlibs) |
| 275 | ifelse($3,,C_LINK_SHL=$pac_clink_sharedlibs,$3=$pac_clink_sharedlibs) |
| 276 | ifelse($4,,SHAREDLIB_TYPE=$pac_type_sharedlibs,$4=$pac_type_sharedlibs) |
| 277 | ]) |
| 278 | dnl |
| 279 | dnl |
| 280 | dnl This macro ensures that all of the necessary substitutions are |
| 281 | dnl made by any subdirectory configure (which may simply SUBST the |
| 282 | dnl necessary values rather than trying to determine them from scratch) |
| 283 | dnl This is a more robust (and, in the case of libtool, only |
| 284 | dnl managable) method. |
| 285 | AC_DEFUN([PAC_CC_SUBDIR_SHLIBS],[ |
| 286 | AC_SUBST(CC_SHL) |
| 287 | AC_SUBST(C_LINK_SHL) |
| 288 | AC_SUBST(LIBTOOL) |
| 289 | AC_SUBST(ENABLE_SHLIB) |
| 290 | AC_SUBST(SHLIB_EXT) |
| 291 | if test "$ENABLE_SHLIB" = "libtool" ; then |
| 292 | if test -z "$LIBTOOL" ; then |
| 293 | AC_MSG_WARN([libtool selected for shared library support but LIBTOOL is not defined]) |
| 294 | fi |
| 295 | fi |
| 296 | ]) |
| 297 | dnl |
| 298 | dnl |
| 299 | dnl PAC_CC_SHLIB_EXT - get the extension for shared libraries |
| 300 | dnl Set the variable SHLIB_EXT if it is other than unknown. |
| 301 | dnl |
| 302 | AC_DEFUN([PAC_CC_SHLIB_EXT],[ |
| 303 | # Not all systems use .so as the extension for shared libraries (cygwin |
| 304 | # and OSX are two important examples). If we did not set the SHLIB_EXT, |
| 305 | # then try and determine it. We need this to properly implement |
| 306 | # clean steps that look for libfoo.$SHLIB_EXT . |
| 307 | if test "$SHLIB_EXT" = "unknown" ; then |
| 308 | osname=`uname -s` |
| 309 | case $osname in |
| 310 | *Darwin*|*darwin*) SHLIB_EXT=dylib |
| 311 | ;; |
| 312 | *CYGWIN*|*cygwin*) SHLIB_EXT=dll |
| 313 | ;; |
| 314 | *Linux*|*LINUX*|*SunOS*) SHLIB_EXT=so |
| 315 | ;; |
| 316 | esac |
| 317 | fi |
| 318 | ]) |
Note: See TracBrowser
for help on using the browser.
