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)
26 # Assume non-shared by default and override below
27 # these are the defaults, good for lots of systems
39 AC_MSG_CHECKING([ability to build shared libraries])
41 # and these are for particular systems
45 SHLD_FLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
46 LDFLAGS="-Wl,--export-dynamic"
48 SONAMEFLAG="-Wl,-soname="
54 if test "${GCC}" = "yes"; then
56 SONAMEFLAG="-Wl,-soname="
57 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
62 ## ${CFLAGS} added for building 64-bit shared
63 ## libs using Sun's Compiler
64 SHLD_FLAGS="-G \${CFLAGS}"
71 PICFLAG="-KPIC" # Is this correct for SunOS
73 *netbsd* | *freebsd* | *dragonfly* )
75 LDFLAGS="-Wl,--export-dynamic"
76 SONAMEFLAG="-Wl,-soname,"
81 LDFLAGS="-Wl,-Bdynamic"
82 SONAMEFLAG="-Wl,-soname,"
87 SHLD_FLAGS="-set_version sgi1.0 -shared"
90 if test "${GCC}" = "yes"; then
98 SHLD_FLAGS="-Wl,-G,-bexpall,-bbigtoc"
99 LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
100 # as AIX code is always position independent...
104 # Use special PIC flags for the native HP-UX compiler.
105 if test $ac_cv_prog_cc_Ae = yes; then
107 SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z"
110 elif test "${GCC}" = "yes"; then
111 BLDSHARED="true" # I hope this is correct
114 if test "$host_cpu" = "ia64"; then
116 LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
119 LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
124 SONAMEFLAG="-Wl,-soname,"
129 SONAMEFLAG="-Wl,-soname,"
134 SHLD_FLAGS="-bundle -flat_namespace -undefined suppress"
139 AC_MSG_RESULT($BLDSHARED)
141 AC_MSG_CHECKING([LD])
143 AC_MSG_CHECKING([LDFLAGS])
144 AC_MSG_RESULT([$LDFLAGS])
146 AC_MSG_CHECKING([STLD])
147 AC_MSG_RESULT([$STLD])
148 AC_MSG_CHECKING([STLD_FLAGS])
149 AC_MSG_RESULT([$STLD_FLAGS])
151 #######################################################
152 # test whether building a shared library actually works
153 if test $BLDSHARED = true; then
155 AC_MSG_CHECKING([SHLD])
156 AC_MSG_RESULT([$SHLD])
157 AC_MSG_CHECKING([SHLD_FLAGS])
158 AC_MSG_RESULT([$SHLD_FLAGS])
160 AC_DEFINE_UNQUOTED(SHLIBEXT, "$SHLIBEXT", [Shared library extension])
161 AC_MSG_CHECKING([SHLIBEXT])
162 AC_MSG_RESULT([$SHLIBEXT])
163 AC_MSG_CHECKING([SONAMEFLAG])
164 AC_MSG_RESULT([$SONAMEFLAG])
166 AC_MSG_CHECKING([PICFLAG])
167 AC_MSG_RESULT([$PICFLAG])
169 AC_CACHE_CHECK([whether building shared libraries actually works],
170 [ac_cv_shlib_works],[
172 # try building a trivial shared library
173 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
174 ${SHLD} `eval echo ${SHLD_FLAGS} ` -o shlib.${SHLIBEXT} shlib.o &&
175 ac_cv_shlib_works=yes
176 rm -f shlib.${SHLIBEXT} shlib.o
178 if test $ac_cv_shlib_works = no; then
183 AC_MSG_CHECKING([if we can link using the selected flags])
184 AC_TRY_RUN([#include "${srcdir-.}/build/tests/trivial.c"],
186 AC_MSG_ERROR([we cannot link with the selected cc and ld flags. Aborting configure]),
187 AC_MSG_WARN([cannot run when cross-compiling]))
190 [ --enable-dso Enable building internal libraries as DSO's (experimental)],
191 [ if test x$enable_dso != xyes; then