[m-rev.] for preliminary review: post-installation addition of extra library grades

Julien Fischer jfischer at opturion.com
Tue Sep 9 13:57:39 AEST 2014


For preliminary review:

(This almost certainly does not work on Windows at the moment.  Also,
attempting to add extra grades to a cross compiler probably won't work
either.)

---------------------------

Support post-installation addition of extra library grades.

A feature that has often been requested is the ability to add extra library
grades to an existing Mercury installation without requiring a re-install of
the entire system.  In the past doing this has been awkward because the set of
library grades is hardcoded into various configuration files.  This is no
longer true for mmc --make, which now detects the set of installed library
grades at runtime.  (It is still true for mmake, but that probably doesn't matter.)

This change adds a new option to configure script,
--enable-extra-grade-install.  When invoked with this option, the configure
script will set up the source tree to build and install only additional library
grades, not the entire system.  An example of the process is:

    $ ./configure --enable-extra-grade-install
    $ mmake LIBGRADES="java csharp" install

The above causes the java and csharp grades to be added to the existing
installation.  (This is no different to what the developers of Mercury already
do in this situation except that it removes the need to edit Mmakefiles by
hand and makes the whole thing a bit more user-friendly.)

configure.ac:
 	Add the new option.  If it is enabled then:
 	- query the installed Mercury compiler for which C compiler to use.
 	- use the install prefix of the installed compiler by default.
 	- set the set of grades to be installed to empty.

Mmakefile:
 	If the source tree was configure to install extra library grades then:
 	- disable the default target -- print a message about this if it is invoked.
 	- make the install target a synonym for install_grades.
 	- remove the dependency of install_grades on install_main.

Mmake.common.in:
 	Record whether configure was invoked with the
 	--enable-extra-grade-install option.

.INSTALL.in:
 	Document the process for installing extra library grades.

diff --git a/.INSTALL.in b/.INSTALL.in
index db62cf1..c63cf07 100755
--- a/.INSTALL.in
+++ b/.INSTALL.in
@@ -201,6 +201,37 @@ make install
  #          If you want to use Mercury on some other CPU, contact us and
  #          we'll add support for gcc global registers for that CPU.
  #
+# Adding extra library grades to an existing installation
+# -------------------------------------------------------
+#
+# Adding extra library grades to an existing Mercury installation may be done
+# as follows:
+#
+# Step 1. Begin with a clean Mercury source tree.  This source tree must
+#         be the same version as that of the already installed compiler.
+#
+# Step 2. Ensure that the already installed Mercury compiler is in your
+#         PATH.
+#
+# Step 3. Invoke the configure script as follows:
+#
+#         $ configure --enable-extra-grade-install
+#
+#         NOTE: you do not need to provide any other options to configure
+#         when it is invoked with the --enable-extra-grade-install option.
+#         The script will query the installed Mercury compiler for any
+#         settings that it requires.
+#
+# Step 4. Do:
+#
+#         $ mmake LIBGRADES="<grade list>" install
+#
+#         where <grade list> is a space separated list of additional grades to
+#         install.
+#
+# Library grades installed by this method will NOT be recognised by mmake,
+# only by mmc --make.
+#
  # De-installation:
  # ----------------
  #
diff --git a/Mmake.common.in b/Mmake.common.in
index 760fe5d..7d4533d 100644
--- a/Mmake.common.in
+++ b/Mmake.common.in
@@ -26,6 +26,8 @@ SET_RPATH=no
  # This affects the tools set in Mmake.workspace so must be set first.
  CROSS_COMPILING=@CROSS_COMPILING@

+EXTRA_GRADE_INSTALL=@EXTRA_GRADE_INSTALL@
+
  WORKSPACE=$(MERCURY_DIR)
  include $(MERCURY_DIR)/Mmake.workspace

diff --git a/Mmakefile b/Mmakefile
index 920dc42..732ce9a 100644
--- a/Mmakefile
+++ b/Mmakefile
@@ -244,7 +244,17 @@ depend_mfilterjavac:
  # it is required.

  .PHONY: all
+ifeq ("$(EXTRA_GRADE_INSTALL)","no")
  all: 	$(GENERATED_DOCS) util_no_rt $(SUBDIRS)
+else
+all:
+	@echo "-- This source tree has been configured for the installation"
+	@echo "-- of additional library grades only."
+	@echo "-- To build and install the Mercury compiler itself, re-run the"
+	@echo "-- configure script *without* the option \`--enable-extra-grade-install'".
+	@echo "-- See the file INSTALL for further details."
+	@exit 0
+endif

  .PHONY: util_no_rt
  util_no_rt: scripts
@@ -513,6 +523,7 @@ echo_libgrades:
  # The code of the install rule is duplicated in bindist/bindist.Makefile.in.

  .PHONY: install
+ifeq ("$(EXTRA_GRADE_INSTALL)","no")
  install: install_main install_grades
  	@echo
  	@echo "-- Installation complete."
@@ -538,6 +549,12 @@ install: install_main install_grades
  	@echo "	(add-to-list 'load-path "
  	@echo "		\"$(FINAL_INSTALL_ELISP_DIR)\")"
  	@echo "	(autoload 'mdb \"gud\" \"Invoke the Mercury debugger\" t)"
+	@echo
+	@echo "-- If you need to install additional library grades for this"
+	@echo "-- installation then see INSTALL."
+else
+install: install_grades
+endif

  .PHONY: install_main
  install_main: all \
@@ -638,8 +655,15 @@ OVERRIDE_MC_FOR_LIBGRADE = MC=mmc \
  	MERCURY_CONFIG_DIR=$(INSTALL_LIBDIR)
  endif

+# XXX there should be no util dependency in the EXTRA_GRADE_INSTALL case.
+ifeq ("$(EXTRA_GRADE_INSTALL)","no")
+INSTALL_GRADES_DEPS=install_main
+else
+INSTALL_GRADES_DEPS=util
+endif
+
  .PHONY: install_grades
-install_grades: install_main
+install_grades: $(INSTALL_GRADES_DEPS)
  	# Use the newly installed compiler to build the libraries in various
  	# different grades. Except when cross-compiling, we override MC=mmc so
  	# that we use the mmc from the scripts directory, which runs the newly
diff --git a/configure.ac b/configure.ac
index d67cbd0..4f45f29 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,10 +103,36 @@ AC_CONFIG_HEADER(runtime/mercury_conf.h)
  AC_PREFIX_DEFAULT(/usr/local/mercury-`. ./VERSION; echo $VERSION`)

  #-----------------------------------------------------------------------------#
+
+AC_ARG_ENABLE([extra-grade-install],
+    AC_HELP_STRING([--enable-extra-grade-install],
+        [configure the source tree to only install extra library grades]),
+    [enable_extra_grade_install="$enableval"],
+    [enable_extra_grade_install="no"]
+)
+
+if test "$enable_extra_grade_install" = "yes"
+then
+    EXTRA_GRADE_INSTALL="yes"
+else
+    EXTRA_GRADE_INSTALL="no"
+fi
+
+AC_SUBST([EXTRA_GRADE_INSTALL])
+
+#-----------------------------------------------------------------------------#
  #
  # Let the user specify which C compiler to use.
  #

+# If we have been configured for installing extra grades, then query the
+# installed Mercury compiler as to which C compiler to use.
+#
+if test "$EXTRA_GRADE_INSTALL" = yes
+then
+    CC=`mmc --output-cc`
+fi
+
  AC_ARG_WITH(cc,
      AC_HELP_STRING([--with-cc=<program>], [Specify which C compiler to use.]),
      mercury_cv_with_cc="$withval", mercury_cv_with_cc="")
@@ -210,6 +236,20 @@ if test "$prefix" = "NONE"; then
      else
          INSTALLABLE_PREFIX=no
      fi
+
+    # If we are just installing additional libgrades then use the install
+    # prefix of the installed compiler if --prefix was not given.
+    #
+    if test "$EXTRA_GRADE_INSTALL" = "yes"
+    then
+        # XXX there must be a better way of doing this.
+        # XXX Mercury.config requires PREFIX; Mmake.vars requires prefix.
+        prefix=`which mmc`
+        prefix=`dirname $prefix`
+        prefix=`dirname $prefix`
+        PREFIX="$prefix"
+        INSTALLABLE_PREFIX=yes
+    fi
  else
      PREFIX="$prefix"
      # the directory may be created later
@@ -336,6 +376,7 @@ CONFIG_PREFIX="`$CYGPATH $CONFIG_PREFIX`"
  CONFIG_LIBDIR="`$CYGPATH $CONFIG_LIBDIR`"
  AC_SUBST(CONFIG_PREFIX)
  AC_SUBST(CONFIG_LIBDIR)
+
  #-----------------------------------------------------------------------------#

  case "$build" in
@@ -4014,6 +4055,14 @@ do
      fi
  done

+# If we are configured for extra libgrade installation then the user
+# will tell us what grades to install when they run mmake.
+#
+if test "$EXTRA_GRADE_INSTALL" = "yes"
+then
+    LIBGRADES=
+fi
+
  LIBGRADE_OPTS=
  for libgrade in $LIBGRADES
  do



More information about the reviews mailing list