view common/autoconf/configure @ 500:c8d320b48626

7181504: Update of latest build-infra Makefiles Reviewed-by: ohair
author erikj
date Tue, 03 Jul 2012 16:11:12 -0700
parents efd26e051e50
children
line wrap: on
line source

#!/bin/sh

CONFIGURE_COMMAND_LINE="$@"
conf_script_dir=`dirname $0`
conf_closed_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"

###
### Test that the generated configure is up-to-date
###

# On Solaris /bin/sh doesn't support test -nt but /usr/bin/test does.
TEST=`which test`

print_error_not_up_to_date() {
  echo "Error: The configure source files is newer than the generated files."
  echo "Please run 'sh autogen.sh' to update the generated files."
}

for file in configure.ac *.m4 ; do
  if $TEST $file -nt generated-configure.sh; then
    print_error_not_up_to_date
    exit 1
  fi
done

if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
  # If closed source configure is available, make sure it is up-to-date as well.
  for file in configure.ac *.m4 $conf_closed_script_dir/*.m4; do
    if $TEST $file -nt $conf_closed_script_dir/generated-configure.sh; then
      print_error_not_up_to_date
      exit 1
    fi
  done

  # Test if open configure is newer than closed configure, if so, closed needs to
  # be regenerated.
  conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_script_dir/generated-configure.sh  | cut -d" " -f 3`
  conf_closed_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_closed_script_dir/generated-configure.sh  | cut -d" " -f 3`
  if $TEST $conf_open_configure_timestamp -gt $conf_closed_configure_timestamp; then
    print_error_not_up_to_date
    exit 1
  fi
  
fi

###
### Process command-line arguments
###
conf_processed_arguments=
conf_openjdk_target=
conf_extra_cflags=
conf_extra_cxxflags=

for conf_option
do
  case $conf_option in
  --openjdk-target=*)
    conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
    continue ;;
  --with-extra-cflags=*)
    conf_extra_cflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
    continue ;;
  --with-extra-cxxflags=*)
    conf_extra_cxxflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
    continue ;;
  *)
    conf_processed_arguments="$conf_processed_arguments $conf_option" ;;
  esac

  case $conf_option in
  -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  esac
done

if $TEST "x$conf_legacy_crosscompile" != "x"; then
  if $TEST "x$conf_openjdk_target" != "x"; then
    echo "Error: Specifying --openjdk-target together with autoconf"
    echo "legacy cross-compilation flags is not supported."
    echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
    echo "The recommended use is just --openjdk-target."
    exit 1
  else
    echo "Warning: You are using legacy autoconf cross-compilation flags."
    echo "It is recommended that you use --openjdk-target instead."
    echo ""
  fi
fi

if $TEST "x$conf_openjdk_target" != "x"; then
  conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
  conf_processed_arguments="--build=$conf_build_platform --host=$conf_openjdk_target --target=$conf_openjdk_target $conf_processed_arguments"
fi

# Make configure exit with error on invalid options as default.
# Can be overridden by --disable-option-checking, since we prepend our argument
# and later options override earlier.
conf_processed_arguments="--enable-option-checking=fatal $conf_processed_arguments"

###
### Call the configure script
###
if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
  # Closed source configure available; run that instead
  . $conf_closed_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
else
  . $conf_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
fi

###
### Post-processing
###

# Move the log file to the output root, if this was successfully created
if $TEST -d "$OUTPUT_ROOT"; then
  mv -f config.log "$OUTPUT_ROOT" 2> /dev/null
fi