a1eb4f4b468d9f194f26f1bcf7ac4737487afda4
[amitay/samba.git] / source4 / configure.ac
1 dnl -*- mode: m4-mode -*-
2 dnl Process this file with autoconf to produce a configure script.
3
4 AC_PREREQ(2.54)
5
6 AC_INIT([samba],[4],[samba-technical@samba.org])
7
8 AC_CONFIG_SRCDIR([include/includes.h])
9 AC_CONFIG_HEADER(include/config_tmp.h)
10 AC_DEFINE(CONFIG_H_IS_FROM_SAMBA,1,[Marker for samba's config.h])
11
12 # Configuration rules.
13 m4_include(build/m4/env.m4)
14 m4_include(../lib/replace/samba.m4)
15 m4_include(lib/smbreadline/readline.m4)
16 m4_include(heimdal_build/config.m4)
17 m4_include(../lib/util/fault.m4)
18 m4_include(../lib/util/signal.m4)
19 m4_include(../lib/util/util.m4)
20 m4_include(../lib/util/fsusage.m4)
21 m4_include(../lib/util/xattr.m4)
22 m4_include(../lib/util/capability.m4)
23 m4_include(../lib/util/time.m4)
24 m4_include(../lib/popt/samba.m4)
25 m4_include(../lib/util/charset/config.m4)
26 m4_include(lib/socket/config.m4)
27 m4_include(../lib/zlib/zlib.m4)
28 AC_ZLIB([
29 SMB_EXT_LIB(ZLIB, [${ZLIB_LIBS}])
30 ],[
31 SMB_INCLUDE_MK(lib/zlib.mk)
32 ])
33 m4_include(../nsswitch/nsstest.m4)
34 m4_include(../pidl/config.m4)
35
36 AC_CONFIG_FILES(lib/registry/registry.pc)
37 AC_CONFIG_FILES(librpc/dcerpc.pc)
38 AC_CONFIG_FILES(../librpc/ndr.pc)
39 AC_CONFIG_FILES(../lib/torture/torture.pc)
40 AC_CONFIG_FILES(auth/gensec/gensec.pc)
41 AC_CONFIG_FILES(param/samba-hostconfig.pc)
42 AC_CONFIG_FILES(librpc/dcerpc_samr.pc)
43 AC_CONFIG_FILES(librpc/dcerpc_atsvc.pc)
44
45 SMB_INCLUDED_LIB_PKGCONFIG(LIBTALLOC, talloc >= 1.3.0, [],
46         [
47                 m4_include(../lib/talloc/libtalloc.m4)
48                 SMB_INCLUDE_MK(../lib/talloc/config.mk)
49         ]
50 )
51
52 SMB_INCLUDED_LIB_PKGCONFIG(LIBTDB, tdb >= 1.1.3,
53         [],
54         [
55                 m4_include(../lib/tdb/libtdb.m4)
56                 SMB_INCLUDE_MK(../lib/tdb/config.mk)
57         ]
58 )
59
60 SMB_INCLUDE_MK(../lib/tdb/python.mk) 
61
62 SMB_INCLUDED_LIB_PKGCONFIG(LIBTEVENT, tevent = 0.9.4,
63         [],[m4_include(../lib/tevent/samba.m4)]
64 )
65
66 SMB_INCLUDE_MK(../lib/tevent/python.mk) 
67
68 SMB_INCLUDED_LIB_PKGCONFIG(LIBLDB, ldb = 0.9.3,
69         [
70                 SMB_INCLUDE_MK(lib/ldb/ldb_ildap/config.mk)
71                 SMB_INCLUDE_MK(lib/ldb/tools/config.mk)
72                 define_ldb_modulesdir=no
73         ],
74         [
75                 # Here we need to do some tricks
76                 # with AC_CONFIG_COMMANDS_PRE
77                 # as that's the deferrs the commands
78                 # to location after $prefix and $exec_prefix
79                 # have usefull values and directly before
80                 # creating config.status.
81                 #
82                 # The 'eval eval echo' trick is used to
83                 # actually get the raw absolute directory
84                 # path as this is needed in config.h
85                 define_ldb_modulesdir=yes
86                 AC_CONFIG_COMMANDS_PRE([
87                 if test x"$define_ldb_modulesdir" = x"yes";then
88                         LDB_MODULESDIR=`eval eval echo ${modulesdir}/ldb`
89                         AC_DEFINE_UNQUOTED(LDB_MODULESDIR, "${LDB_MODULESDIR}" , [ldb Modules directory])
90                 fi
91                 ])
92                 ldbdir=lib/ldb
93                 AC_SUBST(ldbdir)
94                 m4_include(lib/ldb/sqlite3.m4)
95                 m4_include(lib/ldb/libldb.m4)
96                 SMB_INCLUDE_MK(lib/ldb/config.mk)
97                 AC_CONFIG_FILES(lib/ldb/ldb.pc)
98         ], [no])
99 SMB_INCLUDE_MK(lib/ldb/python.mk) 
100
101 m4_include(lib/tls/config.m4)
102
103 dnl m4_include(auth/kerberos/config.m4)
104 m4_include(auth/gensec/config.m4)
105 m4_include(smbd/process_model.m4)
106 m4_include(ntvfs/posix/config.m4)
107 m4_include(ntvfs/unixuid/config.m4)
108 m4_include(../lib/socket_wrapper/config.m4)
109 m4_include(../lib/nss_wrapper/config.m4)
110 m4_include(auth/config.m4)
111 m4_include(kdc/config.m4)
112 m4_include(ntvfs/sysdep/config.m4)
113 m4_include(../nsswitch/config.m4)
114
115 #################################################
116 # add *_CFLAGS only for the real build
117 CFLAGS="${CFLAGS} ${DEVELOPER_CFLAGS}"
118
119 #################################################
120 # final configure stuff
121
122 AC_MSG_CHECKING([configure summary])
123 AC_TRY_RUN([#include "${srcdir-.}/../tests/summary.c"],
124            AC_MSG_RESULT(yes),
125            AC_MSG_ERROR([summary failure. Aborting config]); exit 1;,
126            AC_MSG_WARN([cannot run when cross-compiling]))
127
128 LIBS=`echo $LIBS | sed -e 's/ *//g'`
129 if test x"$LIBS" != x""; then
130         echo "LIBS: $LIBS"
131         AC_MSG_WARN([the global \$LIBS variable contains some libraries!])
132         AC_MSG_WARN([this should not happen, please report to samba-technical@lists.samba.org!])
133         AC_MSG_ERROR([only _EXT macros from aclocal.m4 should be used!])
134 fi
135
136 dnl Remove -L/usr/lib/? from LDFLAGS and LIBS
137 LIB_REMOVE_USR_LIB(LDFLAGS)
138 LIB_REMOVE_USR_LIB(LIBS)
139
140 dnl Remove -I/usr/include/? from CFLAGS and CPPFLAGS
141 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
142 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
143
144 AC_SUBST(ac_default_prefix)
145
146 for d in build/smb_build bin include ; do
147     test -d ${builddir}/$d || AS_MKDIR_P(${builddir}/$d)
148 done
149
150 AC_SUBST(INTERN_LDFLAGS)
151 AC_SUBST(INSTALL_LINK_FLAGS)
152 if test $USESHARED = "true";
153 then
154         INTERN_LDFLAGS="-L\$(shliboutputdir) -L\${builddir}/bin/static"
155         INSTALL_LINK_FLAGS="-Wl,-rpath-link,\$(shliboutputdir)";
156 else
157         INTERN_LDFLAGS="-L\${builddir}/bin/static -L\$(shliboutputdir)"
158 fi
159
160 builddir_headers=""
161         
162 if test "x$ac_abs_srcdir" != "x$ac_abs_builddir"
163 then
164         builddir_headers="-I\$(builddir)/include -I\$(builddir) -I\$(builddir)/lib ";
165 fi
166
167 CPPFLAGS="$builddir_headers-I\$(srcdir)/include -I\$(srcdir) -I\$(srcdir)/lib -I\$(srcdir)/../lib/replace -I\$(srcdir)/../lib/talloc -I\$(srcdir)/.. -D_SAMBA_BUILD_=4 -DHAVE_CONFIG_H $CPPFLAGS"
168
169 SMB_WRITE_PERLVARS(build/smb_build/config.pm)
170
171 echo "configure: creating config.mk"
172 cat >config.mk<<CEOF
173 # config.mk - Autogenerated by configure, DO NOT EDIT!
174 $SMB_INFO_EXT_LIBS
175 $SMB_INFO_SUBSYSTEMS
176 $SMB_INFO_LIBRARIES
177 CEOF
178
179 SMB_BUILD_RUN(data.mk)
180 AC_OUTPUT
181
182 cmp include/config_tmp.h include/config.h >/dev/null 2>&1
183 CMP_RET=$?
184 if test $CMP_RET != 0; then
185         cp include/config_tmp.h include/config.h
186 fi
187
188 SMB_WRITE_MAKEVARS(mkconfig.mk)
189
190 if test $USESHARED = true
191 then
192         echo "To run binaries without installing, set the following environment variable:"
193         echo "$LIB_PATH_VAR=$builddir/bin/shared"
194 fi
195
196 echo
197 echo "To build Samba, run $MAKE"