changeset 2261:7dd1a3ba46d2

Hard link external OpenJDK source directories if possible, and check that ${OPENJDK_SRC_DIR}/README exists. 2010-06-14 Andrew John Hughes <ahughes@redhat.com> * Makefile.am: (REFLINK): Remove unneeded quotation. (OPENJDK_SRC_DIR_LINK): Use reflink only if hard linking is not possible. * acinclude.m4: (IT_CP_SUPPORTS_REFLINK): Define once only. (WITH_OPENJDK_SRC_DIR): Define once only. Check that directory is valid (to the extent this is discernable by the README being present) and whether hardlinking is possible, defining OPENJDK_SRC_DIR_HARDLINKABLE if it is.
author Andrew John Hughes <ahughes@redhat.com>
date Mon, 14 Jun 2010 16:27:40 +0100
parents 2877f76472f7
children 731f4c50030c
files ChangeLog Makefile.am acinclude.m4
diffstat 3 files changed, 53 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jun 14 13:41:26 2010 +0100
+++ b/ChangeLog	Mon Jun 14 16:27:40 2010 +0100
@@ -1,3 +1,17 @@
+2010-06-14  Andrew John Hughes  <ahughes@redhat.com>
+
+	* Makefile.am:
+	(REFLINK): Remove unneeded quotation.
+	(OPENJDK_SRC_DIR_LINK): Use reflink only
+	if hard linking is not possible.
+	* acinclude.m4:
+	(IT_CP_SUPPORTS_REFLINK): Define once only.
+	(WITH_OPENJDK_SRC_DIR): Define once only.
+	Check that directory is valid (to the extent
+	this is discernable by the README being present)
+	and whether hardlinking is possible, defining
+	OPENJDK_SRC_DIR_HARDLINKABLE if it is.
+
 2010-06-14  Andrew John Hughes  <ahughes@redhat.com>
 
 	* Makefile.am:
--- a/Makefile.am	Mon Jun 14 13:41:26 2010 +0100
+++ b/Makefile.am	Mon Jun 14 16:27:40 2010 +0100
@@ -237,7 +237,13 @@
 endif
 
 if CP_SUPPORTS_REFLINK
-  REFLINK="--reflink=auto"
+  REFLINK = --reflink=auto
+endif
+
+if OPENJDK_SRC_DIR_HARDLINKABLE
+  OPENJDK_SRC_DIR_LINK = -l
+else
+  OPENJDK_SRC_DIR_LINK = $(REFLINK)
 endif
 
 # Target to ensure a patched OpenJDK tree containing Zero & Shark
@@ -1177,7 +1183,7 @@
 
 stamps/extract-openjdk.stamp: stamps/download-openjdk.stamp
 if OPENJDK_SRC_DIR_FOUND
-	cp -pPR $(REFLINK) $(OPENJDK_SRC_DIR) openjdk
+	cp -pPR $(OPENJDK_SRC_DIR_LINK) $(OPENJDK_SRC_DIR) openjdk
 else
 	set -e ; \
 	if ! test -d openjdk ; then \
--- a/acinclude.m4	Mon Jun 14 13:41:26 2010 +0100
+++ b/acinclude.m4	Mon Jun 14 16:27:40 2010 +0100
@@ -234,7 +234,7 @@
   AC_SUBST(JAVA)
 ])
 
-AC_DEFUN([IT_CP_SUPPORTS_REFLINK],
+AC_DEFUN_ONCE([IT_CP_SUPPORTS_REFLINK],
 [
   AC_CACHE_CHECK([if cp supports --reflink], it_cv_reflink, [
     touch tmp.$$
@@ -248,23 +248,45 @@
   AM_CONDITIONAL([CP_SUPPORTS_REFLINK], test x"${it_cv_reflink}" = "xyes")
 ])
 
-AC_DEFUN([WITH_OPENJDK_SRC_DIR],
+AC_DEFUN_ONCE([WITH_OPENJDK_SRC_DIR],
 [
-  AC_MSG_CHECKING(for an OpenJDK source directory)
+  DEFAULT_SRC_DIR=${abs_top_builddir}/openjdk
+  AC_MSG_CHECKING([for an OpenJDK source directory])
   AC_ARG_WITH([openjdk-src-dir],
               [AS_HELP_STRING(--with-openjdk-src-dir,specify the location of the openjdk sources)],
   [
     OPENJDK_SRC_DIR=${withval}
-    AC_MSG_RESULT(${withval})
-    conditional_with_openjdk_sources=true
+    with_external_src_dir=true
   ],
   [ 
-    conditional_with_openjdk_sources=false
-    OPENJDK_SRC_DIR=`pwd`/openjdk
-    AC_MSG_RESULT(${OPENJDK_SRC_DIR})
+    OPENJDK_SRC_DIR=${DEFAULT_SRC_DIR}
+    with_external_src_dir=false
   ])
+  AC_MSG_RESULT(${OPENJDK_SRC_DIR})
   AC_SUBST(OPENJDK_SRC_DIR)
-  AM_CONDITIONAL(OPENJDK_SRC_DIR_FOUND, test "x${conditional_with_openjdk_sources}" = xtrue)
+  if test "x${with_external_src_dir}" = "xtrue"; then
+    AC_MSG_CHECKING([if ${OPENJDK_SRC_DIR}/README exists])
+    if test -f ${OPENJDK_SRC_DIR}/README; then
+      openjdk_src_dir_valid=yes;
+    else
+      openjdk_src_dir_valid="no, resetting to ${DEFAULT_SRC_DIR}";
+      OPENJDK_SRC_DIR=${DEFAULT_SRC_DIR}
+      with_external_src_dir=false
+    fi
+    AC_MSG_RESULT(${openjdk_src_dir_valid})
+    if test "x${openjdk_src_dir_valid}" = "xyes"; then
+      AC_MSG_CHECKING([if we can hard link rather than copy the OpenJDK source directory])
+      if cp -l ${OPENJDK_SRC_DIR}/README tmp.$$ >&AS_MESSAGE_LOG_FD 2>&1; then
+        openjdk_src_dir_hardlinkable=yes;
+      else
+        openjdk_src_dir_hardlinkable=no;
+      fi
+      AC_MSG_RESULT(${openjdk_src_dir_hardlinkable})
+      rm -f tmp.$$
+    fi
+  fi
+  AM_CONDITIONAL(OPENJDK_SRC_DIR_FOUND, test "x${with_external_src_dir}" = "xtrue")
+  AM_CONDITIONAL(OPENJDK_SRC_DIR_HARDLINKABLE, test "x${openjdk_src_dir_hardlinkable}" = "xyes")
 ])
 
 AC_DEFUN([FIND_ECJ_JAR],