configure revision 476:2ba6f4da4bf3
1#!/bin/sh
2
3CONFIGURE_COMMAND_LINE="$@"
4conf_script_dir=`dirname $0`
5
6if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
7  conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
8else
9  conf_custom_script_dir=$CUSTOM_CONFIG_DIR
10fi
11
12###
13### Test that the generated configure is up-to-date
14###
15
16# On Solaris /bin/sh doesn't support test -nt but /usr/bin/test does.
17TEST=`which test`
18
19print_error_not_up_to_date() {
20  echo "Error: The configure source files is newer than the generated files."
21  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# NOTE: This test can occasionally go wrong due to the way mercurial handles
26# timestamps. It it supposed to aid during development of build-infra, but should
27# go away before making this the default build system.
28for file in configure.ac *.m4 ; do
29  if $TEST $file -nt generated-configure.sh; then
30    print_error_not_up_to_date
31    exit 1
32  fi
33done
34
35if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
36  # If custom source configure is available, make sure it is up-to-date as well.
37  for file in configure.ac *.m4 $conf_custom_script_dir/*.m4; do
38    if $TEST $file -nt $conf_custom_script_dir/generated-configure.sh; then
39      print_error_not_up_to_date
40      exit 1
41    fi
42  done
43
44  # Test if open configure is newer than custom configure, if so, custom needs to
45  # 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  conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_custom_script_dir/generated-configure.sh  | cut -d" " -f 3`
48  if $TEST $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then
49    echo "Error: The generated configure file contains changes not present in the custom generated file."
50    echo "Please run 'sh autogen.sh' to update the generated files."
51    exit 1
52  fi
53  
54fi
55
56# Autoconf calls the configure script recursively sometimes. 
57# Don't start logging twice in that case
58if $TEST "x$conf_debug_configure" = xtrue; then
59  conf_debug_configure=recursive
60fi
61###
62### Process command-line arguments
63###
64conf_processed_arguments=
65conf_openjdk_target=
66conf_extra_cflags=
67conf_extra_cxxflags=
68
69for conf_option
70do
71  case $conf_option in
72  --openjdk-target=*)
73    conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
74    continue ;;
75  --with-extra-cflags=*)
76    conf_extra_cflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
77    continue ;;
78  --with-extra-cxxflags=*)
79    conf_extra_cxxflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
80    continue ;;
81  --debug-configure)
82    if $TEST "x$conf_debug_configure" != xrecursive; then
83      conf_debug_configure=true
84      export conf_debug_configure
85    fi
86    continue ;;
87  *)
88    conf_processed_arguments="$conf_processed_arguments $conf_option" ;;
89  esac
90
91  case $conf_option in
92  -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
93    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
94  -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
95    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
96  -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
97    conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
98  esac
99done
100
101if $TEST "x$conf_legacy_crosscompile" != "x"; then
102  if $TEST "x$conf_openjdk_target" != "x"; then
103    echo "Error: Specifying --openjdk-target together with autoconf"
104    echo "legacy cross-compilation flags is not supported."
105    echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
106    echo "The recommended use is just --openjdk-target."
107    exit 1
108  else
109    echo "Warning: You are using legacy autoconf cross-compilation flags."
110    echo "It is recommended that you use --openjdk-target instead."
111    echo ""
112  fi
113fi
114
115if $TEST "x$conf_openjdk_target" != "x"; then
116  conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
117  conf_processed_arguments="--build=$conf_build_platform --host=$conf_openjdk_target --target=$conf_openjdk_target $conf_processed_arguments"
118fi
119
120# Make configure exit with error on invalid options as default.
121# Can be overridden by --disable-option-checking, since we prepend our argument
122# and later options override earlier.
123conf_processed_arguments="--enable-option-checking=fatal $conf_processed_arguments"
124
125###
126### Call the configure script
127###
128if $TEST -e $conf_custom_script_dir/generated-configure.sh; then
129  # Custom source configure available; run that instead
130  echo Running custom generated-configure.sh
131  conf_script_to_run=$conf_custom_script_dir/generated-configure.sh
132else
133  echo Running generated-configure.sh
134  conf_script_to_run=$conf_script_dir/generated-configure.sh
135fi  
136
137if $TEST "x$conf_debug_configure" != x; then
138  # Turn on shell debug output if requested (initial or recursive)
139  set -x
140fi
141
142if $TEST "x$conf_debug_configure" = xtrue; then
143  # Turn on logging, but don't turn on twice when called recursive
144  conf_debug_logfile=./debug-configure.log
145  (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
146else
147  . $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
148fi
149
150conf_result_code=$?
151###
152### Post-processing
153###
154
155# Move the log file to the output root, if this was successfully created
156if $TEST -d "$OUTPUT_ROOT"; then
157  mv -f config.log "$OUTPUT_ROOT" 2> /dev/null
158fi
159
160exit $conf_result_code
161