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 if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
46 SHLD_FLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
48 SHLD_FLAGS="-shared -Wl,-Bsymbolic"
50 LDFLAGS="-Wl,--export-dynamic"
52 SONAMEFLAG="-Wl,-soname="
58 if test "${GCC}" = "yes"; then
60 SONAMEFLAG="-Wl,-soname="
61 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
66 ## ${CFLAGS} added for building 64-bit shared
67 ## libs using Sun's Compiler
68 SHLD_FLAGS="-G \${CFLAGS}"
75 PICFLAG="-KPIC" # Is this correct for SunOS
77 *netbsd* | *freebsd* | *dragonfly* )
79 LDFLAGS="-Wl,--export-dynamic"
80 SONAMEFLAG="-Wl,-soname,"
85 LDFLAGS="-Wl,-Bdynamic"
86 SONAMEFLAG="-Wl,-soname,"
91 SHLD_FLAGS="-set_version sgi1.0 -shared"
94 if test "${GCC}" = "yes"; then
102 SHLD_FLAGS="-Wl,-G,-bexpall"
103 LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
104 # as AIX code is always position independent...
108 # Use special PIC flags for the native HP-UX compiler.
109 if test $ac_cv_prog_cc_Ae = yes; then
111 SHLD_FLAGS="-b -Wl,-B,symbolic,-b,-z"
114 elif test "${GCC}" = "yes"; then
115 BLDSHARED="true" # I hope this is correct
118 if test "$host_cpu" = "ia64"; then
120 LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
123 LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
128 SONAMEFLAG="-Wl,-soname,"
133 SONAMEFLAG="-Wl,-soname,"
138 SHLD_FLAGS="-bundle -flat_namespace -undefined suppress"
143 AC_MSG_RESULT($BLDSHARED)
145 AC_MSG_CHECKING([LD])
147 AC_MSG_CHECKING([LDFLAGS])
148 AC_MSG_RESULT([$LDFLAGS])
150 AC_MSG_CHECKING([STLD])
151 AC_MSG_RESULT([$STLD])
152 AC_MSG_CHECKING([STLD_FLAGS])
153 AC_MSG_RESULT([$STLD_FLAGS])
155 #######################################################
156 # test whether building a shared library actually works
157 if test $BLDSHARED = true; then
159 AC_MSG_CHECKING([SHLD])
160 AC_MSG_RESULT([$SHLD])
161 AC_MSG_CHECKING([SHLD_FLAGS])
162 AC_MSG_RESULT([$SHLD_FLAGS])
164 AC_MSG_CHECKING([SHLIBEXT])
165 AC_MSG_RESULT([$SHLIBEXT])
166 AC_MSG_CHECKING([SONAMEFLAG])
167 AC_MSG_RESULT([$SONAMEFLAG])
169 AC_MSG_CHECKING([PICFLAG])
170 AC_MSG_RESULT([$PICFLAG])
172 AC_CACHE_CHECK([whether building shared libraries actually works],
173 [ac_cv_shlib_works],[
175 # try building a trivial shared library
176 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
177 ${SHLD} `eval echo ${SHLD_FLAGS} ` -o shlib.${SHLIBEXT} shlib.o &&
178 ac_cv_shlib_works=yes
179 rm -f shlib.${SHLIBEXT} shlib.o
181 if test $ac_cv_shlib_works = no; then
187 [ --enable-dso Enable building internal libraries as DSO's (experimental)],
188 [ if test x$enable_dso != xyes; then