. "$GRIMOIRE"/chroot.function

if ! is_chroot; then
  if [[ "$(get_kernel_config CONFIG_DEVTMPFS)" != "y"  &&
        "$(get_kernel_config CONFIG_DEVTMPFS_MOUNT)" != "y" ]]; then
    message "${SPELL_COLOR}$SPELL${DEFAULT_COLOR}${PROBLEM_COLOR} requires" \
            "CONFIG_DEVTMPFS and CONFIG_DEVTMPFS_MOUNT built-in${DEFAULT_COLOR}" &&
    return 1
  fi &&

  if [[ "$(get_kernel_config CONFIG_FHANDLE)" != "y" ]]; then
    message "${SPELL_COLOR}$SPELL${DEFAULT_COLOR}${PROBLEM_COLOR} requires" \
            "CONFIG_FHANDLE built-in${DEFAULT_COLOR}" &&
    return 1
  fi &&

  if [[ "$(get_kernel_config CONFIG_NET)" != "y" ]]; then
    message "${SPELL_COLOR}$SPELL${DEFAULT_COLOR}${PROBLEM_COLOR} requires" \
            "CONFIG_NET built-in${DEFAULT_COLOR}" &&
    return 1
  fi &&

  # Disable userspace firmware loader in Linux 3.7+
  if [[ "$(get_kernel_version|cut -d. -f3)" -ge "37" &&
        "$(get_kernel_config CONFIG_FW_LOADER_USER_HELPER)" == "y" ]]; then
    message "${SPELL_COLOR}$SPELL${DEFAULT_COLOR}${PROBLEM_COLOR} requires" \
            "CONFIG_FW_LOADER_USER_HELPER disabled${DEFAULT_COLOR}" &&
    return 1
  fi
fi &&

default_pre_build  &&
cd $SOURCE_DIRECTORY &&
cp ${SPELL_DIRECTORY}/udev.conf ${SOURCE_DIRECTORY}/src/udev/ &&
apply_patch_dir patches &&
# The installed lib has no dependencies, so also for the static libudev.a, the
# libtool file is only clutter.
find . -name Makefile.in \
| xargs sed -i 's,^\(LIBTOOL[[:space:]]*=[[:space:]]*\),\1'"$GRIMOIRE"'/libtool-nola ,'
