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