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 $ac_cv_prog_cc_Ae = yes; then
76 elif test "${GCC}" = "yes"; then
79 if test "$host_cpu" = "ia64"; then
96 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_LINKER],
98 LD_SHLIB_LINKER="${CC}"
102 LD_SHLIB_LINKER="${PROG_LD}"
106 AC_SUBST(LD_SHLIB_LINKER)
109 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_FLAGS],
111 LD_SHLIB_FLAGS="-shared"
115 LD_SHLIB_FLAGS="-shared -Wl,-Bsymbolic"
119 if test "${GCC}" = "no"; then
120 ## ${CFLAGS} added for building 64-bit shared
121 ## libs using Sun's Compiler
122 LD_SHLIB_FLAGS="-G \${CFLAGS}"
129 LD_SHLIB_FLAGS="-shared"
132 LD_SHLIB_FLAGS="-Wl,-G,-bexpall,-bbigtoc"
135 if test "${GCC}" = "yes"; then
136 LD_SHLIB_FLAGS="-shared"
142 LD_SHLIB_FLAGS="-shared"
145 LD_SHLIB_FLAGS="-dynamiclib -Wl,-search_paths_first"
149 AC_SUBST(LD_SHLIB_FLAGS)
152 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG],
154 LD_SHLIB_DISALLOW_UNDEF_FLAG=""
157 # TODO: enforce error not only warnings
159 # NOTE: -Wl,--no-allow-shlib-undefined isn't what we want...
160 # as it bails out on broken system libraries
164 LD_SHLIB_DISALLOW_UNDEF_FLAG="-warning_unresolved"
167 LD_SHLIB_DISALLOW_UNDEF_FLAG="-undefined error"
171 AC_SUBST(LD_SHLIB_DISALLOW_UNDEF_FLAG)
174 AC_DEFUN([AC_LIBREPLACE_SHLD],
176 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
177 SHLD="$LD_SHLIB_LINKER"
181 AC_DEFUN([AC_LIBREPLACE_SHLD_FLAGS],
183 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
184 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_DISALLOW_UNDEF_FLAG])
185 SHLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_DISALLOW_UNDEF_FLAG"
189 AC_DEFUN([AC_LD_SHLIBEXT],
194 if test "$host_cpu" = "ia64"; then
207 AC_DEFUN([AC_LD_SONAMEFLAG],
213 SONAMEFLAG="-Wl,-soname="
217 if test "${GCC}" = "yes"; then
218 SONAMEFLAG="-Wl,-soname="
224 *netbsd* | *freebsd* | *dragonfly* )
225 SONAMEFLAG="-Wl,-soname,"
228 SONAMEFLAG="-Wl,-soname,"
231 SONAMEFLAG="-Wl,-soname,"
237 SONAMEFLAG="-Wl,-soname,"
240 SONAMEFLAG="-Wl,-soname,"
252 AC_DEFUN([AC_LIBREPLACE_MDLD],
254 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_LINKER])
255 MDLD="$LD_SHLIB_LINKER"
259 AC_DEFUN([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG],
261 LD_ALLOW_SHLIB_UNDEF_FLAG=""
265 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,--allow-shlib-undefined"
268 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-expect_unresolved,\"*\""
271 LD_SHLIB_ALLOW_UNDEF_FLAG="-undefined dynamic_lookup"
274 LD_SHLIB_ALLOW_UNDEF_FLAG="-Wl,-bnoentry"
278 AC_SUBST(LD_SHLIB_ALLOW_UNDEF_FLAG)
281 AC_DEFUN([AC_LIBREPLACE_MDLD_FLAGS],
283 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_FLAGS])
284 AC_REQUIRE([AC_LIBREPLACE_LD_SHLIB_ALLOW_UNDEF_FLAG])
285 MDLD_FLAGS="$LD_SHLIB_FLAGS $LD_SHLIB_ALLOW_UNDEF_FLAG"
289 AC_DEFUN([AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR],
293 LIB_PATH_VAR=LD_LIBRARY_PATH
296 LIB_PATH_VAR=LD_LIBRARY_PATH
299 LIB_PATH_VAR=LD_LIBRARY_PATH
302 LIB_PATH_VAR=SHLIB_PATH
305 LIB_PATH_VAR=LD_LIBRARY_PATH
308 LIB_PATH_VAR=LIB_PATH
311 LIB_PATH_VAR=LD_LIBRARY_PATH
314 LIB_PATH_VAR=DYLD_LIBRARY_PATH
318 AC_SUBST(LIB_PATH_VAR)