1 dnl SMB Build Environment LD Checks
2 dnl -------------------------------------------------------
3 dnl Copyright (C) Stefan (metze) Metzmacher 2004
4 dnl Copyright (C) Jelmer Vernooij 2006
5 dnl Released under the GNU GPL
6 dnl -------------------------------------------------------
9 AC_PATH_PROG(PROG_LD,ld)
19 # Assume non-shared by default and override below
20 # these are the defaults, good for lots of systems
25 # allow for --with-hostld=gcc
26 AC_ARG_WITH(hostld,[ --with-hostld=linker choose host linker],
30 AC_MSG_CHECKING([whether to try to build shared libraries on $host_os])
32 # and these are for particular systems
36 SYS_LDFLAGS="-Wl,--export-dynamic"
40 if test "${GCC}" = "yes"; then
41 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
49 *netbsd* | *freebsd* | *dragonfly* )
51 SYS_LDFLAGS="-Wl,--export-dynamic"
55 SYS_LDFLAGS="-Wl,-Bdynamic"
62 SYS_LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
65 # Use special PIC flags for the native HP-UX compiler.
66 BLDSHARED="true" # I hope this is correct
67 if test "$host_cpu" = "ia64"; then
68 SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
70 SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
84 AC_MSG_RESULT($BLDSHARED)
88 AC_MSG_CHECKING([LDFLAGS])
89 AC_MSG_RESULT([$LDFLAGS])
90 AC_MSG_CHECKING([SYS_LDFLAGS])
91 AC_MSG_RESULT([$SYS_LDFLAGS])
96 AC_LIBREPLACE_STLD_FLAGS
98 AC_MSG_CHECKING([STLD])
99 AC_MSG_RESULT([$STLD])
100 AC_MSG_CHECKING([STLD_FLAGS])
101 AC_MSG_RESULT([$STLD_FLAGS])
108 AC_LIBREPLACE_SHLD_FLAGS
110 AC_LIBREPLACE_MDLD_FLAGS
111 AC_LIBREPLACE_RUNTIME_LIB_PATH_VAR
113 #######################################################
114 # test whether building a shared library actually works
115 if test $BLDSHARED = true; then
117 AC_MSG_CHECKING([SHLD])
118 AC_MSG_RESULT([$SHLD])
119 AC_MSG_CHECKING([SHLD_FLAGS])
120 AC_MSG_RESULT([$SHLD_FLAGS])
122 AC_MSG_CHECKING([MDLD])
123 AC_MSG_RESULT([$MDLD])
124 AC_MSG_CHECKING([MDLD_FLAGS])
125 AC_MSG_RESULT([$MDLD_FLAGS])
127 AC_MSG_CHECKING([SHLIBEXT])
128 AC_MSG_RESULT([$SHLIBEXT])
129 AC_MSG_CHECKING([SONAMEFLAG])
130 AC_MSG_RESULT([$SONAMEFLAG])
132 AC_MSG_CHECKING([PICFLAG])
133 AC_MSG_RESULT([$PICFLAG])
135 AC_CACHE_CHECK([whether building shared libraries actually works],
136 [ac_cv_shlib_works],[
138 # try building a trivial shared library
139 # TODO: also test SONAMEFLAG
140 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/../tests/shlib.c -o shlib.o &&
141 ${SHLD} ${SHLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o &&
142 ac_cv_shlib_works=yes
143 rm -f shlib.${SHLIBEXT} shlib.o
145 AC_CACHE_CHECK([whether building shared modules actually works],
146 [ac_cv_shmod_works],[
148 # try building a trivial shared library
149 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/../tests/shlib.c -o shlib.o &&
150 ${MDLD} ${MDLD_FLAGS} -o shlib.${SHLIBEXT} shlib.o &&
151 ac_cv_shmod_works=yes
152 rm -f shlib.${SHLIBEXT} shlib.o
154 if test $ac_cv_shlib_works = no; then
155 AC_MSG_ERROR(unable to build shared libraries)
157 if test $ac_cv_shmod_works = no; then
158 AC_MSG_ERROR(unable to build shared modules)
162 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
164 AC_MSG_CHECKING([if we can link using the selected flags])
165 AC_TRY_RUN([#include "${srcdir-.}/../tests/trivial.c"],
167 AC_MSG_ERROR([we cannot link with the selected cc and ld flags. Aborting configure]),
168 AC_MSG_WARN([cannot run when cross-compiling]))
175 [ --enable-dso Enable using shared libraries internally (experimental)],
178 if test x"$enable_dso" = x"yes" -a x"$BLDSHARED" != x"true"; then
179 AC_MSG_ERROR([--enable-dso: no support for shared libraries])
182 if test x"$enable_dso" != x"no"; then
186 AC_MSG_CHECKING([if binaries will use shared libraries])
187 AC_MSG_RESULT([$USESHARED])