Make configure builtin-aware.

This patch adds a new option to configure: --enable-linux-builtin. When
this option is used, the following happens:

 - Compilation of kernel modules is disabled.

 - A failure to find UTS_RELEASE is followed by a suggestion to run
   "make prepare" on the kernel source tree.

This patch also adds a new test which tries to compile an empty module
as a basic toolchain sanity test. If it fails and the option was
specified, the error is followed by a suggestion to run "make scripts"
on the kernel source tree.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue zfsonlinux/zfs#851
This commit is contained in:
Etienne Dechamps 2012-07-16 16:34:43 +02:00 committed by Brian Behlendorf
parent 38b5ff4d07
commit 0408008b33
2 changed files with 257 additions and 62 deletions

View File

@ -22,6 +22,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
SPL_AC_DEBUG_LOG
SPL_AC_DEBUG_KMEM
SPL_AC_DEBUG_KMEM_TRACKING
SPL_AC_TEST_MODULE
SPL_AC_ATOMIC_SPINLOCK
SPL_AC_TYPE_ATOMIC64_CMPXCHG
SPL_AC_TYPE_ATOMIC64_XCHG
@ -94,7 +95,7 @@ AC_DEFUN([SPL_AC_CONFIG_KERNEL], [
AC_DEFUN([SPL_AC_MODULE_SYMVERS], [
modpost=$LINUX/scripts/Makefile.modpost
AC_MSG_CHECKING([kernel file name for module symbols])
if test -f "$modpost"; then
if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
if grep -q Modules.symvers $modpost; then
LINUX_SYMBOLS=Modules.symvers
else
@ -196,7 +197,13 @@ AC_DEFUN([SPL_AC_KERNEL], [
fi
else
AC_MSG_RESULT([Not found])
AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Cannot find UTS_RELEASE definition.])
else
AC_MSG_ERROR([
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree.])
fi
fi
AC_MSG_RESULT([$kernsrcver])
@ -439,34 +446,38 @@ AC_DEFUN([SPL_AC_LICENSE], [
])
AC_DEFUN([SPL_AC_CONFIG], [
SPL_CONFIG=all
AC_ARG_WITH([config],
AS_HELP_STRING([--with-config=CONFIG],
[Config file 'kernel|user|all|srpm']),
[SPL_CONFIG="$withval"])
SPL_CONFIG=all
AC_ARG_WITH([config],
AS_HELP_STRING([--with-config=CONFIG],
[Config file 'kernel|user|all|srpm']),
[SPL_CONFIG="$withval"])
AC_ARG_ENABLE([linux-builtin],
[AC_HELP_STRING([--enable-linux-builtin],
[Configure for builtin in-tree kernel modules @<:@default=no@:>@])],
[],
[enable_linux_builtin=no])
AC_MSG_CHECKING([spl config])
AC_MSG_RESULT([$SPL_CONFIG]);
AC_SUBST(SPL_CONFIG)
AC_MSG_CHECKING([spl config])
AC_MSG_RESULT([$SPL_CONFIG]);
AC_SUBST(SPL_CONFIG)
case "$SPL_CONFIG" in
kernel) SPL_AC_CONFIG_KERNEL ;;
user) SPL_AC_CONFIG_USER ;;
all) SPL_AC_CONFIG_KERNEL
SPL_AC_CONFIG_USER ;;
case "$SPL_CONFIG" in
kernel) SPL_AC_CONFIG_KERNEL ;;
user) SPL_AC_CONFIG_USER ;;
all) SPL_AC_CONFIG_KERNEL
SPL_AC_CONFIG_USER ;;
srpm) ;;
*)
AC_MSG_RESULT([Error!])
AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
user kernel|user|all|srpm]) ;;
esac
*)
AC_MSG_RESULT([Error!])
AC_MSG_ERROR([Bad value "$SPL_CONFIG" for --with-config,
user kernel|user|all|srpm]) ;;
esac
AM_CONDITIONAL([CONFIG_USER],
[test "$SPL_CONFIG" = user] ||
[test "$SPL_CONFIG" = all])
AM_CONDITIONAL([CONFIG_KERNEL],
[test "$SPL_CONFIG" = kernel] ||
[test "$SPL_CONFIG" = all])
AM_CONDITIONAL([CONFIG_USER],
[test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all])
AM_CONDITIONAL([CONFIG_KERNEL],
[test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all] &&
[test "x$enable_linux_builtin" != xyes ])
])
dnl #
@ -738,6 +749,25 @@ AC_DEFUN([SPL_CHECK_HEADER],
])
])
dnl #
dnl # Basic toolchain sanity check.
dnl #
AC_DEFUN([SPL_AC_TEST_MODULE],
[AC_MSG_CHECKING([whether modules can be built])
SPL_LINUX_TRY_COMPILE([],[],[
AC_MSG_RESULT([yes])
],[
AC_MSG_RESULT([no])
if test "x$enable_linux_builtin" != xyes; then
AC_MSG_ERROR([*** Unable to build an empty module.])
else
AC_MSG_ERROR([
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree.])
fi
])
])
dnl #
dnl # Use the atomic implemenation based on global spinlocks. This
dnl # should only be needed by 32-bit kernels which do not provide

237
configure vendored
View File

@ -962,6 +962,7 @@ enable_fast_install
with_gnu_ld
enable_libtool_lock
with_config
enable_linux_builtin
with_linux
with_linux_obj
enable_debug
@ -1619,6 +1620,8 @@ Optional Features:
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-linux-builtin Configure for builtin in-tree kernel modules
[default=no]
--enable-debug Enable generic debug support [default=no]
--enable-debug-log Enable basic debug logging [default=yes]
--enable-debug-kmem Enable basic kmem accounting [default=yes]
@ -4789,13 +4792,13 @@ if test "${lt_cv_nm_interface+set}" = set; then
else
lt_cv_nm_interface="BSD nm"
echo "int some_variable = 0;" > conftest.$ac_ext
(eval echo "\"\$as_me:4792: $ac_compile\"" >&5)
(eval echo "\"\$as_me:4795: $ac_compile\"" >&5)
(eval "$ac_compile" 2>conftest.err)
cat conftest.err >&5
(eval echo "\"\$as_me:4795: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval echo "\"\$as_me:4798: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
(eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
cat conftest.err >&5
(eval echo "\"\$as_me:4798: output\"" >&5)
(eval echo "\"\$as_me:4801: output\"" >&5)
cat conftest.out >&5
if $GREP 'External.*some_variable' conftest.out > /dev/null; then
lt_cv_nm_interface="MS dumpbin"
@ -6001,7 +6004,7 @@ ia64-*-hpux*)
;;
*-*-irix6*)
# Find out which ABI we are using.
echo '#line 6004 "configure"' > conftest.$ac_ext
echo '#line 6007 "configure"' > conftest.$ac_ext
if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
(eval $ac_compile) 2>&5
ac_status=$?
@ -7854,11 +7857,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:7857: $lt_compile\"" >&5)
(eval echo "\"\$as_me:7860: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:7861: \$? = $ac_status" >&5
echo "$as_me:7864: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -8193,11 +8196,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8196: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8199: $lt_compile\"" >&5)
(eval "$lt_compile" 2>conftest.err)
ac_status=$?
cat conftest.err >&5
echo "$as_me:8200: \$? = $ac_status" >&5
echo "$as_me:8203: \$? = $ac_status" >&5
if (exit $ac_status) && test -s "$ac_outfile"; then
# The compiler can only warn and ignore the option if not recognized
# So say no if there are warnings other than the usual output.
@ -8298,11 +8301,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8301: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8304: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:8305: \$? = $ac_status" >&5
echo "$as_me:8308: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -8353,11 +8356,11 @@ else
-e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-e 's:$: $lt_compiler_flag:'`
(eval echo "\"\$as_me:8356: $lt_compile\"" >&5)
(eval echo "\"\$as_me:8359: $lt_compile\"" >&5)
(eval "$lt_compile" 2>out/conftest.err)
ac_status=$?
cat out/conftest.err >&5
echo "$as_me:8360: \$? = $ac_status" >&5
echo "$as_me:8363: \$? = $ac_status" >&5
if (exit $ac_status) && test -s out/conftest2.$ac_objext
then
# The compiler can only warn and ignore the option if not recognized
@ -11156,7 +11159,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11159 "configure"
#line 11162 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11252,7 +11255,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
#line 11255 "configure"
#line 11258 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@ -11720,22 +11723,29 @@ fi
SPL_CONFIG=all
SPL_CONFIG=all
# Check whether --with-config was given.
if test "${with_config+set}" = set; then
withval=$with_config; SPL_CONFIG="$withval"
fi
# Check whether --enable-linux-builtin was given.
if test "${enable_linux_builtin+set}" = set; then
enableval=$enable_linux_builtin;
else
enable_linux_builtin=no
fi
{ $as_echo "$as_me:$LINENO: checking spl config" >&5
{ $as_echo "$as_me:$LINENO: checking spl config" >&5
$as_echo_n "checking spl config... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $SPL_CONFIG" >&5
{ $as_echo "$as_me:$LINENO: result: $SPL_CONFIG" >&5
$as_echo "$SPL_CONFIG" >&6; };
case "$SPL_CONFIG" in
kernel)
case "$SPL_CONFIG" in
kernel)
# Check whether --with-linux was given.
@ -11836,9 +11846,19 @@ $as_echo "$as_me: error: *** Cannot determine kernel version." >&2;}
else
{ $as_echo "$as_me:$LINENO: result: Not found" >&5
$as_echo "Not found" >&6; }
{ { $as_echo "$as_me:$LINENO: error: *** Cannot find UTS_RELEASE definition." >&5
if test "x$enable_linux_builtin" != xyes; then
{ { $as_echo "$as_me:$LINENO: error: *** Cannot find UTS_RELEASE definition." >&5
$as_echo "$as_me: error: *** Cannot find UTS_RELEASE definition." >&2;}
{ (exit 1); exit 1; }; }
else
{ { $as_echo "$as_me:$LINENO: error:
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree." >&5
$as_echo "$as_me: error:
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
{ $as_echo "$as_me:$LINENO: result: $kernsrcver" >&5
@ -11856,7 +11876,7 @@ $as_echo "$kernsrcver" >&6; }
modpost=$LINUX/scripts/Makefile.modpost
{ $as_echo "$as_me:$LINENO: checking kernel file name for module symbols" >&5
$as_echo_n "checking kernel file name for module symbols... " >&6; }
if test -f "$modpost"; then
if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
if grep -q Modules.symvers $modpost; then
LINUX_SYMBOLS=Modules.symvers
else
@ -12091,6 +12111,74 @@ $as_echo_n "checking whether detailed kmem tracking is enabled... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $enable_debug_kmem_tracking" >&5
$as_echo "$enable_debug_kmem_tracking" >&6; }
{ $as_echo "$as_me:$LINENO: checking whether modules can be built" >&5
$as_echo_n "checking whether modules can be built... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.c
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
if test "x$enable_linux_builtin" != xyes; then
{ { $as_echo "$as_me:$LINENO: error: *** Unable to build an empty module." >&5
$as_echo "$as_me: error: *** Unable to build an empty module." >&2;}
{ (exit 1); exit 1; }; }
else
{ { $as_echo "$as_me:$LINENO: error:
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree." >&5
$as_echo "$as_me: error:
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
rm -Rf build
# Check whether --enable-atomic-spinlocks was given.
if test "${enable_atomic_spinlocks+set}" = set; then
@ -16310,8 +16398,8 @@ fi
;;
user) ;;
all)
user) ;;
all)
# Check whether --with-linux was given.
@ -16412,9 +16500,19 @@ $as_echo "$as_me: error: *** Cannot determine kernel version." >&2;}
else
{ $as_echo "$as_me:$LINENO: result: Not found" >&5
$as_echo "Not found" >&6; }
{ { $as_echo "$as_me:$LINENO: error: *** Cannot find UTS_RELEASE definition." >&5
if test "x$enable_linux_builtin" != xyes; then
{ { $as_echo "$as_me:$LINENO: error: *** Cannot find UTS_RELEASE definition." >&5
$as_echo "$as_me: error: *** Cannot find UTS_RELEASE definition." >&2;}
{ (exit 1); exit 1; }; }
else
{ { $as_echo "$as_me:$LINENO: error:
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree." >&5
$as_echo "$as_me: error:
*** Cannot find UTS_RELEASE definition.
*** Please run 'make prepare' inside the kernel source tree." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
{ $as_echo "$as_me:$LINENO: result: $kernsrcver" >&5
@ -16432,7 +16530,7 @@ $as_echo "$kernsrcver" >&6; }
modpost=$LINUX/scripts/Makefile.modpost
{ $as_echo "$as_me:$LINENO: checking kernel file name for module symbols" >&5
$as_echo_n "checking kernel file name for module symbols... " >&6; }
if test -f "$modpost"; then
if test "x$enable_linux_builtin" != xyes -a -f "$modpost"; then
if grep -q Modules.symvers $modpost; then
LINUX_SYMBOLS=Modules.symvers
else
@ -16667,6 +16765,74 @@ $as_echo_n "checking whether detailed kmem tracking is enabled... " >&6; }
{ $as_echo "$as_me:$LINENO: result: $enable_debug_kmem_tracking" >&5
$as_echo "$enable_debug_kmem_tracking" >&6; }
{ $as_echo "$as_me:$LINENO: checking whether modules can be built" >&5
$as_echo_n "checking whether modules can be built... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.c
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
if test "x$enable_linux_builtin" != xyes; then
{ { $as_echo "$as_me:$LINENO: error: *** Unable to build an empty module." >&5
$as_echo "$as_me: error: *** Unable to build an empty module." >&2;}
{ (exit 1); exit 1; }; }
else
{ { $as_echo "$as_me:$LINENO: error:
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree." >&5
$as_echo "$as_me: error:
*** Unable to build an empty module.
*** Please run 'make scripts' inside the kernel source tree." >&2;}
{ (exit 1); exit 1; }; }
fi
fi
rm -Rf build
# Check whether --enable-atomic-spinlocks was given.
if test "${enable_atomic_spinlocks+set}" = set; then
@ -20886,20 +21052,19 @@ fi
;;
;;
srpm) ;;
*)
{ $as_echo "$as_me:$LINENO: result: Error!" >&5
*)
{ $as_echo "$as_me:$LINENO: result: Error!" >&5
$as_echo "Error!" >&6; }
{ { $as_echo "$as_me:$LINENO: error: Bad value \"$SPL_CONFIG\" for --with-config,
user kernel|user|all|srpm" >&5
{ { $as_echo "$as_me:$LINENO: error: Bad value \"$SPL_CONFIG\" for --with-config,
user kernel|user|all|srpm" >&5
$as_echo "$as_me: error: Bad value \"$SPL_CONFIG\" for --with-config,
user kernel|user|all|srpm" >&2;}
user kernel|user|all|srpm" >&2;}
{ (exit 1); exit 1; }; } ;;
esac
esac
if test "$SPL_CONFIG" = user ||
test "$SPL_CONFIG" = all; then
if test "$SPL_CONFIG" = user -o "$SPL_CONFIG" = all; then
CONFIG_USER_TRUE=
CONFIG_USER_FALSE='#'
else
@ -20907,8 +21072,8 @@ else
CONFIG_USER_FALSE=
fi
if test "$SPL_CONFIG" = kernel ||
test "$SPL_CONFIG" = all; then
if test "$SPL_CONFIG" = kernel -o "$SPL_CONFIG" = all &&
test "x$enable_linux_builtin" != xyes ; then
CONFIG_KERNEL_TRUE=
CONFIG_KERNEL_FALSE='#'
else