2 # This offers a nice overview how to build shared libraries on all platforms
3 # http://www.fortran-2000.com/ArnaudRecipes/sharedlib.html
6 AC_DEFUN([AC_LIBREPLACE_STLD],
8 AC_PATH_PROG(PROG_AR, ar)
15 AC_DEFUN([AC_LIBREPLACE_STLD_FLAGS],
21 AC_DEFUN([AC_LD_EXPORT_DYNAMIC],
23 saved_LDFLAGS="$LDFLAGS"
24 if AC_TRY_COMMAND([${CC-cc} $CFLAGS -Wl,--version 2>&1 | grep "GNU ld" >/dev/null]); then
25 LD_EXPORT_DYNAMIC="-Wl,-export-dynamic"
29 LD_EXPORT_DYNAMIC="-Wl,-E"
36 AC_SUBST(LD_EXPORT_DYNAMIC)
37 LDFLAGS="$saved_LDFLAGS"
40 AC_DEFUN([AC_LD_PICFLAG],
47 if test "${GCC}" = "yes"; then
54 PICFLAG="-KPIC" # Is this correct for SunOS
56 *netbsd* | *freebsd* | *dragonfly* )
63 if test "${GCC}" = "yes"; then
70 # as AIX code is always position independent...
74 if test "${GCC}" = "yes"; then
76 elif test "$host_cpu" = "ia64"; then
78 elif test $ac_cv_prog_cc_Ae = yes; then
95 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_LINKER],
97 LD_SHLIB_LINKER="${CC}"
101 LD_SHLIB_LINKER="${PROG_LD}"
105 AC_SUBST(LD_SHLIB_LINKER)
108 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS],
110 LD_SHLIB_FLAGS="-shared"
114 LD_SHLIB_FLAGS="-shared -Wl,-Bsymbolic"
118 if test "${GCC}" = "no"; then
119 ## ${CFLAGS} added for building 64-bit shared
120 ## libs using Sun's Compiler
121 LD_SHLIB_FLAGS="-G \${CFLAGS}"
128 LD_SHLIB_FLAGS="-shared"
131 LD_SHLIB_FLAGS="-Wl,-G,-bexpall,-bbigtoc"
134 if test "${GCC}" = "yes"; then
135 LD_SHLIB_FLAGS="-shared"
141 LD_SHLIB_FLAGS="-shared"
144 LD_SHLIB_FLAGS="-dynamiclib -Wl,-search_paths_first"
148 AC_SUBST(LD_SHLIB_FLAGS)
151 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG],
153 LD_SHLIB_DISALLOW_UNDEF_FLAG=""
156 # TODO: enforce error not only warnings
158 # NOTE: -Wl,--no-allow-shlib-undefined isn't what we want...
159 # as it bails out on broken system libraries
163 LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved"
166 LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined error"
170 AC_SUBST(LD_SHLIB_DISALLOW_UNDEF_FLAG)
173 AC_DEFUN([AC_LIBREPLACE_SHLD],
175 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
176 SHLD="$LD_SHLIB_LINKER"
180 AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS],
182 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
183 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG])
184 SHLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_DISALLOW_UNDEF_FLAG"
188 AC_DEFUN([AC_LD_SHLIBEXT],
193 if test "$host_cpu" = "ia64"; then
206 AC_DEFUN([AC_LD_SONAMEFLAG],
212 SONAMEFLAG="-Wl,-soname="
216 if test "${GCC}" = "yes"; then
217 SONAMEFLAG="-Wl,-soname="
223 *netbsd* | *freebsd* | *dragonfly* )
224 SONAMEFLAG="-Wl,-soname,"
227 SONAMEFLAG="-Wl,-soname,"
230 SONAMEFLAG="-Wl,-soname,"
236 SONAMEFLAG="-Wl,-soname,"
239 SONAMEFLAG="-Wl,-soname,"
251 AC_DEFUN([AC_LD_VERSIONSCRIPT],
253 AC_SUBST(VERSIONSCRIPT)
257 VERSIONSCRIPT="-Wl,--version-script"
260 if test "${GCC}" = "yes"; then
261 VERSIONSCRIPT="-Wl,--version-script"
267 AC_DEFUN([AC_LIBREPLACE_MDLD],
269 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
270 MDLD="$LD_SHLIB_LINKER"
274 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG],
276 LD_ALLOW_SHLIB_UNDEF_FLAG=""
280 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined"
283 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\""
286 LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
289 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-bnoentry"
293 AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG)
296 AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS],
298 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
299 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG])
300 MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_ALLOW_UNDEF_FLAG"
304 AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR],
308 LIB_PATH_VAR=LD_LIBRARY_PATH
311 LIB_PATH_VAR=LD_LIBRARY_PATH
314 LIB_PATH_VAR=LD_LIBRARY_PATH
317 LIB_PATH_VAR=SHLIB_PATH
320 LIB_PATH_VAR=LD_LIBRARY_PATH
326 LIB_PATH_VAR=LD_LIBRARY_PATH
329 LIB_PATH_VAR=DYLD_LIBRARY_PATH
332 LIB_PATH_VAR=LD_LIBRARY_PATH
336 AC_SUBST(LIB_PATH_VAR)