8003317: build-infra: Configure fails when current dir is part of a symlink
authortbell
Wed, 14 Nov 2012 10:18:51 -0800
changeset 14461 7511ccfbebc0
parent 14460 10ce34aca00e
child 14462 5731c2f9d507
8003317: build-infra: Configure fails when current dir is part of a symlink Summary: Call macro for removing symbolic links on a copy of the CURDIR variable before comparing Reviewed-by: ohair, tbell Contributed-by: erik.joelsson@oracle.com
common/autoconf/basics.m4
common/autoconf/generated-configure.sh
--- a/common/autoconf/basics.m4	Wed Nov 14 10:16:45 2012 -0800
+++ b/common/autoconf/basics.m4	Wed Nov 14 10:18:51 2012 -0800
@@ -345,7 +345,13 @@
         [ CONF_NAME=${with_conf_name} ])
 
 # Test from where we are running configure, in or outside of src root.
-if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
+# To enable comparison of directories, CURDIR needs to be symlink free
+# just like SRC_ROOT already is
+NOSYM_CURDIR="$CURDIR"
+BASIC_REMOVE_SYMBOLIC_LINKS(NOSYM_CURDIR)
+if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \
+        || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \
+        || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
     # We are running configure from the src root.
     # Create a default ./build/target-variant-debuglevel output root.
     if test "x${CONF_NAME}" = x; then
--- a/common/autoconf/generated-configure.sh	Wed Nov 14 10:16:45 2012 -0800
+++ b/common/autoconf/generated-configure.sh	Wed Nov 14 10:18:51 2012 -0800
@@ -3068,7 +3068,7 @@
 #CUSTOM_AUTOCONF_INCLUDE
 
 # Do not change or remove the following line, it is needed for consistency checks:
-DATE_WHEN_GENERATED=1352916966
+DATE_WHEN_GENERATED=1352917083
 
 ###############################################################################
 #
@@ -7137,7 +7137,56 @@
 
 
 # Test from where we are running configure, in or outside of src root.
-if test "x$CURDIR" = "x$SRC_ROOT" || test "x$CURDIR" = "x$SRC_ROOT/common" || test "x$CURDIR" = "x$SRC_ROOT/common/autoconf" || test "x$CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
+# To enable comparison of directories, CURDIR needs to be symlink free
+# just like SRC_ROOT already is
+NOSYM_CURDIR="$CURDIR"
+
+    if test "x$OPENJDK_BUILD_OS" != xwindows; then
+        # Follow a chain of symbolic links. Use readlink
+        # where it exists, else fall back to horribly
+        # complicated shell code.
+        if test "x$READLINK_TESTED" != yes; then
+            # On MacOSX there is a readlink tool with a different
+            # purpose than the GNU readlink tool. Check the found readlink.
+            ISGNU=`$READLINK --help 2>&1 | $GREP GNU`
+            if test "x$ISGNU" = x; then
+                 # A readlink that we do not know how to use.
+                 # Are there other non-GNU readlinks out there?
+                 READLINK_TESTED=yes
+                 READLINK=
+            fi
+        fi
+
+        if test "x$READLINK" != x; then
+            NOSYM_CURDIR=`$READLINK -f $NOSYM_CURDIR`
+        else
+            STARTDIR=$PWD
+            COUNTER=0
+            sym_link_dir=`$DIRNAME $NOSYM_CURDIR`
+            sym_link_file=`$BASENAME $NOSYM_CURDIR`
+            while test $COUNTER -lt 20; do
+                ISLINK=`$LS -l $sym_link_dir/$sym_link_file | $GREP '\->' | $SED -e 's/.*-> \(.*\)/\1/'`
+                if test "x$ISLINK" == x; then
+                    # This is not a symbolic link! We are done!
+                    break
+                fi
+                # The link might be relative! We have to use cd to travel safely.
+                cd $sym_link_dir
+                # ... and we must get the to the absolute path, not one using symbolic links.
+                cd `pwd -P`
+                cd `$DIRNAME $ISLINK`
+                sym_link_dir=`$THEPWDCMD`
+                sym_link_file=`$BASENAME $ISLINK`
+                let COUNTER=COUNTER+1
+            done
+            cd $STARTDIR
+            NOSYM_CURDIR=$sym_link_dir/$sym_link_file
+        fi
+    fi
+
+if test "x$NOSYM_CURDIR" = "x$SRC_ROOT" || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common" \
+        || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/autoconf" \
+        || test "x$NOSYM_CURDIR" = "x$SRC_ROOT/common/makefiles" ; then
     # We are running configure from the src root.
     # Create a default ./build/target-variant-debuglevel output root.
     if test "x${CONF_NAME}" = x; then