torture_auth: Add missing dependency on gensec_ntlmssp.
[Samba.git] / source4 / build / m4 / check_ld.m4
blob48d6b333efbbc7b39e94b9ac8a362eef8b802431
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 -------------------------------------------------------
7 dnl
9 AC_PATH_PROG(PROG_LD,ld)
10 LD=${PROG_LD}
11 AC_PROG_LD_GNU
12 LD=""
14 AC_SUBST(BLDSHARED)
15 AC_SUBST(LD)
16 AC_SUBST(SYS_LDFLAGS)
17 AC_SUBST(LDFLAGS)
19 # Assume non-shared by default and override below
20 # these are the defaults, good for lots of systems
21 BLDSHARED="false"
22 LD="${CC}"
23 PICFLAG=""
25 # allow for --with-hostld=gcc
26 AC_ARG_WITH(hostld,[  --with-hostld=linker    choose host linker],
27 [HOSTLD=$withval],
28 [HOSTLD=$HOSTCC])
30 AC_MSG_CHECKING([whether to try to build shared libraries on $host_os])
32 # and these are for particular systems
33 case "$host_os" in
34         *linux*)
35                 BLDSHARED="true"
36                 SYS_LDFLAGS="-Wl,--export-dynamic"
37                 ;;
38         *solaris*)
39                 BLDSHARED="true"
40                 if test "${GCC}" = "yes"; then
41                         if test "${ac_cv_prog_gnu_ld}" = "yes"; then
42                                 SYS_LDFLAGS="-Wl,-E"
43                         fi
44                 fi
45                 ;;
46         *sunos*)
47                 BLDSHARED="true"
48                 ;;
49         *netbsd* | *freebsd* | *dragonfly* )  
50                 BLDSHARED="true"
51                 SYS_LDFLAGS="-Wl,--export-dynamic"
52                 ;;
53         *openbsd*)
54                 BLDSHARED="true"
55                 SYS_LDFLAGS="-Wl,-Bdynamic"
56                 ;;
57         *irix*)
58                 BLDSHARED="true"
59                 ;;
60         *aix*)
61                 BLDSHARED="true"
62                 SYS_LDFLAGS="-Wl,-brtl,-bexpall,-bbigtoc"
63                 ;;
64         *hpux*)
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"
69                 else
70                         SYS_LDFLAGS="-Wl,-E,+b/usr/local/lib:/usr/lib"
71                 fi
72                 ;;
73         *osf*)
74                 BLDSHARED="true"
75                 ;;
76         *unixware*)
77                 BLDSHARED="true"
78                 ;;
79         *darwin*)
80                 BLDSHARED="true"
81                 ;;
82 esac
84 AC_MSG_RESULT($BLDSHARED)
86 AC_MSG_CHECKING([LD])
87 AC_MSG_RESULT([$LD])
88 AC_MSG_CHECKING([LDFLAGS])
89 AC_MSG_RESULT([$LDFLAGS])
90 AC_MSG_CHECKING([SYS_LDFLAGS])
91 AC_MSG_RESULT([$SYS_LDFLAGS])
93 AC_SUBST(HOSTLD)
95 AC_LIBREPLACE_STLD
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])
103 AC_LD_PICFLAG
104 AC_LD_EXPORT_DYNAMIC
105 AC_LD_SHLIBEXT
106 AC_LD_SONAMEFLAG
107 AC_LIBREPLACE_SHLD
108 AC_LIBREPLACE_SHLD_FLAGS
109 AC_LIBREPLACE_MDLD
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],[
137                         ac_cv_shlib_works=no
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
144         ])
145         AC_CACHE_CHECK([whether building shared modules actually works], 
146                        [ac_cv_shmod_works],[
147                         ac_cv_shmod_works=no
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
153         ])
154         if test $ac_cv_shlib_works = no; then
155                 AC_MSG_ERROR(unable to build shared libraries)
156         fi
157         if test $ac_cv_shmod_works = no; then
158                 AC_MSG_ERROR(unable to build shared modules)
159         fi
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"],
166             AC_MSG_RESULT(yes),
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]))
171 USESHARED=false
172 AC_SUBST(USESHARED)
174 AC_ARG_ENABLE(dso,
175 [  --enable-dso                   Enable using shared libraries internally (experimental)],
176 [],[enable_dso=no])
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
183         USESHARED=$BLDSHARED
186 AC_MSG_CHECKING([if binaries will use shared libraries])
187 AC_MSG_RESULT([$USESHARED])