configure 5.8 KB
Newer Older
1
#!/bin/sh
2

3 4
CONFIGURE_COMMAND_LINE="$@"
conf_script_dir=`dirname $0`
5 6 7 8 9 10

if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
  conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
else
  conf_custom_script_dir=$CUSTOM_CONFIG_DIR
fi
11

12 13 14
###
### Test that the generated configure is up-to-date
###
15

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

19 20 21
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."
22
  echo "Note that this test might trigger incorrectly sometimes due to hg timestamps".
23 24
}

25 26 27
# NOTE: This test can occasionally go wrong due to the way mercurial handles
# timestamps. It it supposed to aid during development of build-infra, but should
# go away before making this the default build system.
28 29 30 31
for file in configure.ac *.m4 ; do
  if $TEST $file -nt generated-configure.sh; then
    print_error_not_up_to_date
    exit 1
32 33 34
  fi
done

35 36 37 38
if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
  # If custom source configure is available, make sure it is up-to-date as well.
  for file in configure.ac *.m4 $conf_custom_script_dir/*.m4; do
    if $TEST $file -nt $conf_custom_script_dir/generated-configure.sh; then
39 40 41
      print_error_not_up_to_date
      exit 1
    fi
42 43
  done

44 45
  # Test if open configure is newer than custom configure, if so, custom needs to
  # be regenerated. This test is required to ensure consistency with custom source.
46
  conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_script_dir/generated-configure.sh  | cut -d" " -f 3`
47 48 49 50
  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_custom_script_dir/generated-configure.sh  | cut -d" " -f 3`
  if $TEST $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
    echo "Error: The generated configure file contains changes not present in the custom generated file."
    echo "Please run 'sh autogen.sh' to update the generated files."
51
    exit 1
52
  fi
53
  
54 55
fi

56 57 58 59 60
# Autoconf calls the configure script recursively sometimes. 
# Don't start logging twice in that case
if $TEST "x$conf_debug_configure" = xtrue; then
  conf_debug_configure=recursive
fi
61 62 63 64 65 66 67
###
### Process command-line arguments
###
conf_processed_arguments=
conf_openjdk_target=
conf_extra_cflags=
conf_extra_cxxflags=
68

69
for conf_option
70
do
71 72 73 74 75 76 77 78 79 80
  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 ;;
81 82 83 84 85 86
  --debug-configure)
    if $TEST "x$conf_debug_configure" != xrecursive; then
      conf_debug_configure=true
      export conf_debug_configure
    fi
    continue ;;
87
  *)
88
    conf_processed_arguments="$conf_processed_arguments $conf_option" ;;
89 90
  esac

91 92 93 94 95 96 97
  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" ;;
98 99 100
  esac
done

101 102 103 104 105 106 107
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
108
  else
109 110 111
    echo "Warning: You are using legacy autoconf cross-compilation flags."
    echo "It is recommended that you use --openjdk-target instead."
    echo ""
112 113 114
  fi
fi

115 116 117
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"
118 119
fi

120 121 122 123
# 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"
124

125 126 127
###
### Call the configure script
###
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145
if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
  # Custom source configure available; run that instead
  echo Running custom generated-configure.sh
  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
else
  echo Running generated-configure.sh
  conf_script_to_run=$conf_script_dir/generated-configure.sh
fi  

if $TEST "x$conf_debug_configure" != x; then
  # Turn on shell debug output if requested (initial or recursive)
  set -x
fi

if $TEST "x$conf_debug_configure" = xtrue; then
  # Turn on logging, but don't turn on twice when called recursive
  conf_debug_logfile=./debug-configure.log
  (exec 3>&1 ; (. $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags" 2>&1 1>&3 ) | tee -a $conf_debug_logfile 1>&2 ; exec 3>&-) | tee -a $conf_debug_logfile
146
else
147
  . $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
148 149
fi

150
conf_result_code=$?
151 152 153
###
### Post-processing
###
154

155 156 157
# 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
158
fi
159 160

exit $conf_result_code