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)
11 AC_PATH_PROG(PROG_AR, ar)
24 # Assume non-shared by default and override below
25 # these are the defaults, good for lots of systems
37 AC_MSG_CHECKING([ability to build shared libraries])
39 # and these are for particular systems
43 if test "${ac_cv_gnu_ld_no_default_allow_shlib_undefined}" = "yes"; then
44 SHLD_FLAGS="-shared -Wl,-Bsymbolic -Wl,--allow-shlib-undefined"
46 SHLD_FLAGS="-shared -Wl,-Bsymbolic"
48 LDFLAGS="-Wl,--export-dynamic"
50 SONAMEFLAG="-Wl,-soname="
56 if test "${GCC}" = "yes"; then
58 SONAMEFLAG="-Wl,-soname="
59 if test "${ac_cv_prog_gnu_ld}" = "yes"; then
64 ## ${CFLAGS} added for building 64-bit shared
65 ## libs using Sun's Compiler
66 SHLD_FLAGS="-G \${CFLAGS}"
73 PICFLAG="-KPIC" # Is this correct for SunOS
75 *netbsd* | *freebsd* | *dragonfly* )
77 LDFLAGS="-Wl,--export-dynamic"
78 SONAMEFLAG="-Wl,-soname,"
83 LDFLAGS="-Wl,-Bdynamic"
84 SONAMEFLAG="-Wl,-soname,"
89 SHLD_FLAGS="-set_version sgi1.0 -shared"
92 if test "${GCC}" = "yes"; then
100 SHLD_FLAGS="-Wl,-G,-bexpall"
101 LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
102 # as AIX code is always position independent...
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"
112 elif test "${GCC}" = "yes"; then
113 BLDSHARED="true" # I hope this is correct
116 if test "$host_cpu" = "ia64"; then
118 LDFLAGS="-Wl,-E,+b/usr/local/lib/hpux32:/usr/lib/hpux32"
121 LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
126 SONAMEFLAG="-Wl,-soname,"
131 SONAMEFLAG="-Wl,-soname,"
136 SHLD_FLAGS="-bundle -flat_namespace -undefined suppress"
141 AC_MSG_RESULT($BLDSHARED)
143 AC_MSG_CHECKING([LD])
145 AC_MSG_CHECKING([LDFLAGS])
146 AC_MSG_RESULT([$LDFLAGS])
148 AC_MSG_CHECKING([STLD])
149 AC_MSG_RESULT([$STLD])
150 AC_MSG_CHECKING([STLD_FLAGS])
151 AC_MSG_RESULT([$STLD_FLAGS])
153 #######################################################
154 # test whether building a shared library actually works
155 if test $BLDSHARED = true; then
157 AC_MSG_CHECKING([SHLD])
158 AC_MSG_RESULT([$SHLD])
159 AC_MSG_CHECKING([SHLD_FLAGS])
160 AC_MSG_RESULT([$SHLD_FLAGS])
162 AC_MSG_CHECKING([SHLIBEXT])
163 AC_MSG_RESULT([$SHLIBEXT])
164 AC_MSG_CHECKING([SONAMEFLAG])
165 AC_MSG_RESULT([$SONAMEFLAG])
167 AC_MSG_CHECKING([PICFLAG])
168 AC_MSG_RESULT([$PICFLAG])
170 AC_CACHE_CHECK([whether building shared libraries actually works],
171 [ac_cv_shlib_works],[
173 # try building a trivial shared library
174 ${CC} ${CFLAGS} ${PICFLAG} -c ${srcdir-.}/build/tests/shlib.c -o shlib.o &&
175 ${SHLD} `eval echo ${SHLD_FLAGS} ` -o shlib.${SHLIBEXT} shlib.o &&
176 ac_cv_shlib_works=yes
177 rm -f shlib.${SHLIBEXT} shlib.o
179 if test $ac_cv_shlib_works = no; then
185 [ --enable-dso Enable building internal libraries as DSO's (experimental)],
186 [ if test x$enable_dso != xyes; then