configure.ac : remove enable_foo checks for non-linux OSs
PATCH 1/1 configure.ac : remove enable_foo checks for non-linux OSs
Hello,
I implemented this idea from the TODO list, basically it sets some enable_foo constants for non-linux systems to "no" at start and then we can skip if-tests on different places.
From the todo:
build-sys
--------
- we use something like
AC_ARG_ENABLE(...., enable_foo=check) build_foo=yes
if test "x$enable_foo" = xcheck; then
if test "x$linux_os" = xno; then
build_foo=no
fi
fi
AM_CONDITIONAL(BUILD_LIBMOUNT, test "x$build_foo" = xyes)
for Linux-only utils in configure.ac. It would be nice to set all defaults for all $enable_ variables at begin of the configure script according to $linux_os. Something like:
if test "x$linux_os" = xno
enable_mount=no
enable_libmount=no
enable_lsblk=no
fi
then we can remove all "if test "x$enable_foo" = xcheck;" stuff from the
rest
of the configure script.
Thanks, Marek
PS: The TODO list is a good thing, if you write the task more detailed (like this one), more people can easily implement it.
---
diff -Nruw util-linux/configure.ac util-linux-mmm/configure.ac
configure.ac 2011-02-01 11:20:08.860000019 +0100 renamed from configure.ac 2011-02-01 00:26:23.603333351 +0100 +43 -4
@@ -334,13 +334,52 @@ AS_HELP_STRING([--disable-mount], [do not build mount utilities]), [], enable_mount=check ) -build_mount=yes -if test "x$enable_mount" = xcheck; then - if test "x$linux_os" = xno; then + +AC_ARG_ENABLE([libmount], + AS_HELP_STRING([--disable-libmount], [do not build libmount]), + [], enable_libmount=check +) + +C_ARG_ENABLE([switch_root], + AS_HELP_STRING([--disable-switch_root], [do not build switch_root]), + [], enable_switch_root=check +) + +AC_ARG_ENABLE([pivot_root], + AS_HELP_STRING([--disable-pivot_root], [do not build pivot_root]), + [], enable_pivot_root=check +) + +AC_ARG_ENABLE([fallocate], + AS_HELP_STRING([--disable-fallocate], [do not build fallocate]), + [], enable_fallocate=check +) + +AC_ARG_ENABLE([unshare], + AS_HELP_STRING([--disable-unshare], [do not build unshare]), + [], enable_unshare=check +) + + +# we do not build these for non-linux os +if test "x$linux_os" = xno AC_MSG_WARN([non-linux system; do not build mount utilities]) build_mount=no + AC_MSG_WARN([non-linux system; do not build libmount]) + build_libmount=no + AC_MSG_WARN([non-linux system; do not build switch_root]) + build_switch_root=no + AC_MSG_WARN([non-linux system; do not build pivot_root]) + build_pivot_root=no + AC_MSG_WARN([non-linux system; do not build fallocate]) + build_fallocate=no + AC_MSG_WARN([non-linux system; do not build unshare]) + build_unshare=no fi -elif test "x$enable_mount" = xno; then + + +build_mount=yes +if test "x$enable_mount" = xno; then build_mount=no fi AM_CONDITIONAL(BUILD_MOUNT, test "x$build_mount" = xyes)
@@ -459,17 +498,8 @@ AC_ARG_VAR([BLKID_LIBS_STATIC], [-l options for linking statically with
blkid])
-AC_ARG_ENABLE([libmount],
- AS_HELP_STRING([--disable-libmount], [do not build libmount]),
- [], enable_libmount=check
-)
build_libmount=yes
-if test "x$enable_libmount" = xcheck; then
- if test "x$linux_os" = xno; then
- AC_MSG_WARN([non-linux system; do not build libmount])
- build_libmount=no
- fi
-elif test "x$enable_libmount" = xno; then
+if test "x$enable_libmount" = xno; then
build_libmount=no
fi
@@ -872,19 +902,10 @@
AM_CONDITIONAL(BUILD_CRAMFS, test "x$build_cramfs" = xyes)
-AC_ARG_ENABLE([switch_root],
- AS_HELP_STRING([--disable-switch_root], [do not build switch_root]),
- [], enable_switch_root=check
-)
+build_switch_root=yes
if test "x$enable_switch_root" = xno; then
build_switch_root=no
-else
- build_switch_root=yes - case $enable_switch_root:$linux_os in - yes:no) AC_MSG_ERROR([switch_root selected for non-linux system]);; - check:no) AC_MSG_WARN([non-linux system; do not build switch_root])
- build_switch_root=no;;
- esac
+fi
if test "x$build_switch_root" = xyes; then
case $enable_switch_root:$have_openat in
yes:no) AC_MSG_ERROR([switch_root selected but openat() function not
found]);;
@@ -892,23 +913,13 @@
build_switch_root=no;;
esac fi
-fi
AM_CONDITIONAL(BUILD_SWITCH_ROOT, test "x$build_switch_root" = xyes)
-AC_ARG_ENABLE([pivot_root],
- AS_HELP_STRING([--disable-pivot_root], [do not build pivot_root]),
- [], enable_pivot_root=check
-)
+build_pivot_root=yes
if test "x$enable_pivot_root" = xno; then
build_pivot_root=no
-else
- build_pivot_root=yes - case $enable_pivot_root:$linux_os in - yes:no) AC_MSG_ERROR([pivot_root selected for non-linux system]);; - check:no) AC_MSG_WARN([non-linux system; do not build pivot_root])
- build_pivot_root=no;;
- esac
+fi
if test "x$build_pivot_root" = xyes; then
case $enable_pivot_root:$util_cv_syscall_pivot_root in yes:no) AC_MSG_ERROR([pivot_root selected but pivot_root syscall not
found]);;
@@ -916,23 +927,13 @@
build_pivot_root=no;;
esac fi
-fi
AM_CONDITIONAL(BUILD_PIVOT_ROOT, test "x$build_pivot_root" = xyes)
-AC_ARG_ENABLE([fallocate],
- AS_HELP_STRING([--disable-fallocate], [do not build fallocate]),
- [], enable_fallocate=check
-)
+build_fallocate=yes
if test "x$enable_fallocate" = xno; then
build_fallocate=no
-else
- build_fallocate=yes - case $enable_fallocate:$linux_os in - yes:no) AC_MSG_ERROR([fallocate selected for non-linux system]);; - check:no) AC_MSG_WARN([non-linux system; do not build fallocate])
- build_fallocate=no;;
- esac
+fi
if test "x$build_fallocate" = xyes; then
case $enable_fallocate:$util_cv_syscall_fallocate in yes:no) AC_MSG_ERROR([fallocate selected but fallocate syscall not
found]);;
@@ -940,23 +941,13 @@
build_fallocate=no;;
esac fi
-fi
AM_CONDITIONAL(BUILD_FALLOCATE, test "x$build_fallocate" = xyes)
-AC_ARG_ENABLE([unshare],
- AS_HELP_STRING([--disable-unshare], [do not build unshare]),
- [], enable_unshare=check
-)
+build_unshare=yes
if test "x$enable_unshare" = xno; then
build_unshare=no
-else
- build_unshare=yes - case $enable_unshare:$linux_os in - yes:no) AC_MSG_ERROR([unshare selected for non-linux system]);; - check:no) AC_MSG_WARN([non-linux system; do not build unshare])
- build_unshare=no;;
- esac
+fi
if test "x$build_unshare" = xyes; then
case $enable_unshare:$util_cv_syscall_unshare in
yes:no) AC_MSG_ERROR([unshare selected but unshare syscall not found]);;
@@ -964,11 +955,9 @@
build_unshare=no;;
esac fi
-fi
AM_CONDITIONAL(BUILD_UNSHARE, test "x$build_unshare" = xyes)
-
AC_ARG_ENABLE([elvtune],
AS_HELP_STRING([--enable-elvtune], [build elvtune (only works with 2.2 and
2.4 kernels)]),
[], enable_elvtune=no
Signature · 1 line
Marek Otahal :o)
Karel Zak
maintainerQuoted 2 lines · Marek Otahal
PS: The TODO list is a good thing, if you write the task more detailed (like this one), more people can easily implement it.
OK :-)
Quoted 5 lines
configure.ac 2011-02-01 11:20:08.860000019 +0100 renamed from configure.ac 2011-02-01 00:26:23.603333351 +0100 +3
-0+# we do not build these for non-linux os +if test "x$linux_os" = xno AC_MSG_WARN([non-linux system; do not build mount utilities]) build_mount=no + AC_MSG_WARN([non-linux system; do not build libmount])
configure.ac 2011-02-01 11:20:08.860000019 +0100 line 378
Quoted 10 lines
configure.ac 2011-02-01 11:20:08.860000019 +0100 renamed from configure.ac 2011-02-01 00:26:23.603333351 +0100 +9
-0+ build_libmount=no + AC_MSG_WARN([non-linux system; do not build switch_root]) + build_switch_root=no + AC_MSG_WARN([non-linux system; do not build pivot_root]) + build_pivot_root=no + AC_MSG_WARN([non-linux system; do not build fallocate]) + build_fallocate=no + AC_MSG_WARN([non-linux system; do not build unshare]) + build_unshare=no fi
This is not exactly what I mean. In your implementation are Linux-only things disable at all, so if you explicitly
./configure --enable-unshare
then the configure script will ignore this request and unshare(1) will be disabled. That's wrong (and for some utils is the current implementation wrong too).
The configure script should not be more smart than user. We need to care about default settings (if --disable/enable is not specified) only. Currently the default is "check", I'd like to modify the default according to $linux_os.
Something like:
linuxonly_default=check
if test "x$linux_os" = xno
AC_MSG_WARN([non-linux system; unshare(1), libmount, ...
are disabled by default. Use --enable-<name> to enable required util(s)])
linuxonly_default=no
fi
AC_ARG_ENABLE([unshare],
AS_HELP_STRING([--disable-unshare], [do not build unshare]), [], enable_unshare=$linuxonly_default)
AM_CONDITIONAL(BUILD_UNSHARE, test "x$enable_unshare" != xno)
maybe that for some utils it will be necessary to do some extra checks before AM_CONDITIONAL() -- for example to detect that systems has proper syscall (e.g. switch_root depends on openat()).
Note that this is nothing urgent, it's too late for v2.19 release.
Karel
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com