8022411: Allow overriding of CXX and CC with absolute path
authorihse
Tue, 28 Jan 2014 14:47:22 +0100
changeset 22458 6a74da13c52f
parent 22183 7979ec8adcbb
child 22459 def24c6b5019
8022411: Allow overriding of CXX and CC with absolute path Reviewed-by: erikj, tbell
common/autoconf/generated-configure.sh
common/autoconf/toolchain.m4
--- a/common/autoconf/generated-configure.sh	Thu Jan 16 21:43:13 2014 -0800
+++ b/common/autoconf/generated-configure.sh	Tue Jan 28 14:47:22 2014 +0100
@@ -747,8 +747,8 @@
 CXX
 ac_ct_PROPER_COMPILER_CXX
 PROPER_COMPILER_CXX
+TOOLS_DIR_CXX
 POTENTIAL_CXX
-TOOLS_DIR_CXX
 OBJEXT
 EXEEXT
 ac_ct_CC
@@ -758,8 +758,8 @@
 CC
 ac_ct_PROPER_COMPILER_CC
 PROPER_COMPILER_CC
+TOOLS_DIR_CC
 POTENTIAL_CC
-TOOLS_DIR_CC
 BUILD_LD
 BUILD_CXX
 BUILD_CC
@@ -3865,7 +3865,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1389815815
+DATE_WHEN_GENERATED=1390907294
 
 ###############################################################################
 #
@@ -7868,7 +7868,7 @@
   fi
 
   # Replace the commas with AND for use in the build directory name.
-  ANDED_JVM_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/^,//' -e 's/,$//' -e 's/,/AND/'`
+  ANDED_JVM_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/^,//' -e 's/,$//' -e 's/,/AND/g'`
   COUNT_VARIANTS=`$ECHO "$JVM_VARIANTS" | $SED -e 's/server,/1/' -e 's/client,/1/' -e 's/minimal1,/1/' -e 's/kernel,/1/' -e 's/zero,/1/' -e 's/zeroshark,/1/'`
   if test "x$COUNT_VARIANTS" != "x,1"; then
     BUILDING_MULTIPLE_JVM_VARIANTS=yes
@@ -19073,9 +19073,7 @@
   # On Solaris, cc is preferred to gcc.
   # Elsewhere, gcc is preferred to cc.
 
-  if test "x$CC" != x; then
-    COMPILER_CHECK_LIST="$CC"
-  elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
     COMPILER_CHECK_LIST="cl"
   elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
     COMPILER_CHECK_LIST="cc gcc"
@@ -19085,14 +19083,80 @@
 
 
   COMPILER_NAME=C
-
-  CC=
-  # If TOOLS_DIR is set, check for all compiler names in there first
-  # before checking the rest of the PATH.
-  if test -n "$TOOLS_DIR"; then
-    PATH_save="$PATH"
-    PATH="$TOOLS_DIR"
-    for ac_prog in $COMPILER_CHECK_LIST
+  SEARCH_LIST="$COMPILER_CHECK_LIST"
+
+  if test "x$CC" != x; then
+    # User has supplied compiler name already, always let that override.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied compiler CC=$CC" >&5
+$as_echo "$as_me: Will use user supplied compiler CC=$CC" >&6;}
+    if test "x`basename $CC`" = "x$CC"; then
+      # A command without a complete path is provided, search $PATH.
+
+      for ac_prog in $CC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_POTENTIAL_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $POTENTIAL_CC in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_POTENTIAL_CC="$POTENTIAL_CC" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_POTENTIAL_CC="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+POTENTIAL_CC=$ac_cv_path_POTENTIAL_CC
+if test -n "$POTENTIAL_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POTENTIAL_CC" >&5
+$as_echo "$POTENTIAL_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$POTENTIAL_CC" && break
+done
+
+      if test "x$POTENTIAL_CC" != x; then
+        CC=$POTENTIAL_CC
+      else
+        as_fn_error $? "User supplied compiler CC=$CC could not be found" "$LINENO" 5
+      fi
+    else
+      # Otherwise it might already be a complete path
+      if test ! -x "$CC"; then
+        as_fn_error $? "User supplied compiler CC=$CC does not exist" "$LINENO" 5
+      fi
+    fi
+  else
+    # No user supplied value. Locate compiler ourselves
+    CC=
+    # If TOOLS_DIR is set, check for all compiler names in there first
+    # before checking the rest of the PATH.
+    if test -n "$TOOLS_DIR"; then
+      PATH_save="$PATH"
+      PATH="$TOOLS_DIR"
+      for ac_prog in $SEARCH_LIST
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -19137,14 +19201,14 @@
   test -n "$TOOLS_DIR_CC" && break
 done
 
-    CC=$TOOLS_DIR_CC
-    PATH="$PATH_save"
-  fi
-
-  # AC_PATH_PROGS can't be run multiple times with the same variable,
-  # so create a new name for this run.
-  if test "x$CC" = x; then
-    for ac_prog in $COMPILER_CHECK_LIST
+      CC=$TOOLS_DIR_CC
+      PATH="$PATH_save"
+    fi
+
+    # AC_PATH_PROGS can't be run multiple times with the same variable,
+    # so create a new name for this run.
+    if test "x$CC" = x; then
+      for ac_prog in $SEARCH_LIST
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -19189,10 +19253,10 @@
   test -n "$POTENTIAL_CC" && break
 done
 
-    CC=$POTENTIAL_CC
-  fi
-
-  if test "x$CC" = x; then
+      CC=$POTENTIAL_CC
+    fi
+
+    if test "x$CC" = x; then
 
   # Print a helpful message on how to acquire the necessary build dependency.
   # devkit is the help tag: freetype, cups, pulse, alsa etc
@@ -19225,8 +19289,11 @@
     fi
   fi
 
-    as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5
-  fi
+      as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5
+    fi
+  fi
+
+  # Now we have a compiler binary in CC. Make sure it's okay.
 
   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 
@@ -20652,9 +20719,7 @@
 
   ### Locate C++ compiler (CXX)
 
-  if test "x$CXX" != x; then
-    COMPILER_CHECK_LIST="$CXX"
-  elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
     COMPILER_CHECK_LIST="cl"
   elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
     COMPILER_CHECK_LIST="CC g++"
@@ -20664,14 +20729,80 @@
 
 
   COMPILER_NAME=C++
-
-  CXX=
-  # If TOOLS_DIR is set, check for all compiler names in there first
-  # before checking the rest of the PATH.
-  if test -n "$TOOLS_DIR"; then
-    PATH_save="$PATH"
-    PATH="$TOOLS_DIR"
-    for ac_prog in $COMPILER_CHECK_LIST
+  SEARCH_LIST="$COMPILER_CHECK_LIST"
+
+  if test "x$CXX" != x; then
+    # User has supplied compiler name already, always let that override.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied compiler CXX=$CXX" >&5
+$as_echo "$as_me: Will use user supplied compiler CXX=$CXX" >&6;}
+    if test "x`basename $CXX`" = "x$CXX"; then
+      # A command without a complete path is provided, search $PATH.
+
+      for ac_prog in $CXX
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_path_POTENTIAL_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $POTENTIAL_CXX in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_POTENTIAL_CXX="$POTENTIAL_CXX" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
+    ac_cv_path_POTENTIAL_CXX="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+POTENTIAL_CXX=$ac_cv_path_POTENTIAL_CXX
+if test -n "$POTENTIAL_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $POTENTIAL_CXX" >&5
+$as_echo "$POTENTIAL_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$POTENTIAL_CXX" && break
+done
+
+      if test "x$POTENTIAL_CXX" != x; then
+        CXX=$POTENTIAL_CXX
+      else
+        as_fn_error $? "User supplied compiler CXX=$CXX could not be found" "$LINENO" 5
+      fi
+    else
+      # Otherwise it might already be a complete path
+      if test ! -x "$CXX"; then
+        as_fn_error $? "User supplied compiler CXX=$CXX does not exist" "$LINENO" 5
+      fi
+    fi
+  else
+    # No user supplied value. Locate compiler ourselves
+    CXX=
+    # If TOOLS_DIR is set, check for all compiler names in there first
+    # before checking the rest of the PATH.
+    if test -n "$TOOLS_DIR"; then
+      PATH_save="$PATH"
+      PATH="$TOOLS_DIR"
+      for ac_prog in $SEARCH_LIST
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -20716,14 +20847,14 @@
   test -n "$TOOLS_DIR_CXX" && break
 done
 
-    CXX=$TOOLS_DIR_CXX
-    PATH="$PATH_save"
-  fi
-
-  # AC_PATH_PROGS can't be run multiple times with the same variable,
-  # so create a new name for this run.
-  if test "x$CXX" = x; then
-    for ac_prog in $COMPILER_CHECK_LIST
+      CXX=$TOOLS_DIR_CXX
+      PATH="$PATH_save"
+    fi
+
+    # AC_PATH_PROGS can't be run multiple times with the same variable,
+    # so create a new name for this run.
+    if test "x$CXX" = x; then
+      for ac_prog in $SEARCH_LIST
 do
   # Extract the first word of "$ac_prog", so it can be a program name with args.
 set dummy $ac_prog; ac_word=$2
@@ -20768,10 +20899,10 @@
   test -n "$POTENTIAL_CXX" && break
 done
 
-    CXX=$POTENTIAL_CXX
-  fi
-
-  if test "x$CXX" = x; then
+      CXX=$POTENTIAL_CXX
+    fi
+
+    if test "x$CXX" = x; then
 
   # Print a helpful message on how to acquire the necessary build dependency.
   # devkit is the help tag: freetype, cups, pulse, alsa etc
@@ -20804,8 +20935,11 @@
     fi
   fi
 
-    as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5
-  fi
+      as_fn_error $? "Could not find a $COMPILER_NAME compiler. $HELP_MSG" "$LINENO" 5
+    fi
+  fi
+
+  # Now we have a compiler binary in CXX. Make sure it's okay.
 
   if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then
 
--- a/common/autoconf/toolchain.m4	Thu Jan 16 21:43:13 2014 -0800
+++ b/common/autoconf/toolchain.m4	Tue Jan 28 14:47:22 2014 +0100
@@ -113,29 +113,53 @@
 AC_DEFUN([TOOLCHAIN_FIND_COMPILER],
 [
   COMPILER_NAME=$2
+  SEARCH_LIST="$3"
 
-  $1=
-  # If TOOLS_DIR is set, check for all compiler names in there first
-  # before checking the rest of the PATH.
-  if test -n "$TOOLS_DIR"; then
-    PATH_save="$PATH"
-    PATH="$TOOLS_DIR"
-    AC_PATH_PROGS(TOOLS_DIR_$1, $3)
-    $1=$TOOLS_DIR_$1
-    PATH="$PATH_save"
+  if test "x[$]$1" != x; then
+    # User has supplied compiler name already, always let that override.
+    AC_MSG_NOTICE([Will use user supplied compiler $1=[$]$1])
+    if test "x`basename [$]$1`" = "x[$]$1"; then
+      # A command without a complete path is provided, search $PATH.
+      
+      AC_PATH_PROGS(POTENTIAL_$1, [$]$1)
+      if test "x$POTENTIAL_$1" != x; then
+        $1=$POTENTIAL_$1
+      else
+        AC_MSG_ERROR([User supplied compiler $1=[$]$1 could not be found])
+      fi
+    else
+      # Otherwise it might already be a complete path
+      if test ! -x "[$]$1"; then
+        AC_MSG_ERROR([User supplied compiler $1=[$]$1 does not exist])
+      fi
+    fi
+  else
+    # No user supplied value. Locate compiler ourselves
+    $1=
+    # If TOOLS_DIR is set, check for all compiler names in there first
+    # before checking the rest of the PATH.
+    if test -n "$TOOLS_DIR"; then
+      PATH_save="$PATH"
+      PATH="$TOOLS_DIR"
+      AC_PATH_PROGS(TOOLS_DIR_$1, $SEARCH_LIST)
+      $1=$TOOLS_DIR_$1
+      PATH="$PATH_save"
+    fi
+
+    # AC_PATH_PROGS can't be run multiple times with the same variable,
+    # so create a new name for this run.
+    if test "x[$]$1" = x; then
+      AC_PATH_PROGS(POTENTIAL_$1, $SEARCH_LIST)
+      $1=$POTENTIAL_$1
+    fi
+
+    if test "x[$]$1" = x; then
+      HELP_MSG_MISSING_DEPENDENCY([devkit])
+      AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
+    fi
   fi
 
-  # AC_PATH_PROGS can't be run multiple times with the same variable,
-  # so create a new name for this run.
-  if test "x[$]$1" = x; then
-    AC_PATH_PROGS(POTENTIAL_$1, $3)
-    $1=$POTENTIAL_$1
-  fi
-
-  if test "x[$]$1" = x; then
-    HELP_MSG_MISSING_DEPENDENCY([devkit])
-    AC_MSG_ERROR([Could not find a $COMPILER_NAME compiler. $HELP_MSG])
-  fi
+  # Now we have a compiler binary in $1. Make sure it's okay.
   BASIC_FIXUP_EXECUTABLE($1)
   AC_MSG_CHECKING([resolved symbolic links for $1])
   TEST_COMPILER="[$]$1"
@@ -248,9 +272,7 @@
   # On Solaris, cc is preferred to gcc.
   # Elsewhere, gcc is preferred to cc.
 
-  if test "x$CC" != x; then
-    COMPILER_CHECK_LIST="$CC"
-  elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
     COMPILER_CHECK_LIST="cl"
   elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
     COMPILER_CHECK_LIST="cc gcc"
@@ -264,9 +286,7 @@
 
   ### Locate C++ compiler (CXX)
 
-  if test "x$CXX" != x; then
-    COMPILER_CHECK_LIST="$CXX"
-  elif test "x$OPENJDK_TARGET_OS" = "xwindows"; then
+  if test "x$OPENJDK_TARGET_OS" = "xwindows"; then
     COMPILER_CHECK_LIST="cl"
   elif test "x$OPENJDK_TARGET_OS" = "xsolaris"; then
     COMPILER_CHECK_LIST="CC g++"