Merge branch 'upstream'
[jelmer/samba4-debian.git] / source / configure.ac
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3
4 dnl disabled 2.53 requirement - we do work with 2.52 on suse 7.3 for example
5 dnl AC_PREREQ(2.53)
6
7 AC_INIT([samba],[4],[samba-technical@samba.org])
8
9 AC_CONFIG_SRCDIR([include/includes.h])
10 AC_CONFIG_HEADER(include/config_tmp.h)
11 AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
12
13 # Configuration rules.
14 m4_include(build/m4/env.m4)
15 m4_include(lib/replace/samba.m4)
16 m4_include(lib/smbreadline/readline.m4)
17 m4_include(heimdal_build/config.m4)
18 m4_include(lib/util/fault.m4)
19 m4_include(lib/util/signal.m4)
20 m4_include(lib/util/util.m4)
21 m4_include(lib/util/fsusage.m4)
22 m4_include(lib/util/xattr.m4)
23 m4_include(lib/util/capability.m4)
24 m4_include(lib/util/time.m4)
25 m4_include(lib/popt/samba.m4)
26 m4_include(lib/charset/config.m4)
27 m4_include(lib/socket/config.m4)
28 m4_include(nsswitch/nsstest.m4)
29 m4_include(pidl/config.m4)
30
31 AC_CONFIG_FILES(lib/registry/registry.pc)
32 AC_CONFIG_FILES(librpc/dcerpc.pc)
33 AC_CONFIG_FILES(librpc/ndr.pc)
34 AC_CONFIG_FILES(torture/torture.pc)
35 AC_CONFIG_FILES(auth/gensec/gensec.pc)
36 AC_CONFIG_FILES(param/samba-hostconfig.pc)
37 AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
38 AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc)
39
40 SMB_EXT_LIB_FROM_PKGCONFIG(LIBTALLOC, talloc >= 1.2.0,
41         [],
42         [
43                 m4_include(lib/talloc/libtalloc.m4)
44                 SMB_INCLUDE_MK(lib/talloc/config.mk)
45         ]
46 )
47
48 SMB_EXT_LIB_FROM_PKGCONFIG(LIBTDB, tdb >= 1.1.0,
49         [],
50         [
51                 m4_include(lib/tdb/libtdb.m4)
52                 SMB_INCLUDE_MK(lib/tdb/config.mk)
53         ]
54 )
55
56 SMB_INCLUDE_MK(lib/tdb/python.mk) 
57
58 SMB_EXT_LIB_FROM_PKGCONFIG(LIBLDB, ldb >= 0.9.1,
59         [
60                 SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
61                 SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
62                 SMB_SUBSYSTEM(ldb_map, [], [LIBLDB])
63                 define_ldb_modulesdir=no
64         ],
65         [
66                 # Here we need to do some tricks
67                 # with AC_CONFIG_COMMANDS_PRE
68                 # as that's the deferrs the commands
69                 # to location after $prefix and $exec_prefix
70                 # have usefull values and directly before
71                 # creating config.status.
72                 #
73                 # The 'eval eval echo' trick is used to
74                 # actually get the raw absolute directory
75                 # path as this is needed in config.h
76                 define_ldb_modulesdir=yes
77                 AC_CONFIG_COMMANDS_PRE([
78                 if test x"$define_ldb_modulesdir" = x"yes";then
79                         LDB_MODULESDIR=`eval eval echo ${modulesdir}/ldb`
80                         AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory])
81                 fi
82                 ])
83                 ldbdir=lib/ldb
84                 AC_SUBST(ldbdir)
85                 m4_include(lib/ldb/sqlite3.m4)
86                 m4_include(lib/ldb/libldb.m4)
87                 SMB_INCLUDE_MK(lib/ldb/config.mk)
88                 AC_CONFIG_FILES(lib/ldb/ldb.pc)
89         ]
90 )
91 SMB_INCLUDE_MK(lib/ldb/python.mk) 
92
93 m4_include(lib/tls/config.m4)
94 m4_include(lib/events/config.m4)
95
96 dnl m4_include(auth/kerberos/config.m4)
97 m4_include(scripting/python/config.m4)
98 m4_include(auth/gensec/config.m4)
99 m4_include(smbd/process_model.m4)
100 m4_include(ntvfs/posix/config.m4)
101 m4_include(ntvfs/unixuid/config.m4)
102 m4_include(lib/socket_wrapper/config.m4)
103 m4_include(lib/nss_wrapper/config.m4)
104 m4_include(auth/config.m4)
105 m4_include(kdc/config.m4)
106 m4_include(ntvfs/sysdep/config.m4)
107 m4_include(lib/appweb/config.m4)
108 m4_include(nsswitch/config.m4)
109
110 #################################################
111 # add *_CFLAGS only for the real build
112 CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
113
114 #################################################
115 # final configure stuff
116
117 AC_MSG_CHECKING([configure summary])
118 AC_TRY_RUN([#include "${srcdir-.}/build/tests/summary.c"],
119            AC_MSG_RESULT(yes),
120            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
121            AC_MSG_WARN([cannot run when cross-compiling]))
122
123 LIBS=`echo $LIBS | sed -e 's/ *//g'`
124 if test x"$LIBS" != x""; then
125         echo "LIBS: $LIBS"
126         AC_MSG_WARN([the global \$LIBS variable contains some libraries!])
127         AC_MSG_WARN([this should not happen, please report to samba-technical@lists.samba.org!])
128         AC_MSG_ERROR([only _EXT macros from aclocal.m4 should be used!])
129 fi
130
131 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
132 LIB_REMOVE_USR_LIB(LDFLAGS)
133 LIB_REMOVE_USR_LIB(LIBS)
134
135 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
136 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
137 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
138
139 AC_SUBST(ac_default_prefix)
140
141 for d in build/smb_build bin include ; do
142     test -d ${builddir}/$d || AS_MKDIR_P(${builddir}/$d)
143 done
144
145 AC_SUBST(INTERN_LDFLAGS)
146 AC_SUBST(INSTALL_LINK_FLAGS)
147 if test $USESHARED = "true";
148 then
149         INTERN_LDFLAGS="-L\${builddir}/bin/shared -L\${builddir}/bin/static"
150         INSTALL_LINK_FLAGS="-Wl,-rpath-link,\${builddir}/bin/shared";
151 else
152         INTERN_LDFLAGS="-L\${builddir}/bin/static -L\${builddir}/bin/shared"
153 fi
154
155 builddir_headers=""
156         
157 if test "x$ac_abs_srcdir" != "x$ac_abs_builddir"
158 then
159         builddir_headers="-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
160 fi
161
162 CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/lib/replace -I\$(srcdir)/lib/talloc -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS"
163
164 echo "configure: creating build/smb_build/config.pm"
165 cat >build/smb_build/config.pm<<CEOF
166 # config.pm - Autogenerate by configure. DO NOT EDIT!
167
168 package config;
169 require Exporter;
170 @ISA = qw(Exporter);
171 @EXPORT_OK = qw(%enabled %config);
172 use strict;
173
174 use vars qw(%enabled %config);
175
176 %config = (AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
177         AC_Var => '$AC_Var',])
178 );
179
180 $SMB_INFO_ENABLES
181 1;
182 CEOF
183
184 echo "configure: creating config.mk"
185 cat >config.mk<<CEOF
186 # config.mk - Autogenerated by configure, DO NOT EDIT!
187 $SMB_INFO_EXT_LIBS
188 $SMB_INFO_SUBSYSTEMS
189 $SMB_INFO_LIBRARIES
190 CEOF
191
192 AC_OUTPUT_COMMANDS(
193 [
194 test "x$ac_abs_srcdir" != "x$ac_abs_builddir" && (
195         cd $builddir;
196         # NOTE: We *must* use -R so we don't follow symlinks (at least on BSD
197         # systems).
198         test -d heimdal || cp -R $srcdir/heimdal $builddir/
199         test -d heimdal_build || cp -R $srcdir/heimdal_build $builddir/
200         test -d build || builddir="$builddir" \
201                         srcdir="$srcdir" \
202                         $PERL ${srcdir}/script/buildtree.pl
203  )
204
205 $PERL -I${builddir} -I${builddir}/build \
206     -I${srcdir} -I${srcdir}/build \
207     ${srcdir}/build/smb_build/main.pl || exit $?
208 ],
209 [
210 srcdir="$srcdir"
211 builddir="$builddir"
212 PERL="$PERL"
213
214 export PERL
215 export srcdir
216 export builddir
217 ])
218 AC_OUTPUT
219
220 cmp include/config_tmp.h include/config.h >/dev/null 2>&1
221 CMP_RET=$?
222 if test $CMP_RET != 0; then
223         cp include/config_tmp.h include/config.h
224 fi
225
226 echo "configure: creating mkconfig.mk"
227 cat >mkconfig.mk<<CEOF
228 # mkconfig.mk - Autogenerated by configure, DO NOT EDIT!
229 AC_FOREACH([AC_Var], m4_defn([_AC_SUBST_VARS]), [
230 AC_Var = $AC_Var])
231 $MAKE_SETTINGS
232 CEOF
233
234 if test $USESHARED = true
235 then
236         echo "To run binaries without installing, set the following environment variable:"
237         echo "$ac_cv_LIB_PATH_VAR=$builddir/bin/shared"
238 fi
239
240 echo
241 echo "To build Samba, run $ac_cv_path_MAKE"