1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
# SYNOPSIS
#
# AX_PROG_LD_STATIC
#
# DESCRIPTION
#
# Try to determine the mode of static linking. The macro guesses the proper
# flag for static linking, caches the result, and updates LDFLAGS.
#
# Code inspired from GNU libtool 1.4.2 (yes, I know this is a rather old one).
#
# LAST MODIFICATION
#
# 2006-06-04
#
# COPYLEFT
#
# Copyright (c) 2006 Nicolas Calimet
#
# Copying and distribution of this file, with or without
# modification, are permitted in any medium without royalty provided
# the copyright notice and this notice are preserved.
AC_DEFUN([AX_PROG_LD_STATIC],
[
AC_CACHE_VAL(
[ax_cv_prog_ld_static],
[
AC_MSG_CHECKING([for linker static flag])
if test x"$GCC" = x"yes"; then
ax_cv_prog_ld_static="-static"
case "$build_os" in
aix*)
ax_cv_prog_ld_static="$ax_cv_prog_ld_static -Wl,-lC"
;;
irix*) # [NC]
ax_cv_prog_ld_static="$ax_cv_prog_ld_static -Wl,-Bstatic"
;;
esac
else
case "$build_os" in
aix3* | aix4* | aix5*)
if text x"$build_cpu" = x"ia64"; then
ax_cv_prog_ld_static="-Bstatic"
else
ax_cv_prog_ld_static="-bnso -bI:/lib/syscalls.exp"
fi
;;
hpux9* | hpux10* | hpux11*)
ax_cv_prog_ld_static="-Wl,-a -Wl,archive"
;;
irix5* | irix6*)
ax_cv_prog_ld_static="-non_shared"
;;
osf3* | osf4* | osf5*)
ax_cv_prog_ld_static="-non_shared"
;;
sco3.2v5*)
ax_cv_prog_ld_static="-dn"
;;
*)
ax_cv_prog_ld_static="-Bstatic"
;;
esac
fi
AC_MSG_RESULT([$ax_cv_prog_ld_static])
# now check for working flag
AC_MSG_CHECKING([for working '$ax_cv_prog_ld_static' flag])
ax_prog_ld_static_save_ldflags="$LDFLAGS"
LDFLAGS="$LDFLAGS $ax_cv_prog_ld_static"
AC_LINK_IFELSE(
[AC_LANG_PROGRAM([], [])],
[AC_MSG_RESULT([yes])],
[
AC_MSG_RESULT([no])
AC_MSG_NOTICE([static linking does not work, revert to dynamic linking])
ax_cv_prog_ld_static=""
LDFLAGS="$ax_prog_ld_static_save_ldflags"
]
)
]
)
])
|