Lots of small fixes to make everything behave like it should.
[util-vserver.git] / configure.ac
1 dnl $Id$
2
3 dnl Copyright (C) 2003,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
4 dnl  
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2, or (at your option)
8 dnl any later version.
9 dnl  
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl  
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 dnl  
19 dnl  
20 dnl As a special exception to the GNU General Public License, if you
21 dnl distribute this file as part of a program that contains a configuration
22 dnl script generated by Autoconf, you may include it under the same
23 dnl distribution terms that you use for the rest of that program.
24 dnl  
25
26 AC_PREREQ(2.57)
27 AC_INIT(util-vserver, 0.30.214, vserver@list.linux-vserver.org)
28 AC_CONFIG_SRCDIR([src/capchroot.c])
29 AC_CONFIG_HEADER([config.h])
30
31 AM_INIT_AUTOMAKE([1.9 gnits dist-bzip2 subdir-objects])
32 AM_MAINTAINER_MODE
33
34 AC_CANONICAL_BUILD
35 AC_CANONICAL_HOST
36
37 AC_SUBST(GPG_KEY, "0xFFD316AC53ACA43A!")
38
39 # Checks for programs.
40 AC_PROG_CXX
41 AC_PROG_CC
42 AC_PROG_INSTALL
43 AC_PROG_LN_S
44 AM_PROG_CC_C_O
45 ENSC_CXXCOMPILER
46 ENSC_C99COMPILER
47
48 ENSC_SET_SEARCHPATH([$PATH:/sbin:/usr/sbin:/usr/local/sbin])
49 ENSC_PATHPROG_STANDARD_TOOLS
50
51 ENSC_PATHPROG(IP,        ip,,      [Usually, this tool is shipped in the 'iproute' or 'iproute2' package of your distribution])
52 ENSC_PATHPROG(IPTABLES,  iptables)
53 ENSC_PATHPROG(MODPROBE,  modprobe)
54 ENSC_PATHPROG(NAMEIF,    nameif)
55 ENSC_PATHPROG(NOHUP,     nohup)
56 ENSC_PATHPROG(RMMOD,     rmmod)
57 ENSC_PATHPROG(VCONFIG,   vconfig,, [See http://www.candelatech.com/~greear/vlan.html; usually this tool is shipped in the 'vconfig' or 'vlan' package of your distribution])
58 ENSC_PATHPROG(WGET,      wget)
59 ENSC_PATHPROG(FILE,      file,    [file])
60 ENSC_PATHPROG(GZIP,      gzip,    [gzip])
61 ENSC_PATHPROG(BZIP2,     bzip2,   [bzip2])
62 ENSC_PATHPROG(CPIO,      cpio,    [cpio])
63 ENSC_PATHPROG(RESTORE,   restore, [restore])
64 ENSC_PATHPROG(RSYNC,     rsync,   [rsync])
65 ENSC_PATHPROG(STRACE,    strace,  [strace])
66 ENSC_PATHPROG(FSCK,      fsck)
67
68 ENSC_PATHPROG(DOXYGEN,   doxygen,  [:])
69 ENSC_PATHPROG(XSLTP,     xsltp,    [:])
70 ENSC_PATHPROG(XSLTPROC,  xsltproc, [:])
71
72
73 AM_CONDITIONAL(HAVE_XSLTP,    test "$XSLTP"    != ':')
74 AM_CONDITIONAL(HAVE_XSLTPROC, test "$XSLTPROC" != ':')
75
76 if test x"$prefix" = x/; then
77         prefix=
78 fi      
79
80 ENSC_CHECK_CC_FLAG([-std=c99 -Wall -pedantic -W])
81 ENSC_CHECK_CXX_FLAG([-ansi   -Wall -pedantic -W -fmessage-length=0])
82
83 AC_MSG_CHECKING([whether to enable extra optimizations])
84 AC_ARG_ENABLE([extra-optimizations],
85               [AC_HELP_STRING([--disable-extra-optimizations],
86                               [disable certain extra optimizations (default: no)])],
87               [case "$enableval" in
88                   (yes) use_extra_optimizations=1;;
89                   (no)  use_extra_optimizations=;;
90                   (*)   AC_MSG_ERROR(['$enableval' is not a valid value for '--disable-extra-optimizations']);;
91                esac],
92               [use_extra_optimizations=1])
93
94 if test x"$use_extra_optimizations" = x; then
95         AC_MSG_RESULT(no)
96 else
97         AC_MSG_RESULT(yes)
98         ENSC_CHECK_CC_FLAG([-funit-at-a-time])
99         ENSC_CHECK_CXX_FLAG([-funit-at-a-time])
100 fi
101
102 AC_MSG_CHECKING([whether to enable debug-code in library])
103 AC_ARG_ENABLE([lib-debug],
104               [AC_HELP_STRING([--enable-lib-debug],
105                               [enable additional debug code in library (default: no)])],
106               [case "$enableval" in
107                   (yes) use_lib_debug=1;;
108                   (no)  use_lib_debug=;;
109                   (*)   AC_MSG_ERROR(['$enableval' is not a valid value for '--enable-lib-debug']);;
110                esac],
111               [ use_lib_debug= ])
112
113 if test x"$use_lib_debug" = x; then
114         AC_SUBST(LIB_DEBUG_CPPFLAGS, [-DNDEBUG])
115         AC_MSG_RESULT(no)
116 else
117         AC_SUBST(LIB_DEBUG_CPPFLAGS, [])
118         AC_MSG_RESULT(yes)
119 fi
120
121 AC_MSG_CHECKING([whether to enable expensive tests])
122 AC_ARG_ENABLE([expensive-tests],
123               [AC_HELP_STRING([--enable-expensive-tests],
124                               [disable tests which might be expensive on some systems (default: no)])],
125               [case "$enableval" in
126                  (yes|no)  use_expensive_tests=$enableval;;
127                  (*)       AC_MSG_ERROR(['$enableval' is not a valid value for '--enable-expensive-tests']);;
128                esac],
129               [ use_expensive_tests=no ])
130 AC_MSG_RESULT($use_expensive_tests)
131
132 AC_SUBST(ENSC_USE_EXPENSIVE_TESTS, "$use_expensive_tests")
133
134
135 ENSC_CHECK_PERSONALITY_FLAGS
136
137 AC_ARG_VAR(CC, [The C compiler])
138
139 ENSC_INITRDDIR(initrddir)
140 ENSC_RELEASE(RELEASE_CPPFLAGS)
141
142 # HACK: This needs to be before ENSC_DIETLIBC_NEED_COMPAT, or the alternative
143 # syscalls will never be enabled for glibc.
144 ENSC_SYSCALLNR(vserver,273,[lib/syscall-fallback.h])
145 ENSC_SYSCALL
146
147 dnl ###########################
148 dnl
149 dnl {some dietlibc related tests
150 dnl
151
152 case $host_cpu in
153         (i*86|athlon)   min_diet_ver=0.25;;
154         (ia64|hppa*)    min_diet_ver=0.29;;
155         (sparc*)        min_diet_ver=0.30;;
156         (x86_64)        min_diet_ver=0.27;;
157         (*)             min_diet_ver=0.28;;
158 esac
159
160 ENSC_ENABLE_DIETLIBC(USE_DIETLIBC, [$min_diet_ver])
161
162 if test x"$ensc_have_dietlibc" = xno; then
163         AC_MSG_WARN([***                                                         ***])
164         AC_MSG_WARN([*** it is strongly recommended to link util-vserver against ***])
165         AC_MSG_WARN([*** dietlibc;  glibc's NSS functions are very unreliable in ***])
166         AC_MSG_WARN([*** chroot() environments,  so you have to  expect problems ***])
167         AC_MSG_WARN([*** there.                                                  ***])
168         AC_MSG_WARN([***                                                         ***])
169         AM_CONDITIONAL(USE_DIETLIBC_COMPAT, false)
170 else
171         # HACK: libtool does not have cmdline options to build only
172         # dynamic libraries; this can be done with the
173         # '--disable-static' ./configure option only.  As our static
174         # libraries will be build with dietlibc, we have to do set
175         # this option which is evaluated by 'AC_PROG_LIBTOOL'
176         # below.  Therefore, this macro must not be called earlier.
177         enable_static=no
178
179         ENSC_DIETLIBC_NEED_COMPAT(USE_DIETLIBC_COMPAT)
180 fi
181
182 AM_CONDITIONAL(ENSC_USE_DIETLIBC, test x"$ensc_have_dietlibc" = xyes)
183 AM_CONDITIONAL(ENSC_USE_GLIBC,    true)
184
185 # HACK: see comments at 'enable_static' above
186 AC_PROG_LIBTOOL
187 dnl
188 dnl dietlibc stuff ends here}
189 dnl
190 dnl ##########################
191
192
193 ENSC_UV_VROOTDIR(vserverdir)
194 ENSC_CHANGELOG
195
196
197 dnl ##########################
198 dnl
199 dnl {Check whether to use external kernel headers
200 dnl
201 AC_MSG_CHECKING([whether to use internal kernel headers])
202 AC_ARG_ENABLE([internal-headers],
203               [AC_HELP_STRING([--disable-internal-headers],
204                               [use vserver specific headers from the kernel instead of the shipped versions (default: no)])],
205               [case "$enableval" in
206                   (yes|no) ;;
207                   (*)      AC_MSG_ERROR(['$i' is not a supported value for '--disable-internal-headers']);;
208                esac],
209               [enable_internal_headers=yes])
210
211 AM_CONDITIONAL(ENSC_ENABLE_INTERNAL_HEADERS, [test x"$enable_internal_headers" = xyes])
212 AC_MSG_RESULT([$enable_internal_headers])
213 dnl
214 dnl the check regarding external kernel headers ends here}
215 dnl
216 dnl ##########################
217
218 dnl ##########################
219 dnl
220 dnl {Check for the APIs to be used
221 dnl
222 AH_TEMPLATE(VC_ENABLE_API_COMPAT,   [Enable support for compatibility syscall API])
223 AH_TEMPLATE(VC_ENABLE_API_LEGACY,   [Enable support for old, /proc parsing API])
224 AH_TEMPLATE(VC_ENABLE_API_V11,      [Enable support for API of vserver 1.1.x])
225 AH_TEMPLATE(VC_ENABLE_API_FSCOMPAT, [Enable support for filesystem compatibility API])
226 AH_TEMPLATE(VC_ENABLE_API_V13OBS,   [Enable support for some obsoleted API of vserver 1.3.x])
227 AH_TEMPLATE(VC_ENABLE_API_V13,      [Enable support for API of vserver 1.3.x])
228 AH_TEMPLATE(VC_ENABLE_API_NET,      [Enable support for network context API])
229 AH_TEMPLATE(VC_ENABLE_API_V21,      [Enable support for API of vserver 2.1.x])
230 AH_TEMPLATE(VC_ENABLE_API_V22,      [Enable support for API of vserver 2.2.x])
231 AH_TEMPLATE(VC_ENABLE_API_V23,      [Enable support for API of vserver 2.3.x])
232 AH_TEMPLATE(VC_ENABLE_API_NETV2,    [Enable support for new networking API])
233 AH_TEMPLATE(VC_ENABLE_API_OLDPROC,  [Enable API for a backward compatible /proc parsing])
234 AH_TEMPLATE(VC_ENABLE_API_OLDUTS,   [Enable API for a backward compatible uts handling])
235
236 AC_MSG_CHECKING([for supported APIs])
237 AC_ARG_ENABLE([apis],
238               [AC_HELP_STRING([--enable-apis=APIS],
239                               [enable support for the given apis; possible values are: legacy,compat,v11,fscompat,v13obs,v13,net,v21,v22,v23,netv2 ALL,NOLEGACY (default: v13,net,v21,v22,v23,netv2)])],
240               [],
241               [enable_apis=v13,net,v21,v22,v23,netv2])
242
243 test x"$enable_apis" != xALL      || enable_apis='legacy,compat,v11,fscompat,v13obs,v13,net,v21,v22,v23,netv2'
244 test x"$enable_apis" != xNOLEGACY || enable_apis='compat,v11,fscompat,v13,net,v21,v22,v23,netv2'
245 enable_api_oldproc=
246 enable_api_olduts=
247 old_IFS=$IFS
248 IFS=,;
249
250 for i in $enable_apis; do
251         case "$i" in
252                 (compat)        AC_DEFINE(VC_ENABLE_API_COMPAT,   1)
253                                 enable_api_oldproc=${enable_api_oldproc:-1}
254                                 enable_api_olduts=${enable_api_olduts:-1}
255                                 ;;
256                 (legacy)        AC_DEFINE(VC_ENABLE_API_LEGACY,   1)
257                                 enable_api_oldproc=${enable_api_oldproc:-1}
258                                 enable_api_olduts=${enable_api_olduts:-1}
259                                 ;;
260                 (v11)           AC_DEFINE(VC_ENABLE_API_V11,      1)
261                                 enable_api_oldproc=${enable_api_oldproc:-1}
262                                 enable_api_olduts=${enable_api_olduts:-1}
263                                 ;;
264                 (fscompat)      AC_DEFINE(VC_ENABLE_API_FSCOMPAT, 1);;
265                 (v13obs)        AC_DEFINE(VC_ENABLE_API_V13OBS,   1)
266                                 AC_DEFINE(VC_ENABLE_API_V13,      1);;
267                 (v13)           AC_DEFINE(VC_ENABLE_API_V13,      1);;
268                 (net)           AC_DEFINE(VC_ENABLE_API_NET,      1);;
269                 (v21)           AC_DEFINE(VC_ENABLE_API_V21,      1);;
270                 (v22)           AC_DEFINE(VC_ENABLE_API_V22,      1);;
271                 (v23)           AC_DEFINE(VC_ENABLE_API_V23,      1);;
272                 (netv2)         AC_DEFINE(VC_ENABLE_API_NETV2,    1);;
273                 (oldproc)       enable_api_oldproc=2;;
274                 (olduts)        enable_api_olduts=2;;
275                 (*)             AC_MSG_ERROR(['$i' is not a supported API]);;
276         esac
277 done
278 IFS=$old_IFS
279 if test x"$enable_api_oldproc" != x; then
280         AC_DEFINE(VC_ENABLE_API_OLDPROC, 1)
281         test x"$enable_api_oldproc" != x2 && enable_apis="$enable_apis,oldproc"
282 fi
283 if test x"$enable_api_olduts" != x; then
284         AC_DEFINE(VC_ENABLE_API_OLDUTS, 1)
285         test x"$enable_api_olduts" != x2 && enable_apis="$enable_apis,olduts"
286 fi
287 AC_MSG_RESULT([$enable_apis])
288 dnl
289 dnl the check for used APIs ends here}
290 dnl
291 dnl ##########################
292
293
294 ENSC_CHECK_EXT2FS_HEADER
295 AC_CHECK_FUNCS([vserver])
296 AC_CHECK_DECLS(MS_MOVE,,,[#include <linux/fs.h>])
297 AC_CHECK_TYPES(xid_t,,,[#include <sys/types.h>])
298 AC_CHECK_TYPES(nid_t,,,[#include <sys/types.h>])
299 AC_CHECK_TYPES(tag_t,,,[#include <sys/types.h>])
300
301 AC_CHECK_HEADERS([sys/capability.h])
302
303 dnl vlogin might need -lutil
304 if test x"$ensc_have_dietlibc" = xno; then
305         AC_CHECK_FUNC([openpty],, [AC_CHECK_LIB([util], [openpty],, [AC_MSG_ERROR([
306 ****
307 **** openpty could not be found
308 ****])])])
309 fi
310
311
312 dnl ########################
313 dnl
314 dnl {check for beecrypt
315 dnl
316 if test x"$ensc_cv_c99_c99compiler" = xyes; then
317         ensc_have_beecrypt=yes
318
319         if test x"$ensc_have_beecrypt" = xyes; then
320                 AC_CHECK_HEADER([beecrypt/beecrypt.h], [ : ],
321                                 [ ensc_have_beecrypt=no ])
322         fi
323                         
324         if test x"$ensc_have_beecrypt" = xyes; then
325                 AC_CHECK_LIB(beecrypt, hashFunctionContextInit, [ : ],
326                              [ ensc_have_beecrypt=no ])
327         fi
328
329         if test x"$ensc_have_beecrypt" != xyes; then
330                 AC_MSG_WARN([
331 ****
332 **** 'beecrypt' could not be found;
333 **** this will disable the build of 'vhashify'
334 ****])
335         fi
336 else
337         ensc_have_beecrypt=no
338 fi
339
340 AM_CONDITIONAL(ENSC_HAVE_BEECRYPT, test x"$ensc_have_beecrypt" = xyes)
341 AM_CONDITIONAL(ENSC_CAN_BEECRYPT_WITH_DIETLIBC, false)
342 dnl
343 dnl beecrypt stuff ends here}
344 dnl
345 dnl ########################
346
347
348 dnl Check what distro this is, use Gentoo initscripts if appropriate
349 AC_MSG_CHECKING([for host initscripts])
350 AC_ARG_WITH(initscripts, AC_HELP_STRING([--with-initscripts=TYPE], [force host initscripts; valid values are 'gentoo' and 'sysv' (default: guess)]), [
351         case "$withval" in
352         gentoo) ensc_with_init=gentoo;;
353         sysv)   ensc_with_init=sysv;;
354         *)      AC_MSG_ERROR([invalid initscripts value, only gentoo and sysv are supported]);;
355         esac
356         ], [
357         if test -e /etc/gentoo-release; then
358                 ensc_with_init=gentoo
359         else
360                 ensc_with_init=sysv
361         fi
362         ])
363 AC_MSG_RESULT([$ensc_with_init])
364 AM_CONDITIONAL(HAVE_GENTOO_INIT, test x"$ensc_with_init" = xgentoo)
365 AM_CONDITIONAL(HAVE_SYSV_INIT, test x"$ensc_with_init" = xsysv)
366
367
368 dnl BIG HACK! Do some autodetection here!
369 AC_DEFINE(UTMP_GID, [22], [The utmp gid-number])
370
371 if false; then
372         AC_DEFINE(HAVE_GROWING_STACK, [1], [Define to 1 if the stack is on growing addresses])
373 fi
374
375 AC_DEFINE(_FILE_OFFSET_BITS, [64], [Use 64bit interface for filesystem operations])
376
377 dnl ########################
378 dnl
379 dnl {The final info-page
380 dnl
381 ensc_cxx_affected=" (affected: vbuild, vcheck)"
382 ensc_c99_affected=" (affected: vunify, vcopy, vhashify, vdlimit)"
383 ensc_diet_msg=" (you have been warned)"
384 ensc_diet_version_msg=" ($ensc_version_dietlibc)"
385 ensc_diet_compat_msg=" (using -lcompat)"
386 test x"$ensc_cv_cxx_cxxcompiler"    = xno || ensc_cxx_affected=
387 test x"$ensc_cv_c99_c99compiler"    = xno || ensc_c99_affected=
388 test x"$ensc_have_dietlibc"         = xno || ensc_diet_msg=
389 test x"$ensc_version_dietlibc"     != x   || ensc_diet_version_msg=
390 test x"$ensc_have_dietlibc$ensc_cv_c_dietlibc_compat" = xyesyes || ensc_diet_compat_msg=
391
392 AH_BOTTOM([#include "compat.h"
393 ])
394 AC_CONFIG_COMMANDS_PRE([
395                         FEATURES_TXT="\
396 Features:
397                        CC: $CC, $($CC   --version | sed -e '1p;d')
398                       CXX: $CXX, $($CXX --version | sed -e '1p;d')
399                  CPPFLAGS: '$CPPFLAGS'
400                    CFLAGS: '$CFLAGS'
401                  CXXFLAGS: '$CXXFLAGS'
402                build/host: $build/$host
403              Use dietlibc: $ensc_have_dietlibc$ensc_diet_version_msg$ensc_diet_msg$ensc_diet_compat_msg
404        Build C++ programs: $ensc_cv_cxx_cxxcompiler$ensc_cxx_affected
405        Build C99 programs: $ensc_cv_c99_c99compiler$ensc_c99_affected
406            Available APIs: $enable_apis
407             ext2fs Source: $ensc_cv_test_ext2fs_header
408     syscall(2) invocation: $with_syscall
409       vserver(2) syscall#: $ensc_cv_value_syscall_vserver
410    
411 Paths:
412                    prefix: $prefix
413         sysconf-Directory: $sysconfdir
414             cfg-Directory: $sysconfdir/vservers
415          initrd-Directory: $initrddir
416        pkgstate-Directory: $localstatedir/run/vservers
417           vserver-Rootdir: $vserverdir
418 "
419                         echo "$FEATURES_TXT" >FEATURES.txt
420                         ])
421 dnl
422 dnl final info-page ends here}
423 dnl
424 dnl ########################
425
426 AC_CONFIG_FILES([util-vserver.spec Makefile distrib/Makefile lib/apidoc/Doxyfile])
427 AC_OUTPUT
428
429 AC_MSG_NOTICE([
430
431 $PACKAGE_STRING
432
433 $FEATURES_TXT])