1 #!/bin/sh
   2 
   3 CONFIGURE_COMMAND_LINE="$@"
   4 conf_script_dir=`dirname $0`
   5 conf_closed_script_dir="$conf_script_dir/../../jdk/make/closed/autoconf"
   6 
   7 ###
   8 ### Test that the generated configure is up-to-date
   9 ###
  10 
  11 # On Solaris /bin/sh doesn't support test -nt but /usr/bin/test does.
  12 TEST=`which test`
  13 
  14 print_error_not_up_to_date() {
  15   echo "Error: The configure source files is newer than the generated files."
  16   echo "Please run 'sh autogen.sh' to update the generated files."
  17 }
  18 
  19 for file in configure.ac *.m4 ; do
  20   if $TEST $file -nt generated-configure.sh; then
  21     print_error_not_up_to_date
  22     exit 1
  23   fi
  24 done
  25 
  26 if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
  27   # If closed source configure is available, make sure it is up-to-date as well.
  28   for file in configure.ac *.m4 $conf_closed_script_dir/*.m4; do
  29     if $TEST $file -nt $conf_closed_script_dir/generated-configure.sh; then
  30       print_error_not_up_to_date
  31       exit 1
  32     fi
  33   done
  34 
  35   # Test if open configure is newer than closed configure, if so, closed needs to
  36   # be regenerated.
  37   conf_open_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_script_dir/generated-configure.sh  | cut -d" " -f 3`
  38   conf_closed_configure_timestamp=`grep DATE_WHEN_GENERATED: $conf_closed_script_dir/generated-configure.sh  | cut -d" " -f 3`
  39   if $TEST $conf_open_configure_timestamp -gt $conf_closed_configure_timestamp; then
  40     print_error_not_up_to_date
  41     exit 1
  42   fi
  43   
  44 fi
  45 
  46 ###
  47 ### Process command-line arguments
  48 ###
  49 conf_processed_arguments=
  50 conf_openjdk_target=
  51 conf_extra_cflags=
  52 conf_extra_cxxflags=
  53 
  54 for conf_option
  55 do
  56   case $conf_option in
  57   --openjdk-target=*)
  58     conf_openjdk_target=`expr "X$conf_option" : '[^=]*=\(.*\)'`
  59     continue ;;
  60   --with-extra-cflags=*)
  61     conf_extra_cflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
  62     continue ;;
  63   --with-extra-cxxflags=*)
  64     conf_extra_cxxflags=`expr "X$conf_option" : '[^=]*=\(.*\)'`
  65     continue ;;
  66   *)
  67     conf_processed_arguments="$conf_processed_arguments $conf_option" ;;
  68   esac
  69 
  70   case $conf_option in
  71   -build | --build | --buil | --bui | --bu |-build=* | --build=* | --buil=* | --bui=* | --bu=*)
  72     conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  73   -target | --target | --targe | --targ | --tar | --ta | --t | -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
  74     conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  75   -host | --host | --hos | --ho | -host=* | --host=* | --hos=* | --ho=*)
  76     conf_legacy_crosscompile="$conf_legacy_crosscompile $conf_option" ;;
  77   esac
  78 done
  79 
  80 if $TEST "x$conf_legacy_crosscompile" != "x"; then
  81   if $TEST "x$conf_openjdk_target" != "x"; then
  82     echo "Error: Specifying --openjdk-target together with autoconf"
  83     echo "legacy cross-compilation flags is not supported."
  84     echo "You specified: --openjdk-target=$conf_openjdk_target and $conf_legacy_crosscompile."
  85     echo "The recommended use is just --openjdk-target."
  86     exit 1
  87   else
  88     echo "Warning: You are using legacy autoconf cross-compilation flags."
  89     echo "It is recommended that you use --openjdk-target instead."
  90     echo ""
  91   fi
  92 fi
  93 
  94 if $TEST "x$conf_openjdk_target" != "x"; then
  95   conf_build_platform=`sh $conf_script_dir/build-aux/config.guess`
  96   conf_processed_arguments="--build=$conf_build_platform --host=$conf_openjdk_target --target=$conf_openjdk_target $conf_processed_arguments"
  97 fi
  98 
  99 # Make configure exit with error on invalid options as default.
 100 # Can be overridden by --disable-option-checking, since we prepend our argument
 101 # and later options override earlier.
 102 conf_processed_arguments="--enable-option-checking=fatal $conf_processed_arguments"
 103 
 104 ###
 105 ### Call the configure script
 106 ###
 107 if $TEST -e $conf_closed_script_dir/generated-configure.sh; then
 108   # Closed source configure available; run that instead
 109   . $conf_closed_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
 110 else
 111   . $conf_script_dir/generated-configure.sh $conf_processed_arguments --with-extra-cflags="$conf_extra_cflags" --with-extra-cxxflags="$conf_extra_cxxflags"
 112 fi
 113 
 114 ###
 115 ### Post-processing
 116 ###
 117 
 118 # Move the log file to the output root, if this was successfully created
 119 if $TEST -d "$OUTPUT_ROOT"; then
 120   mv -f config.log "$OUTPUT_ROOT" 2> /dev/null
 121 fi