minor optimizations
[util-vserver.git] / util-vserver / configure.ac
index 18c33f3..aa87e7d 100644 (file)
@@ -1,6 +1,6 @@
 dnl $Id$
 
-dnl Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
+dnl Copyright (C) 2003,2004 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
 dnl  
 dnl This program is free software; you can redistribute it and/or modify
 dnl it under the terms of the GNU General Public License as published by
@@ -24,80 +24,217 @@ dnl distribution terms that you use for the rest of that program.
 dnl  
 
 AC_PREREQ(2.57)
-AC_INIT(util-vserver, 0.23.89.1, enrico.scholz@informatik.tu-chemnitz.de)
+AC_INIT(util-vserver, 0.30.190, enrico.scholz@informatik.tu-chemnitz.de)
 AC_CONFIG_SRCDIR([src/capchroot.c])
 AC_CONFIG_HEADER([config.h])
 
-AM_INIT_AUTOMAKE([gnu dist-bzip2 subdir-objects])
+AM_INIT_AUTOMAKE([gnits dist-bzip2 subdir-objects])
 AM_MAINTAINER_MODE
 
+AC_SUBST(GPG_KEY, "0x7AE5D4B5922F7AF9!")
 
 # Checks for programs.
 AC_PROG_CXX
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
-AC_PROG_RANLIB
+dnl AC_PROG_RANLIB
+AC_PROG_LIBTOOL
 AM_PROG_CC_C_O
+ENSC_CXXCOMPILER
+ENSC_C99COMPILER
 
-ENSC_CHECK_CC_FLAG([-std=c99])
+check_paths=$PATH:/sbin:/usr/sbin:/usr/local/sbin
+AC_PATH_PROGS(AWK,     [awk],     [awk],         [ $check_paths ])
+AC_PATH_PROGS(GREP,    [grep],    [grep],        [ $check_paths ])
+AC_PATH_PROGS(IP,      [ip],      [ip],          [ $check_paths ])
+AC_PATH_PROGS(MOUNT,   [mount],   [/bin/mount],  [ $check_paths ])
+AC_PATH_PROGS(UMOUNT,  [umount],  [/bin/umount], [ $check_paths ])
+AC_PATH_PROGS(NICE,    [nice],    [nice],        [ $check_paths ])
+AC_PATH_PROGS(VCONFIG, [vconfig], [vconfig],     [ $check_paths ])
+AC_PATH_PROGS(WC,      [wc],      [wc],          [ $check_paths ])
+AC_PATH_PROGS(PS,      [ps],      [/bin/ps],     [ $check_paths ])
+AC_PATH_PROGS(MODPROBE, [modprobe], [/sbin/modprobe], [ $check_paths ])
+AC_PATH_PROGS(RMMOD,    [rmmod],    [/sbin/rmmod],    [ $check_paths ])
+AC_PATH_PROGS(NAMEIF,   [nameif],   [/sbin/nameif],   [ $check_paths ])
+AC_PATH_PROGS(IPTABLES, [iptables], [/sbin/iptables], [ $check_paths ])
+AC_PATH_PROGS(ENV,      [env],      [/usr/bin/env])
+AC_PATH_PROGS(SED,      [sed],      [sed])
+AC_PATH_PROGS(CMP,      [cmp],      [cmp])
+AC_PATH_PROGS(WGET,     [wget],     [wget])
+AC_PATH_PROGS(DOXYGEN,  [doxygen],  [:])
+AC_PATH_PROGS(TAR,      [tar])
+AC_PATH_PROGS(XSLTP,    [xsltp])
+
+AM_CONDITIONAL(HAVE_XSLTP, test "$XSLTP")
+       
+
+ENSC_CHECK_CC_FLAG([-std=c99 -Wall -pedantic -W])
+ENSC_CHECK_CXX_FLAG([-ansi   -Wall -pedantic -W -fmessage-length=0])
+
+ENSC_FPIC_SYSCALL
 
-AC_MSG_CHECKING([whether to enable dietlibc])
-AC_ARG_ENABLE([dietlibc],
-             [AC_HELP_STRING([--disable-dietlibc],
-                             [do not use dietlibc (default: use dietlibc)])],
-             [case "$withval" in
-                 yes)  use_dietlibc=forced;;
-                 no)   use_dietlibc=forced_no;;
-                 *)    AC_MSG_ERROR(['$withval' is not a valid value for --enable-dietlibc]);;
-              esac],
-             [: ${DIET:=diet}
-              which "$DIET" >/dev/null 2>/dev/null && use_dietlibc=detected || use_dietlibc=detected_no])
-
-case x"$use_dietlibc" in
-    xdetected)
-       AM_CONDITIONAL(USE_DIETLIBC, true)
-       AC_MSG_RESULT([yes (autodetected)])
-       ;;
-    xforced)
-       AM_CONDITIONAL(USE_DIETLIBC, true)
-       AC_MSG_RESULT([yes (forced)])
-       ;;
-    xdetected_no)
-       AM_CONDITIONAL(USE_DIETLIBC, false)
-       AC_MSG_RESULT([no (detected)])
-       ;;
-    xforced_no)
-       AM_CONDITIONAL(USE_DIETLIBC, false)
-       AC_MSG_RESULT([no (forced)])
-       ;;
-    *)
-       AC_MSG_ERROR([internal error, use_dietlibc was "$use_dietlibc"])
-       ;;
-esac
+
+AC_MSG_CHECKING([whether to enable debug-code in library])
+AC_ARG_ENABLE([lib-debug],
+             [AC_HELP_STRING([--enable-lib-debug],
+                              [enable additional debug code in library (default: no)])],
+              [case "$enableval" in
+                 yes)  use_lib_debug=1;;
+                  no)   use_lib_debug=;;
+                  *)    AC_MSG_ERROR(['$enableval' is not a valid value for '--enable-lib-debug']);;
+               esac],
+              [ use_lib_debug= ])
+
+if test x"$use_lib_debug" = x; then
+       AC_SUBST(LIB_DEBUG_CPPFLAGS, [-DNDEBUG])
+       AC_MSG_RESULT(no)
+else
+       AC_SUBST(LIB_DEBUG_CPPFLAGS, [])
+       AC_MSG_RESULT(yes)
+fi
 
 AC_ARG_VAR(CC, [The C compiler])
-AC_MSG_CHECKING([for linux kernel headers])
-AC_ARG_WITH([kerneldir],
-           [AC_HELP_STRING([--with-kerneldir=DIR],
-                            [assume top-kernelsources in DIR (default: /lib/modules/<current>/build)])],
-            [case "$withval" in
-               yes|no) AC_MSG_ERROR(['$withval' is not a valid value for kerneldir]);;
-               *)      kerneldir=$withval;;
-            esac],
-           [kerneldir=
-            for i in /lib/modules/$(uname -r)/build /usr/src/linux /usr; do
-               test -e $i/include/linux/version.h && { kerneldir=$i; break; }
-            done])
-
-test "$kerneldir" -a -e $i/include/linux/version.h || {
-       AC_MSG_ERROR([Can not find kernelsources])
-}
-
-kernelincludedir=$kerneldir/include
-AC_SUBST(kernelincludedir)
-AC_MSG_RESULT($kernelincludedir/linux)
-               
-
-AC_CONFIG_FILES([util-vserver.spec Makefile distrib/Makefile])
+
+ENSC_INITRDDIR(initrddir)
+ENSC_RELEASE(RELEASE_CPPFLAGS)
+ENSC_ENABLE_DIETLIBC(USE_DIETLIBC, [0.24])
+
+if test x"$ensc_have_dietlibc" = xno; then
+       AC_MSG_WARN([***                                                         ***])
+       AC_MSG_WARN([*** it is strongly recommended to link util-vserver against ***])
+       AC_MSG_WARN([*** dietlibc;  glibc's NSS functions are very unreliable in ***])
+       AC_MSG_WARN([*** chroot() environments,  so you have to  expect problems ***])
+       AC_MSG_WARN([*** there.                                                  ***])
+       AC_MSG_WARN([***                                                         ***])
+       AM_CONDITIONAL(USE_DIETLIBC_COMPAT, false)
+else
+       ENSC_DIETLIBC_NEED_COMPAT(USE_DIETLIBC_COMPAT)
+fi
+
+
+ENSC_KERNEL_HEADERS(kernelincludedir)
+ENSC_UV_VROOTDIR(vserverdir)
+ENSC_CHANGELOG([trunk])
+
+dnl Check whether to use external kernel headers
+AC_MSG_CHECKING([whether to use internal kernel headers])
+AC_ARG_ENABLE([internal-headers],
+              [AC_HELP_STRING([--disable-internal-headers],
+                              [use vserver specific headers from the kernel instead of the shipped versions (default: no)])],
+              [case "$enableval" in
+                 yes|no) ;;
+                 *)      AC_MSG_ERROR(['$i' is not a supported value for '--disable-internal-headers']);;
+              esac],
+              [enable_internal_headers=yes])
+
+AM_CONDITIONAL(ENSC_ENABLE_INTERNAL_HEADERS, [test x"$enable_internal_headers" = xyes])
+AC_MSG_RESULT([$enable_internal_headers])
+
+
+dnl Check for the APIs to be used
+AC_MSG_CHECKING([for supported APIs])
+AC_ARG_ENABLE([apis],
+             [AC_HELP_STRING([--enable-apis=APIS],
+                             [enable support for the given apis; possible values are: legacy,compat,v11,v13,fscompat,net,ALL (default: all except 'legacy')])],
+              [],
+             [enable_apis=compat,v11,v13,fscompat,net])
+
+test x"$enable_apis" != xALL || enable_apis='legacy,compat,v11,v13,fscompat,net'
+enable_api_oldproc=
+enable_api_olduts=
+old_IFS=$IFS
+IFS=,;
+for i in $enable_apis; do
+       case "$i" in
+               compat)         AC_DEFINE(VC_ENABLE_API_COMPAT,   1, [Enable support for compatibility syscall API])
+                               enable_api_oldproc=1
+                               enable_api_olduts=1
+                               ;;
+               legacy)         AC_DEFINE(VC_ENABLE_API_LEGACY,   1, [Enable support for old, /proc parsing API])
+                               enable_api_old_proc=1
+                               enable_api_olduts=1
+                               ;;
+               v11)            AC_DEFINE(VC_ENABLE_API_V11,      1, [Enable support for API of vserver 1.1.x])
+                               enable_api_oldproc=1
+                               enable_api_olduts=1
+                               ;;
+               v13)            AC_DEFINE(VC_ENABLE_API_V13,      1, [Enable support for API of vserver 1.3.x]);;
+               net)            AC_DEFINE(VC_ENABLE_API_NET,      1, [Enable support for network context API]);;
+               fscompat)       AC_DEFINE(VC_ENABLE_API_FSCOMPAT, 1, [Enable support for filesystem compatibility API]);;
+               *)              AC_MSG_ERROR(['$i' is not a supported API]);;
+       esac
+done
+IFS=$old_IFS
+if test x"$enable_api_oldproc" != x; then
+       AC_DEFINE(VC_ENABLE_API_OLDPROC, 1, [Enable API for a backward compatible /proc parsing])
+       enable_apis="$enable_apis,oldproc"
+fi
+if test x"$enable_api_olduts" != x; then
+       AC_DEFINE(VC_ENABLE_API_OLDUTS, 1, [Enable API for a backward compatible uts handling])
+       enable_apis="$enable_apis,olduts"
+fi
+AC_MSG_RESULT([$enable_apis])
+
+ENSC_SYSCALLNR(vserver,273)
+ENSC_SYSCALL
+ENSC_CHECK_EXT2FS_HEADER
+AC_CHECK_FUNCS([vserver])
+AC_CHECK_DECLS(MS_MOVE,,,[#include <linux/fs.h>])
+AC_CHECK_TYPES(xid_t,,,[#include <sys/types.h>])
+AC_CHECK_TYPES(nid_t,,,[#include <sys/types.h>])
+
+dnl BIG HACK! Do some autodetection here!
+AC_DEFINE(UTMP_GID, [22], [The utmp gid-number])
+
+if false; then
+       AC_DEFINE(HAVE_GROWING_STACK, [1], [Define to 1 if the stack is on growing addresses])
+fi
+
+
+ensc_cxx_affected=" (affected: vbuild, vcheck)"
+ensc_c99_affected=" (affected: vunify, vcopy)"
+ensc_diet_msg=" (you have been warned)"
+ensc_diet_compat_msg=" (using -lcompat)"
+test x"$ensc_cv_cxx_cxxcompiler"    = xno || ensc_cxx_affected=
+test x"$ensc_cv_c99_c99compiler"    = xno || ensc_c99_affected=
+test x"$ensc_have_dietlibc"         = xno || ensc_diet_msg=
+test x"$ensc_have_dietlibc$ensc_cv_c_dietlibc_compat" = xyesyes || ensc_diet_compat_msg=
+
+AH_BOTTOM([#include "compat.h"])
+AC_CONFIG_COMMANDS_PRE([
+                       FEATURES_TXT="\
+Features:
+                      CC: $CC, $($CC   --version | sed -e '1p;d')
+                      CXX: $CXX, $($CXX --version | sed -e '1p;d')
+                 CPPFLAGS: '$CPPFLAGS'
+                   CFLAGS: '$CFLAGS'
+                 CXXFLAGS: '$CXXFLAGS'
+               build/host: $build/$host
+             Use dietlibc: $ensc_have_dietlibc$ensc_diet_msg$ensc_diet_compat_msg
+       Build C++ programs: $ensc_cv_cxx_cxxcompiler$ensc_cxx_affected
+       Build C99 programs: $ensc_cv_c99_c99compiler$ensc_c99_affected
+           Available APIs: $enable_apis
+            ext2fs Source: $ensc_cv_test_ext2fs_header
+    syscall(2) invocation: $with_syscall
+      vserver(2) syscall#: $ensc_cv_value_syscall_vserver
+   
+Paths:
+                   prefix: $prefix
+        sysconf-Directory: $sysconfdir
+            cfg-Directory: $sysconfdir/vservers
+         initrd-Directory: $initrddir
+       pkgstate-Directory: $localstatedir/run/vservers
+            Kernelheaders: $kernelincludedir
+          vserver-Rootdir: $vserverdir
+"
+                       echo "$FEATURES_TXT" >FEATURES.txt
+                       ])
+AC_CONFIG_FILES([util-vserver.spec Makefile distrib/Makefile lib/apidoc/Doxyfile])
 AC_OUTPUT
+
+AC_MSG_NOTICE([
+
+$PACKAGE_STRING
+
+$FEATURES_TXT])