[m-dev.] For review: Simplified installation of user libraries

Warwick Harvey wharvey at cs.monash.edu.au
Wed Sep 29 20:09:20 AEST 1999


I guess for Fergus to review.  Ralph might want to have a look at it too.

Should `.opt' files always be built and installed regardless of the 
intermodule optimisation level settings?  What about `.trans_opt' files?


Estimated hours taken: 18

Added built-in mmake support for installing user libraries.

Mmake.common.in:
	Moved the definitions of many of the generic install directories
	(plus FULLARCH and LIBGRADES) to scripts/Mmake.vars.in, so they
	can be used for things other than just the Mercury compiler.

compiler/modules.m:
	Added code to generate appropriate lib<module>.install* targets.
	Improved the dependency list generated for the lib<module> target to
	include intermodule optimisation files if and only if the
	appropriate flags have been set (previously it always depended on
	the `.opt' files, but never on the `.trans_opt' files).

scripts/Mmake.rules:
	Added some rules for use when installing libraries.

scripts/Mmake.vars.in:
	Added the definitions of many of the generic install directories 
	(plus FULLARCH and LIBGRADES) from Mmake.common.in.
	Added support for overriding and/or adding to the definition of
	LIBGRADES on a per-library basis.

doc/user_guide.texi:
	Documented the new features.

extras/references/Mmakefile:
extras/references/samples/Mmakefile:
	Changed to exploit/test new features.


cvs server: Diffing .
Index: Mmake.common.in
===================================================================
RCS file: /home/mercury1/repository/mercury/Mmake.common.in,v
retrieving revision 1.39
diff -u -r1.39 Mmake.common.in
--- Mmake.common.in	1999/07/20 21:29:35	1.39
+++ Mmake.common.in	1999/09/29 09:56:58
@@ -21,56 +21,12 @@
 
 #-----------------------------------------------------------------------------#
 
-# Specify the locations for installing things.
-# These directories can all be modified independantly.
-# In particular, you might want to find a better place for the DVI and
-# HTML files.
-
-# FINAL_INSTALL_PREFIX describes the directory that the installation
-# will finally end up in. 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), 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
-
-# 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.
-
-INSTALL_PREFIX		= @prefix@
-FINAL_INSTALL_PREFIX	= @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_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
-
 # Specify the Mercury compiler to use for bootstrapping
 MC			= @BOOTSTRAP_MC@
 
 # Specify the compilation model to use for compiling the compiler
 GRADE			= @GRADE@
 
-# Specify the additional compilation models to install the library for
-LIBGRADES  		= @LIBGRADES@
-
 # Specify EXT_FOR_EXE is `.exe' on MS-Windows and empty elsewhere.
 EXT_FOR_EXE	= @EXT_FOR_EXE@
 
@@ -136,16 +92,8 @@
 
 #-----------------------------------------------------------------------------#
 
-INSTALL_MODULE_DIR	= $(INSTALL_LIBDIR)/modules
-INSTALL_INT_DIR		= $(INSTALL_LIBDIR)/ints
-INSTALL_INC_DIR		= $(INSTALL_LIBDIR)/inc
-INSTALL_MMAKE_DIR 	= $(INSTALL_LIBDIR)/mmake
-FULLARCH		= @FULLARCH@
-INSTALL_MERC_BIN_DIR	= $(INSTALL_LIBDIR)/bin/$(FULLARCH)
-INSTALL_MERC_GC_LIB_DIR	= $(INSTALL_LIBDIR)/lib/$(FULLARCH)
-FINAL_INSTALL_MERC_GC_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(FULLARCH)
-INSTALL_MERC_LIB_DIR	= $(INSTALL_LIBDIR)/lib/$(GRADE)/$(FULLARCH)
-FINAL_INSTALL_MERC_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(GRADE)/$(FULLARCH)
+INSTALL_MERC_GC_LIB_DIR	= $(INSTALL_MERC_GRADELESS_LIB_DIR)
+FINAL_INSTALL_MERC_GC_LIB_DIR = $(FINAL_INSTALL_MERC_GRADELESS_LIB_DIR)
 
 SCRIPTS_DIR = $(MERCURY_DIR)/scripts
 RUNTIME_DIR = $(MERCURY_DIR)/runtime
cvs server: Diffing bindist
cvs server: Diffing boehm_gc
cvs server: Diffing boehm_gc/Mac_files
cvs server: Diffing boehm_gc/cord
cvs server: Diffing boehm_gc/cord/private
cvs server: Diffing boehm_gc/include
cvs server: Diffing boehm_gc/include/private
cvs server: Diffing browser
cvs server: Diffing bytecode
cvs server: Diffing bytecode/test
cvs server: Diffing compiler
Index: compiler/modules.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modules.m,v
retrieving revision 1.108
diff -u -r1.108 modules.m
--- modules.m	1999/09/12 04:26:46	1.108
+++ modules.m	1999/09/29 09:56:58
@@ -2568,6 +2568,20 @@
 		"\t$(RANLIB) $(ALL_RANLIBFLAGS) ", SplitLibFileName, "\n\n"
 	]),
 
+	globals__io_lookup_bool_option(intermodule_optimization, Intermod),
+	{ Intermod = yes ->
+		string__append_list(["$(", MakeVarName, ".opts) "],
+				MaybeOptsVar)
+	;
+		MaybeOptsVar = ""
+	},
+	globals__io_lookup_bool_option(transitive_optimization, TransOpt),
+	{ TransOpt = yes ->
+		string__append_list(["$(", MakeVarName, ".trans_opts) "],
+				MaybeTransOptsVar)
+	;
+		MaybeTransOptsVar = ""
+	},
 	module_name_to_lib_file_name("lib", ModuleName, "", no, LibTargetName),
 	module_name_to_lib_file_name("lib", ModuleName, ".a", yes, LibFileName),
 	module_name_to_lib_file_name("lib", ModuleName, ".so", yes,
@@ -2581,7 +2595,7 @@
 		MaybeSharedLibFileName, " \\\n",
 		"\t\t$(", MakeVarName, ".ints) ",
 		"$(", MakeVarName, ".int3s) ",
-		"$(", MakeVarName, ".opts) ",
+		MaybeOptsVar, MaybeTransOptsVar,
 		InitFileName, "\n\n"
 	]),
 
@@ -2644,6 +2658,59 @@
 		SicstusDebugExeFileName, " : $(", MakeVarName, ".qls)\n",
 		"\t$(MSL) --debug $(ALL_MSLFLAGS) -o ", SicstusDebugExeFileName,
 			" $(", MakeVarName, ".qls)\n\n"
+	]),
+
+	module_name_to_lib_file_name("lib", ModuleName, ".install", no,
+				LibInstallTargetName),
+	module_name_to_lib_file_name("lib", ModuleName, ".install_main", no,
+				LibInstallMainTargetName),
+	module_name_to_lib_file_name("lib", ModuleName, ".install_grades", no,
+				LibInstallGradesTargetName),
+	module_name_to_lib_file_name("lib", ModuleName, ".install_ints", no,
+				LibInstallIntsTargetName),
+	module_name_to_lib_file_name("lib", ModuleName, ".install_init", no,
+				LibInstallInitTargetName),
+	module_name_to_lib_file_name("lib", ModuleName, ".install_library", no,
+				LibInstallLibraryTargetName),
+	io__write_strings(DepStream, [
+		".PHONY : ", LibInstallTargetName, "\n",
+		LibInstallTargetName, " : ", LibInstallMainTargetName, " ",
+			LibInstallGradesTargetName, "\n\n",
+		".PHONY : ", LibInstallMainTargetName, "\n",
+		LibInstallMainTargetName, " : ", LibInstallIntsTargetName, " ",
+			LibInstallInitTargetName, " ",
+			LibInstallLibraryTargetName, "\n\n"
+	]),
+
+	io__write_strings(DepStream, [
+		".PHONY : ", LibInstallIntsTargetName, "\n",
+		LibInstallIntsTargetName, " : $(", MakeVarName, ".ints) $(",
+			MakeVarName, ".int3s) ", MaybeOptsVar,
+			MaybeTransOptsVar, "install_lib_dirs\n",
+		"\tfor file in $(", MakeVarName, ".ints) $(", MakeVarName,
+			".int3s) ", MaybeOptsVar, MaybeTransOptsVar,
+			"; do \\\n",
+		"\t\ttarget=$(INSTALL_INT_DIR)/`basename $$file`; \\\n",
+		"\t\tif cmp -s $$file $$target; then \\\n",
+		"\t\t\techo \"$$target unchanged\"; \\\n",
+		"\t\telse \\\n",
+		"\t\t\techo \"installing $$target\"; \\\n",
+		"\t\t\tcp $$file $$target; \\\n",
+		"\t\tfi; \\\n",
+		"\tdone\n",
+		"\t# The following is needed to support the `--use-subdirs'",
+			" option\n",
+		"\t# We try using `ln -s', but if that fails, then we just",
+			" use `cp'.\n",
+		"\tfor ext in int int2 int3 opt trans_opt; do \\\n",
+		"\t\tdir=$${ext}s; \\\n",
+		"\t\trm -f $(INSTALL_INT_DIR)/Mercury/$$dir; \\\n",
+		"\t\tln -s .. $(INSTALL_INT_DIR)/Mercury/$$dir || { \\\n",
+		"\t\t\tmkdir $(INSTALL_INT_DIR)/Mercury/$$dir && \\\n",
+		"\t\t\tcp $(INSTALL_INT_DIR)/*.$$ext \\\n",
+		"\t\t\t\t$(INSTALL_INT_DIR)/Mercury/$$dir; \\\n",
+		"\t\t} || exit 1; \\\n",
+		"\tdone\n\n"
 	]),
 
 	module_name_to_file_name(SourceModuleName, ".check", no,
cvs server: Diffing compiler/notes
cvs server: Diffing debian
cvs server: Diffing detail
cvs server: Diffing doc
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.184
diff -u -r1.184 user_guide.texi
--- user_guide.texi	1999/08/18 06:26:06	1.184
+++ user_guide.texi	1999/09/29 09:56:59
@@ -427,6 +427,12 @@
 (for platforms that support it), and the necessary interface files.
 For more information, see @ref{Libraries}.
 
+ at item lib at var{main-module}.install
+Builds and installs a library whose top-level module is @var{main-module}.
+This will build and install a static object library, a shared object library
+(for platforms that support it), and the necessary interface files.
+For more information, see @ref{Supporting multiple grades and architectures}.
+
 @item @var{main-module}.clean
 Removes the automatically generated files
 that contain the compiled code of the program
@@ -561,6 +567,20 @@
 @item EXTRA_LIB_DIRS
 A list of extra Mercury library directory hierarchies to search when
 looking for extra libraries.
+
+ at item INSTALL_PREFIX
+The path to the root of the directory hierarchy where the libraries,
+etc. you are building should be installed.  The default is to install in
+the same location as the Mercury compiler being used to do the install.
+
+ at item LIBGRADES
+A list of additional grades which should be built when installing libraries.
+The default is to install the Mercury compiler's default set of grades.
+Note that this may not be the set of grades in which the standard libraries
+were actually installed.
+Note also that any @code{GRADEFLAGS} settings will also be applied when
+the library is built in each of the listed grades, so you may not get what
+you expect if those options are not subsumed by each of the grades listed.
 @end table
 
 Other variables also exist - see
@@ -815,15 +835,41 @@
 @section Supporting multiple grades and architectures
 
 In order to better support using and installing libraries in multiple
-grades, @samp{mmake} now has some support for alternative library directory
+grades, @samp{mmake} now has support for alternative library directory
 hierarchies.
 These have the same structure as the @file{@var{prefix}/lib/mercury} tree,
 including the different subdirectories for different grades and different
 machine architectures.
+
+In order to support the installation of a library into such a tree, you
+simply need to specify (e.g. in your @file{Mmakefile}) the path prefix
+and the list of grades to install:
+
+ at example
+INSTALL_PREFIX = /my/install/dir
+LIBGRADES = asm_fast asm_fast.gc.tr.debug
+ at end example
+
+This specifies that libraries should be installed in
+ at file{/my/install/dir/lib/mercury}, in the default grade plus
+ at samp{asm_fast} and @samp{asm_fast.gc.tr.debug}.
+If @samp{INSTALL_PREFIX} is not specified, @samp{mmake} will attempt to
+install the library in the same place as the standard Mercury libraries.
+If @samp{LIBGRADES} is not specified, @samp{mmake} will use the Mercury
+compiler's default set of grades, which may or may not correspond to the
+actual set of grades in which the standard Mercury libraries were installed.
+
+To actually install a library @samp{lib at var{foo}}, use the @samp{mmake}
+target @samp{lib at var{foo}.install}.
+This also installs all the needed interface files, and (if intermodule
+optimisation is enabled) the relevant intermodule optimisation files.
+
+One can override the list of grades to install for a given library
+ at samp{lib at var{foo}} by setting the @samp{LIBGRADES- at var{foo}} variable,
+or add to it by setting @samp{EXTRA_LIBGRADES- at var{foo}}.
 
-Automatically installing a library and all its associated files to such a
-tree is not yet supported, but until it is the user can use the same
-techniques used for building and installing the core Mercury libraries.
+Note that at this stage is not possible to set the installation prefix
+on a library-by-library basis.
 
 Once a library is installed in such a hierarchy, using it is easy.
 Suppose the user wishes to use the library @samp{mypackage} (installed
@@ -833,7 +879,8 @@
 The user need only set the following Mmake variables:
 
 @example
-EXTRA_LIB_DIRS = /some/directory/mypackage /some/directory/myotherlib
+EXTRA_LIB_DIRS = /some/directory/mypackage/lib/mercury \
+		/some/directory/myotherlib/lib/mercury
 EXTRA_LIBRARIES = mypackage myotherlib
 @end example
 
cvs server: Diffing extras
cvs server: Diffing extras/aditi
cvs server: Diffing extras/cgi
cvs server: Diffing extras/complex_numbers
cvs server: Diffing extras/complex_numbers/samples
cvs server: Diffing extras/complex_numbers/tests
cvs server: Diffing extras/dynamic_linking
cvs server: Diffing extras/exceptions
cvs server: Diffing extras/graphics
cvs server: Diffing extras/graphics/mercury_opengl
cvs server: Diffing extras/graphics/mercury_tcltk
cvs server: Diffing extras/graphics/samples
cvs server: Diffing extras/graphics/samples/calc
cvs server: Diffing extras/graphics/samples/maze
cvs server: Diffing extras/graphics/samples/pent
cvs server: Diffing extras/lazy_evaluation
cvs server: Diffing extras/lazy_evaluation/examples
cvs server: Diffing extras/odbc
cvs server: Diffing extras/references
Index: extras/references/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/references/Mmakefile,v
retrieving revision 1.1
diff -u -r1.1 Mmakefile
--- Mmakefile	1998/06/18 04:30:20	1.1
+++ Mmakefile	1999/09/29 09:56:59
@@ -6,6 +6,16 @@
 
 GRADEFLAGS += --use-trail
 
+# Install in an "extras" subdirectory of the main installation tree
+INSTALL_PREFIX := $(INSTALL_PREFIX)/extras
+LIBGRADES = asm_fast.tr asm_fast.gc.tr.debug
+
+MAIN_TARGET = libglobal
+
+# In case the user of the library wants to do intermodule optimisation
+MCFLAGS += --intermodule-optimisation
+MCFLAGS += --transitive-intermodule-optimisation
+
 depend: global.depend
 	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend
 	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" depend
@@ -13,6 +23,8 @@
 check: libglobal
 	cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
 	cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
+
+install: libglobal.install
 
 clean: clean_subdirs
 
cvs server: Diffing extras/references/samples
Index: extras/references/samples/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/extras/references/samples/Mmakefile,v
retrieving revision 1.3
diff -u -r1.3 Mmakefile
--- Mmakefile	1999/09/16 04:45:49	1.3
+++ Mmakefile	1999/09/29 09:57:00
@@ -9,14 +9,9 @@
 # We need to use a grade with trailing
 GRADEFLAGS += --use-trail
 
-MGNUCFLAGS= -I..
+EXTRA_LIB_DIRS = $(INSTALL_PREFIX)/extras/lib/mercury
 
-# Link in the reference library from ..
-MCFLAGS += -I.. $(EXTRA_MCFLAGS)
-MLFLAGS += -R`pwd`/.. -L.. $(EXTRA_MLFLAGS)
-MLLIBS = -lglobal $(EXTRA_MLLIBS)
-VPATH = ..:$(MMAKE_VPATH)
-C2INITARGS = ../global.init
+EXTRA_LIBRARIES = global
 
 # We need the following to use shared libraries on Linux
 #MGNUCFLAGS += -DPIC_REG
cvs server: Diffing extras/references/tests
cvs server: Diffing extras/trailed_update
cvs server: Diffing extras/trailed_update/samples
cvs server: Diffing extras/trailed_update/tests
cvs server: Diffing library
cvs server: Diffing lp_solve
cvs server: Diffing lp_solve/lp_examples
cvs server: Diffing profiler
cvs server: Diffing readline
cvs server: Diffing readline/doc
cvs server: Diffing readline/examples
cvs server: Diffing readline/shlib
cvs server: Diffing readline/support
cvs server: Diffing runtime
cvs server: Diffing runtime/GETOPT
cvs server: Diffing runtime/machdeps
cvs server: Diffing samples
cvs server: Diffing samples/c_interface
cvs server: Diffing samples/c_interface/c_calls_mercury
cvs server: Diffing samples/c_interface/cplusplus_calls_mercury
cvs server: Diffing samples/c_interface/mercury_calls_c
cvs server: Diffing samples/c_interface/mercury_calls_cplusplus
cvs server: Diffing samples/c_interface/mercury_calls_fortran
cvs server: Diffing samples/c_interface/simpler_c_calls_mercury
cvs server: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs server: Diffing samples/diff
cvs server: Diffing samples/muz
cvs server: Diffing samples/rot13
cvs server: Diffing scripts
Index: scripts/Mmake.rules
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.rules,v
retrieving revision 1.71
diff -u -r1.71 Mmake.rules
--- Mmake.rules	1999/08/18 06:26:09	1.71
+++ Mmake.rules	1999/09/29 09:57:05
@@ -321,3 +321,68 @@
 clean_local: clean_prof_files
 
 #-----------------------------------------------------------------------------#
+#
+# Targets for building and installing libraries.
+#
+
+# It would nice to also have rules for `lib%.install' and `lib%.install_main'
+# here, but pattern rules are ignored if they have no body, so they must go
+# in each module's `.dep' file instead.
+
+# We also put the `lib%.install_ints' rule in each module's `.dep' file so
+# it can be more easily customised based on the desired level of intermodule
+# optimisation.
+
+.PHONY: lib%.install_init
+lib%.install_init: %.init install_lib_dirs
+	cp `vpath_find $*.init` $(INSTALL_MODULE_DIR)
+
+.PHONY: lib%.install_library
+lib%.install_library: lib%.a lib%.$(EXT_FOR_SHARED_LIB) install_grade_dirs
+	cp `vpath_find lib$*.a lib$*.$(EXT_FOR_SHARED_LIB)` \
+			$(INSTALL_MERC_LIB_DIR)
+
+lib%.install_split_library: %.split.a install_grade_dirs
+	cp `vpath_find $*.split.a` $(INSTALL_MERC_LIB_DIR)/lib$*.a
+
+lib%.install_grades:
+	rm -rf tmp_dir && \
+	mkdir tmp_dir && \
+	{ mv -f *.c *.o *.pic_o *.a *.so tmp_dir || true; } && \
+	for grade in x $(ALL_LIBGRADES); do \
+		if [ "$$grade" != "x" ]; then \
+			$(MMAKE) GRADE=$$grade lib$*.install_library || \
+				exit 1; \
+			rm -rf *.c *.o *.pic_o *.a *.so; \
+		fi; \
+	done && \
+	{ mv tmp_dir/* . ; rmdir tmp_dir ; true }
+
+lib%.install_split_grades:
+	rm -rf tmp_dir && \
+	mkdir tmp_dir && \
+	{ mv -f *.dir *.c *.o *.pic_o *.a *.so tmp_dir || true; } && \
+	for grade in x $(ALL_LIBGRADES); do \
+		if [ "$$grade" != "x" ]; then \
+			$(MMAKE) GRADE=$$grade lib$*.install_split_library || \
+				exit 1; \
+			rm -rf *.dir *.c *.o *.pic_o *.a *.so; \
+		fi; \
+	done && \
+	{ mv tmp_dir/* . ; rmdir tmp_dir ; true }
+
+
+.PHONY: install_lib_dirs
+install_lib_dirs:
+	-[ -d $(INSTALL_INT_DIR) ] || mkdir -p $(INSTALL_INT_DIR)
+	-[ -d $(INSTALL_INC_DIR) ] || mkdir -p $(INSTALL_INC_DIR)
+	-[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
+	# The following is needed to support the `--use-subdirs' option
+	-[ -d $(INSTALL_INT_DIR)/Mercury ] || \
+		mkdir -p $(INSTALL_INT_DIR)/Mercury
+
+.PHONY: install_grade_dirs
+install_grade_dirs: #install_lib_dirs
+	-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
+
+#-----------------------------------------------------------------------------#
Index: scripts/Mmake.vars.in
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmake.vars.in,v
retrieving revision 1.28
diff -u -r1.28 Mmake.vars.in
--- Mmake.vars.in	1999/07/26 02:52:44	1.28
+++ Mmake.vars.in	1999/09/29 09:57:05
@@ -188,6 +188,11 @@
 RANLIBFLAGS	=
 EXTRA_RANLIBFLAGS =
 
+# List of grades to install for a library
+ALL_LIBGRADES	= $(TARGET_LIBGRADES) $(EXTRA_TARGET_LIBGRADES)
+LIBGRADES	=
+EXTRA_LIBGRADES	=
+
 # $(CFLAGS_FOR_PIC) is passed to the C compiler when creating `.pic_o' files
 # (We use `.pic_o' as the extension for `.o' files that must have
 # position-independent code.)
@@ -305,6 +310,17 @@
 maybe-target-EXTRA_LIBRARIES- = $(EXTRA_LIBRARIES-$(patsubst %_init.c,%,$@))
 maybe-target-EXTRA_LIBRARIES-undefined =
 
+TARGET_LIBGRADES = \
+  $(maybe-base-LIBGRADES-$(findstring undefined,$(origin LIBGRADES-$*)))
+maybe-base-LIBGRADES- = $(LIBGRADES-$*)
+maybe-base-LIBGRADES-undefined = $(LIBGRADES) $(EXTRA_LIBGRADES)
+
+EXTRA_TARGET_LIBGRADES = \
+  $(maybe-base-EXTRA_LIBGRADES-$(findstring undefined,\
+		$(origin EXTRA_LIBGRADES-$*)))
+maybe-base-EXTRA_LIBGRADES- = $(EXTRA_LIBGRADES-$*)
+maybe-base-EXTRA_LIBGRADES-undefined =
+
 # Support for compiling Mercury programs with Prolog will probably be
 # dropped one of these days, so it's probably not worth bothering with these.
 TARGET_MNCFLAGS	=
@@ -382,5 +398,67 @@
 MAIN_TARGET =
 
 default_target: main_target
+
+#-----------------------------------------------------------------------------#
+
+# Specify the locations for installing things.
+# These directories can all be modified independantly.
+# In particular, you might want to find a better place for the DVI and
+# 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.
+#
+# 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
+
+# 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.
+
+INSTALL_PREFIX		= @prefix@
+FINAL_INSTALL_PREFIX	= @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_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
+
+# You should not need to override anything below here
+
+INSTALL_MODULE_DIR	= $(INSTALL_LIBDIR)/modules
+INSTALL_INT_DIR		= $(INSTALL_LIBDIR)/ints
+INSTALL_INC_DIR		= $(INSTALL_LIBDIR)/inc
+INSTALL_MMAKE_DIR	= $(INSTALL_LIBDIR)/mmake
+FULLARCH		= @FULLARCH@
+INSTALL_MERC_BIN_DIR	= $(INSTALL_LIBDIR)/bin/$(FULLARCH)
+INSTALL_MERC_GRADELESS_LIB_DIR = $(INSTALL_LIBDIR)/lib/$(FULLARCH)
+FINAL_INSTALL_MERC_GRADELESS_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(FULLARCH)
+INSTALL_MERC_LIB_DIR	= $(INSTALL_LIBDIR)/lib/$(GRADE)/$(FULLARCH)
+FINAL_INSTALL_MERC_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(GRADE)/$(FULLARCH)
+
+#-----------------------------------------------------------------------------#
+
+# Specify the additional compilation models to install by default
+LIBGRADES		= @LIBGRADES@
 
 #-----------------------------------------------------------------------------#
cvs server: Diffing tools
cvs server: Diffing trace
cvs server: Diffing trial
cvs server: Diffing util

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list