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)
13 AC_PATH_PROG(PROG_AR, ar)
22 AC_SUBST(SHLD_UNDEF_FLAGS)
27 # Assume non-shared by default and override below
28 # these are the defaults, good for lots of systems
39 # allow for --with-hostld=gcc
40 AC_ARG_WITH(hostld,[ --with-hostld=linker choose host linker],
43 if test z"$cross_compiling" = "yes"; then
50 AC_MSG_CHECKING([whether to try to build shared libraries on $host_os])
52 # and these are for particular systems
56 SHLD_FLAGS="-shared -Wl,-Bsymbolic"
57 SHLD_UNDEF_FLAGS="-Wl,--allow-shlib-undefined"
58 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
59 SONAMEFLAG="-Wl,-soname="
65 if test "${GCC}" = "yes"; then
66 SONAMEFLAG="-Wl,-soname="
67 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
68 LDFLAGS="$LDFLAGS -Wl,-E"
71 ## ${CFLAGS} added for building 64-bit shared
72 ## libs using Sun's Compiler
73 SHLD_FLAGS="-G \${CFLAGS}"
81 *netbsd* | *freebsd* | *dragonfly* )
83 LDFLAGS="$LDFLAGS -Wl,--export-dynamic"
84 SONAMEFLAG="-Wl,-soname,"
87 # disabled because us4 fails to link libtorture.so
89 LDFLAGS="$LDFLAGS -Wl,-Bdynamic"
90 SONAMEFLAG="-Wl,-soname,"
93 # disabled because us4 fails to link libtorture.so
95 SHLD_FLAGS="-set_version sgi1.0 -shared"
100 # disabled because us4 fails to link libtorture.so
102 SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc"
103 LDFLAGS="$LDFLAGS -Wl,-brtl,-bexpall,-bbigtoc"
106 # Use special PIC flags for the native HP-UX compiler.
107 if test $ac_cv_prog_cc_Ae = yes; then
109 SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z"
111 elif test "${GCC}" = "yes"; then
112 BLDSHARED="true" # I hope this is correct
114 if test "$host_cpu" = "ia64"; then
116 LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
119 LDFLAGS="$LDFLAGS -Wl,-E,+b/usr/local/lib:/usr/lib"
123 # disabled because tru64 fails to link libtorture.so
125 SONAMEFLAG="-Wl,-soname,"
129 SONAMEFLAG="-Wl,-soname,"
133 SHLD_FLAGS="-bundle -flat_namespace -undefined suppress"
138 AC_MSG_RESULT($BLDSHARED)
140 AC_MSG_CHECKING([LD])
142 AC_MSG_CHECKING([LDFLAGS])
143 AC_MSG_RESULT([$LDFLAGS])
147 AC_MSG_CHECKING([STLD])
148 AC_MSG_RESULT([$STLD])
149 AC_MSG_CHECKING([STLD_FLAGS])
150 AC_MSG_RESULT([$STLD_FLAGS])
154 AC_ARG_ENABLE(shared,
155 [ --disable-shared Disable testing for building shared libraries],
156 [],[enable_shared=yes])
158 if test x"$enable_shared" = x"no" -o x"$enable_shared" = x"false"; then
162 #######################################################
163 # test whether building a shared library actually works
164 if test $BLDSHARED = true; then
166 AC_MSG_CHECKING([SHLD])
167 AC_MSG_RESULT([$SHLD])
168 AC_MSG_CHECKING([SHLD_FLAGS])
169 AC_MSG_RESULT([$SHLD_FLAGS])
171 AC_MSG_CHECKING([SHLIBEXT])
172 AC_MSG_RESULT([$SHLIBEXT])
173 AC_MSG_CHECKING([SONAMEFLAG])
174 AC_MSG_RESULT([$SONAMEFLAG])
176 AC_MSG_CHECKING([PICFLAG])
177 AC_MSG_RESULT([$PICFLAG])
179 AC_CACHE_CHECK([whether building shared libraries actually works],
180 [ac_cv_shlib_works],[
182 # try building a trivial shared library
183 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
184 ${SHLD} `eval echo ${SHLD_FLAGS} ` -o shlib.${SHLIBEXT} shlib.o &&
185 ac_cv_shlib_works=yes
186 rm -f shlib.${SHLIBEXT} shlib.o
188 if test $ac_cv_shlib_works = no; then
193 if test $BLDSHARED != true; then
194 SHLD="shared-libraries-disabled"
195 SHLD_FLAGS="shared-libraries-disabled"
196 SHLIBEXT="shared_libraries_disabled"
197 SONAMEFLAG="shared-libraries-disabled"
199 AC_MSG_CHECKING([SHLD])
200 AC_MSG_RESULT([$SHLD])
201 AC_MSG_CHECKING([SHLD_FLAGS])
202 AC_MSG_RESULT([$SHLD_FLAGS])
204 AC_MSG_CHECKING([SHLIBEXT])
205 AC_MSG_RESULT([$SHLIBEXT])
206 AC_MSG_CHECKING([SONAMEFLAG])
207 AC_MSG_RESULT([$SONAMEFLAG])
209 AC_MSG_CHECKING([PICFLAG])
210 AC_MSG_RESULT([$PICFLAG])
213 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
215 AC_MSG_CHECKING([if we can link using the selected flags])
216 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
218 AC_MSG_ERROR([we cannot link with the selected cc and ld flags. Aborting configure]),
219 AC_MSG_WARN([cannot run when cross-compiling]))
226 [ --enable-dso Enable using shared libraries internally (experimental)],
229 if test x"$enable_dso" = x"yes" -a x"$BLDSHARED" != x"true"; then
230 AC_MSG_ERROR([--enable-dso: no support for shared libraries])
233 if test x"$enable_dso" != x"no"; then
237 AC_MSG_CHECKING([if binaries will use shared libraries])
238 AC_MSG_RESULT([$USESHARED])