[m-rev.] For review: Fix the handling of $DESTDIR on Windows.

Paul Bone pbone at csse.unimelb.edu.au
Thu Dec 16 14:57:07 AEDT 2010


Julien had some comments in person, this patch fixes them.  I've placed it for
review since it's too easy to make mistakes when modifying the build system.

---

Mmke.vars.in:
    Modify the documentation that discuss how to override INSTALL_PATH
    to describe setting of $DESTDIR instead.

    Don't add a slash before INSTALL_PATH if DESTDIR is empty since this
    breaks installation on Windows.  (This change has already been made
    in Mmake.common.in)

    Set more FINAL_INSTALL_ variables to support the new code in
    Mmakefile and bindist.Makefile.in.

Mmake.common.in:
    Improve the prose in a comment.

Mmakefile:
bindist/bindist.Makefile.in:
    Update installation message.

    Tell the user that their install is in $(DESTDIR) if applicable.

    Use FINAL_INSTALL variables rather than INSTALL variables.

Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.101
diff -u -p -b -r1.101 Mmake.common.in
--- Mmake.common.in	15 Dec 2010 05:28:47 -0000	1.101
+++ Mmake.common.in	16 Dec 2010 03:53:34 -0000
@@ -119,9 +119,9 @@ SHARED_LIBS		= @SHARED_LIBS@
 # in scripts/Mmake.vars to avoid accidentally overwriting an
 # existing installation when using an installed mmake.
 ifeq ($(DESTDIR),)
-	# DESTDIR is The empty string, DESTDIR_AND_SLASH is therefore empty. since
-	# the slash can change a relative path into an absolute one; or on Windows,
-	# from an invalid path name.
+	# DESTDIR is the empty string, DESTDIR_AND_SLASH must therefore be empty.
+	# Otherwise the slash can change a relative path into an absolute one; or
+	# on Windows, it can create an invalid path name.
 	DESTDIR_AND_SLASH=
 else
 	# We cannot append paths like this in Windows, but we don't think anyone
Index: Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmakefile,v
retrieving revision 1.141
diff -u -p -b -r1.141 Mmakefile
--- Mmakefile	14 Dec 2010 07:01:54 -0000	1.141
+++ Mmakefile	16 Dec 2010 03:53:34 -0000
@@ -518,20 +518,26 @@ install: install_main install_grades
 	@echo
 	@echo "-- Installation complete."
 	@echo
-	@echo "-- Don't forget to add $(INSTALL_BINDIR) to your PATH,"
-	@echo "-- $(INSTALL_MAN_DIR) to your MANPATH,"
-	@echo "-- and $(INSTALL_INFO_DIR) to your INFOPATH,"
+	@if test -n "$(DESTDIR)"; then \
+		echo "-- The installation was placed in $(DESTDIR)."; \
+		echo "-- to complete installation copy the contents of"; \
+		echo "-- $(DESTDIR) to the root directory of your system(s)."; \
+		echo; \
+	fi
+	@echo "-- Don't forget to add $(FINAL_INSTALL_BINDIR) to your PATH,"
+	@echo "-- $(FINAL_INSTALL_MAN_DIR) to your MANPATH,"
+	@echo "-- and $(FINAL_INSTALL_INFO_DIR) to your INFOPATH,"
 	@if test $(ENABLE_DEEP_PROFILER) != yes || \
 		cmp -s deep_profiler/mdprof_cgi \
 			$(INSTALL_CGI_DIR)/mdprof_cgi; \
 	then true ; else \
 		echo "-- to copy deep_profiler/mdprof_cgi" \
-			"to $(INSTALL_CGI_DIR),"; \
+			"to $(FINAL_INSTALL_CGI_DIR),"; \
 	fi
 	@echo "-- and to add the following lines to the \`.emacs' file"
 	@echo "-- in your home directory:"
 	@echo "	(add-to-list 'load-path "
-	@echo "		\"$(INSTALL_ELISP_DIR)\")"
+	@echo "		\"$(FINAL_INSTALL_ELISP_DIR)\")"
 	@echo "	(autoload 'mdb \"gud\" \"Invoke the Mercury debugger\" t)"
 
 .PHONY: install_main
Index: bindist/bindist.Makefile.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.Makefile.in,v
retrieving revision 1.38
diff -u -p -b -r1.38 bindist.Makefile.in
--- bindist/bindist.Makefile.in	9 Jul 2010 07:10:15 -0000	1.38
+++ bindist/bindist.Makefile.in	16 Dec 2010 03:53:34 -0000
@@ -147,13 +147,19 @@ include $(MMAKE_VARS)
 .PHONY: post_install
 post_install: install_cgi_progs install_gac
 	@echo
-	@echo "-- Don't forget to add $(INSTALL_BINDIR) to your PATH,"
-	@echo "-- $(INSTALL_MAN_DIR) to your MANPATH,"
-	@echo "-- and $(INSTALL_INFODIR) to your INFOPATH,"
+	@if test -n "$(DESTDIR)"; then \
+		echo "-- The installation was placed in $(DESTDIR)."; \
+		echo "-- to complete installation copy the contents of"; \
+		echo "-- $(DESTDIR) to the root directory of your system(s)."; \
+		echo; \
+	fi
+	@echo "-- Don't forget to add $(FINAL_INSTALL_BINDIR) to your PATH,"
+	@echo "-- $(FINAL_INSTALL_MAN_DIR) to your MANPATH,"
+	@echo "-- and $(FINAL_INSTALL_INFO_DIR) to your INFOPATH,"
 	@echo "-- and to add the following lines to the \`.emacs' file"
 	@echo "-- in your home directory:"
 	@echo "	(add-to-list 'load-path "
-	@echo "		\"$(INSTALL_ELISP_DIR)\")"
+	@echo "		\"$(FINAL_INSTALL_ELISP_DIR)\")"
 	@echo "	(autoload 'mdb \"gud\" \"Invoke the Mercury debugger\" t)"
 
 # The code of the install_cgi_progs target is duplicated from the code
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.114
diff -u -p -b -r1.114 Mmake.vars.in
--- scripts/Mmake.vars.in	14 Dec 2010 07:01:55 -0000	1.114
+++ scripts/Mmake.vars.in	16 Dec 2010 03:53:34 -0000
@@ -664,43 +664,60 @@ INSTALL_MKDIR = mkdir -p
 # HTML files.
 
 # FINAL_INSTALL_PREFIX describes the directory that the installation
-# will finally end up in.  When building the Mercury compiler, it
-# should only be set by the configure script.  Other
-# FINAL_INSTALL_* variables have a similar meaning.
+# will finally end up in.  When building the Mercury compiler, it should
+# only be set by the configure script.  Other FINAL_INSTALL_* variables
+# have a similar meaning.
+#
+# If you want to install to a different directory temporarily (e.g.  to
+# build a package, or if you don't have the permissions to install to a
+# final directory), set DESTDIR on the command-line.  If you have
+# previously configured to the directory you want to finally install to,
+# you will then be able to move the files safely, since any hard-coded
+# paths will be set to their final destination already (note that the
+# installation in the temporary directory may not work until moved into
+# its final destination).  e.g.
 #
-# If you want to install to a different directory temporarily (e.g.
-# to build a package, or if you don't have the permissions to install
-# to a final directory), override INSTALL_PREFIX on the command-line.
-# If you have previously configured to the directory you want to
-# finally install to, you will then be able to move the files safely,
-# since any hard-coded paths will be set to their final destination
-# already (note that the installation in the temporary directory may
-# not work until moved into its final destination).
-# e.g.
 #      configure --prefix /usr
-#      make INSTALL_PREFIX=/some/temporary/directory/usr
+#      make DESTDIR=/some/temporary/directory
 
 # If you don't intend to install to a temporary directory, rather than
-# overriding INSTALL_PREFIX you should reconfigure using the configure
-# script, since there are some hardcoded paths created by the configure
-# script (e.g. in the shell scripts mmc, ml, mmake, etc) that will not
-# be updated simply by overriding INSTALL_PREFIX.
+# setting DESTDIR you should reconfigure using the configure script,
+# since there are some hardcoded paths created by the configure script
+# (e.g. in the shell scripts mmc, ml, mmake, etc) that will not be
+# updated simply by overriding INSTALL_PREFIX.
+
+ifeq ($(DESTDIR),)
+    # DESTDIR is the empty string, DESTDIR_AND_SLASH must therefore be empty.
+    # Otherwise the slash can change a relative path into an absolute one; or
+    # on Windows, it can create an invalid path name.
+    DESTDIR_AND_SLASH=
+else
+    # We cannot append paths like this in Windows, but we don't think anyone
+    # will use DESTDIR on Windows.
+    DESTDIR_AND_SLASH=$(DESTDIR)/
+endif
 
-INSTALL_PREFIX		= $(DESTDIR)/@prefix@
-FINAL_INSTALL_PREFIX	= @prefix@
+INSTALL_PREFIX		= $(DESTDIR_AND_SLASH)@prefix@
 INSTALL_BINDIR		= $(INSTALL_PREFIX)/bin
 INSTALL_LIBDIR		= $(INSTALL_PREFIX)/lib/mercury
-FINAL_INSTALL_LIBDIR	= $(FINAL_INSTALL_PREFIX)/lib/mercury
 INSTALL_INFO_DIR	= $(INSTALL_PREFIX)/info
 INSTALL_DVI_DIR		= $(INSTALL_PREFIX)/lib/mercury/doc
 INSTALL_TEXT_DIR	= $(INSTALL_PREFIX)/lib/mercury/doc
 INSTALL_PS_DIR		= $(INSTALL_PREFIX)/lib/mercury/doc
 INSTALL_PDF_DIR		= $(INSTALL_PREFIX)/lib/mercury/doc
-INSTALL_MAN_DIR		= $(INSTALL_PREFIX)/man
+INSTALL_MAN_DIR		= $(INSTALL_PREFIX)/Man
 INSTALL_HTML_DIR	= $(INSTALL_PREFIX)/lib/mercury/html
 INSTALL_MDB_DOC_DIR	= $(INSTALL_PREFIX)/lib/mercury/mdb
 INSTALL_ELISP_DIR	= $(INSTALL_PREFIX)/lib/mercury/elisp
-INSTALL_CGI_DIR		= $(DESTDIR)/@CGIDIR@
+INSTALL_CGI_DIR		= $(DESTDIR_AND_SLASH)@CGIDIR@
+
+FINAL_INSTALL_PREFIX	= @prefix@
+FINAL_INSTALL_BINDIR 	= $(FINAL_INSTALL_PREFIX)/bin
+FINAL_INSTALL_LIBDIR	= $(FINAL_INSTALL_PREFIX)/lib/mercury
+FINAL_INSTALL_INFO_DIR	= $(FINAL_INSTALL_PREFIX)/info
+FINAL_INSTALL_MAN_DIR	= $(FINAL_INSTALL_PREFIX)/man
+FINAL_INSTALL_ELISP_DIR	= $(FINAL_INSTALL_PREFIX)/lib/mercury/elisp
+FINAL_INSTALL_CGI_DIR	= @CGIDIR@
 
 # You should not need to override anything below here
 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 489 bytes
Desc: Digital signature
URL: <http://lists.mercurylang.org/archives/reviews/attachments/20101216/3f9df82c/attachment.sig>


More information about the reviews mailing list