erikj@458: #!/bin/sh ohair@425: erikj@458: CONFIGURE_COMMAND_LINE="$@" erikj@458: conf_script_dir=`dirname $0` ohair@478: ohair@478: if [ "$CUSTOM_CONFIG_DIR" = "" ]; then ohair@478: conf_custom_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf" ohair@478: else ohair@478: conf_custom_script_dir=$CUSTOM_CONFIG_DIR ohair@478: fi erikj@458: erikj@458: ### erikj@458: ### Test that the generated configure is up-to-date erikj@458: ### erikj@458: erikj@458: # On Solaris /bin/sh doesn't support test -nt but /usr/bin/test does. erikj@458: TEST=`which test` erikj@458: erikj@458: print_error_not_up_to_date() { erikj@458: echo "Error: The configure source files is newer than the generated files." erikj@458: echo "Please run 'sh autogen.sh' to update the generated files." ohair@478: echo "Note that this test might trigger incorrectly sometimes due to hg timestamps". erikj@458: } erikj@458: ohair@478: # NOTE: This test can occasionally go wrong due to the way mercurial handles ohair@478: # timestamps. It it supposed to aid during development of build-infra, but should ohair@478: # go away before making this the default build system. erikj@458: for file in configure.ac *.m4 ; do erikj@458: if $TEST $file -nt generated-configure.sh; then erikj@458: print_error_not_up_to_date erikj@458: exit 1 erikj@458: fi erikj@458: done erikj@458: ohair@478: if $TEST -e $conf_custom_script_dir/generated-configure.sh; then ohair@478: # If custom source configure is available, make sure it is up-to-date as well. ohair@478: for file in configure.ac *.m4 $conf_custom_script_dir/*.m4; do ohair@478: if $TEST $file -nt $conf_custom_script_dir/generated-configure.sh; then erikj@458: print_error_not_up_to_date erikj@458: exit 1 erikj@458: fi erikj@458: done erikj@458: ohair@478: # Test if open configure is newer than custom configure, if so, custom needs to ohair@478: # be regenerated. This test is required to ensure consistency with custom source. erikj@458: conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_script_dir/generated-configure.sh | cut -d" " -f 3` ohair@478: conf_custom_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_custom_script_dir/generated-configure.sh | cut -d" " -f 3` ohair@478: if $TEST $conf_open_configure_timestamp -gt $conf_custom_configure_timestamp; then ohair@478: echo "Error: The generated configure file contains changes not present in the custom generated file." ohair@478: echo "Please run 'sh autogen.sh' to update the generated files." erikj@458: exit 1 erikj@458: fi erikj@458: ohair@425: fi ohair@425: ohair@478: # Autoconf calls the configure script recursively sometimes. ohair@478: # Don't start logging twice in that case ohair@478: if $TEST "x$conf_debug_configure" = xtrue; then ohair@478: conf_debug_configure=recursive ohair@478: fi erikj@458: ### erikj@458: ### Process command-line arguments erikj@458: ### erikj@458: conf_processed_arguments= erikj@458: conf_openjdk_target= erikj@458: conf_extra_cflags= erikj@458: conf_extra_cxxflags= ohair@425: erikj@458: for conf_option ohair@425: do erikj@458: case $conf_option in erikj@458: --openjdk-target=*) erikj@458: conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'` erikj@458: continue ;; erikj@458: --with-extra-cflags=*) erikj@458: conf_extra_cflags=`expr "X$conf_option" : '[^=]*=\(.*\)'` erikj@458: continue ;; erikj@458: --with-extra-cxxflags=*) erikj@458: conf_extra_cxxflags=`expr "X$conf_option" : '[^=]*=\(.*\)'` erikj@458: continue ;; ohair@478: --debug-configure) ohair@478: if $TEST "x$conf_debug_configure" != xrecursive; then ohair@478: conf_debug_configure=true ohair@478: export conf_debug_configure ohair@478: fi ohair@478: continue ;; erikj@458: *) erikj@458: conf_processed_arguments="$conf_processed_arguments $conf_option" ;; ohair@425: esac ohair@425: erikj@458: case $conf_option in erikj@458: -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*) erikj@458: conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; erikj@458: -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) erikj@458: conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; erikj@458: -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*) erikj@458: conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;; ohair@425: esac ohair@425: done ohair@425: erikj@458: if $TEST "x$conf_legacy_crosscompile" != "x"; then erikj@458: if $TEST "x$conf_openjdk_target" != "x"; then erikj@458: echo "Error: Specifying --openjdk-target together with autoconf" erikj@458: echo "legacy cross-compilation flags is not supported." erikj@458: echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile." erikj@458: echo "The recommended use is just --openjdk-target." erikj@458: exit 1 erikj@458: else erikj@458: echo "Warning: You are using legacy autoconf cross-compilation flags." erikj@458: echo "It is recommended that you use --openjdk-target instead." erikj@458: echo "" ohair@425: fi ohair@425: fi ohair@425: erikj@458: if $TEST "x$conf_openjdk_target" != "x"; then erikj@458: conf_build_platform=`sh $conf_script_dir/build-aux/config.guess` erikj@458: conf_processed_arguments="--build=$conf_build_platform --host=$conf_openjdk_target --target=$conf_openjdk_target $conf_processed_arguments" ohair@425: fi ohair@425: erikj@458: # Make configure exit with error on invalid options as default. erikj@458: # Can be overridden by --disable-option-checking, since we prepend our argument erikj@458: # and later options override earlier. erikj@458: conf_processed_arguments="--enable-option-checking=fatal $conf_processed_arguments" ohair@425: erikj@458: ### erikj@458: ### Call the configure script erikj@458: ### ohair@478: if $TEST -e $conf_custom_script_dir/generated-configure.sh; then ohair@478: # Custom source configure available; run that instead ohair@478: echo Running custom generated-configure.sh ohair@478: conf_script_to_run=$conf_custom_script_dir/generated-configure.sh erikj@458: else ohair@478: echo Running generated-configure.sh ohair@478: conf_script_to_run=$conf_script_dir/generated-configure.sh ohair@478: fi ohair@478: ohair@478: if $TEST "x$conf_debug_configure" != x; then ohair@478: # Turn on shell debug output if requested (initial or recursive) ohair@478: set -x ohair@425: fi ohair@425: ohair@478: if $TEST "x$conf_debug_configure" = xtrue; then ohair@478: # Turn on logging, but don't turn on twice when called recursive ohair@478: conf_debug_logfile=./debug-configure.log ohair@478: (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 ohair@478: else ohair@478: . $conf_script_to_run $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags" ohair@478: fi ohair@478: ohair@478: conf_result_code=$? erikj@458: ### erikj@458: ### Post-processing erikj@458: ### ohair@425: erikj@458: # Move the log file to the output root, if this was successfully created erikj@458: if $TEST -d "$OUTPUT_ROOT"; then erikj@458: mv -f config.log "$OUTPUT_ROOT" 2> /dev/null ohair@425: fi ohair@478: ohair@478: exit $conf_result_code