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