Tue, 18 Sep 2012 11:29:16 -0700
7197849: Update new build-infra makefiles
Reviewed-by: ihse, erikj, ohrstrom, tbell
1 #!/bin/sh
3 CONFIGURE_COMMAND_LINE="$@"
4 conf_script_dir=`dirname $0`
6 if [ "$CUSTOM_CONFIG_DIR" = "" ]; then
7 conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
8 else
9 conf_custom_script_dir=$CUSTOM_CONFIG_DIR
10 fi
12 ###
13 ### Test that the generated configure is up-to-date
14 ###
16 # On Solaris /bin/sh doesn't support test -nt but /usr/bin/test does.
17 TEST=`which test`
19 print_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 }
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.
28 for 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
33 done
35 if $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
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
54 fi
56 # Autoconf calls the configure script recursively sometimes.
57 # Don't start logging twice in that case
58 if $TEST "x$conf_debug_configure" = xtrue; then
59 conf_debug_configure=recursive
60 fi
61 ###
62 ### Process command-line arguments
63 ###
64 conf_processed_arguments=
65 conf_openjdk_target=
66 conf_extra_cflags=
67 conf_extra_cxxflags=
69 for conf_option
70 do
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
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
99 done
101 if $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
113 fi
115 if $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"
118 fi
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.
123 conf_processed_arguments="--enable-option-checking=fatal $conf_processed_arguments"
125 ###
126 ### Call the configure script
127 ###
128 if $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
132 else
133 echo Running generated-configure.sh
134 conf_script_to_run=$conf_script_dir/generated-configure.sh
135 fi
137 if $TEST "x$conf_debug_configure" != x; then
138 # Turn on shell debug output if requested (initial or recursive)
139 set -x
140 fi
142 if $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
146 else
147 . $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
148 fi
150 conf_result_code=$?
151 ###
152 ### Post-processing
153 ###
155 # Move the log file to the output root, if this was successfully created
156 if $TEST -d "$OUTPUT_ROOT"; then
157 mv -f config.log "$OUTPUT_ROOT" 2> /dev/null
158 fi
160 exit $conf_result_code