Added built-in mmake support for installing user libraries.

Estimated hours taken: 30

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.

scripts/mercury_cleanup_install:
	New script, for cleaning up after failed installs.

scripts/Mmakefile:
	Added `mercury_cleanup_install' to the list of scripts to be
	installed.

bindist/Mmakefile:
bindist/bindist.Makefile.in:
	Added `mercury_cleanup_install' and `vpath_find' to the list of
	utilities included in and installed by a binary distribution.  These
	are used by some of the install targets.

doc/user_guide.texi:
	Documented the new features.

extras/references/Mmakefile:
extras/references/samples/Mmakefile:
	Changed to exploit/test new features.
This commit is contained in:
Warwick Harvey
1999-10-21 14:36:39 +00:00
parent 8e8a6e5273
commit be51ca48b6
11 changed files with 399 additions and 79 deletions

View File

@@ -21,56 +21,12 @@ include $(MERCURY_DIR)/VERSION
#-----------------------------------------------------------------------------#
# 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 @@ SHARED_LIBS = @SHARED_LIBS@
#-----------------------------------------------------------------------------#
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

View File

@@ -16,10 +16,13 @@ INSTALL_LIB_DIR = $(INSTALL_PREFIX)/lib
LIB_FILES = bin doc html inc ints lib mdb/mdb_doc modules
# Miscellaneous scripts and utilities not processed by configure
UTILS = $(INSTALL_PREFIX)/bin/mkinit$(EXT_FOR_EXE) \
$(INSTALL_PREFIX)/bin/mdemangle$(EXT_FOR_EXE) \
$(INSTALL_PREFIX)/bin/mtags \
$(INSTALL_PREFIX)/bin/mprof_merge_runs
$(INSTALL_PREFIX)/bin/mprof_merge_runs \
$(INSTALL_PREFIX)/bin/vpath_find \
$(INSTALL_PREFIX)/bin/mercury_cleanup_install
README_ETC = ../COPYING ../COPYING.LIB ../HISTORY ../LIMITATIONS \
../NEWS ../RELEASE_NOTES ../BUGS ../WORK_IN_PROGRESS \

View File

@@ -16,6 +16,7 @@ INSTALL_INFODIR = $(INSTALL_PREFIX)/info
INSTALL_MAN_DIR = $(INSTALL_PREFIX)/man
INSTALL_ELISP_DIR = $(INSTALL_PREFIX)/lib/mercury/elisp
# These scripts are generated by configure from the corresponding `.in' file
INSTALL_SCRIPTS = scripts/c2init scripts/mmc \
scripts/mercury_update_interface scripts/mgnuc \
scripts/ml scripts/mmake scripts/mprof \
@@ -29,8 +30,10 @@ INSTALL_MDB_EXTRAS = scripts/mdbrc
LIB_PARTS = bin doc html inc ints lib mdb/mdb_doc modules
# Any miscellaneous scripts and utilities not processed by configure
UTILS = util/mdemangle util/mkinit util/mtags \
util/mprof_merge_runs
util/mprof_merge_runs util/vpath_find \
util/mercury_cleanup_install
#-----------------------------------------------------------------------------#

View File

@@ -563,6 +563,7 @@ choose_file_name(_ModuleName, BaseName, Ext, MkDir, FileName) -->
; Ext = ".clean_sicstus"
; Ext = ".realclean"
; Ext = ".depend"
; Ext = ".install_ints"
; Ext = ".check"
; Ext = ".ints"
; Ext = ".int3s"
@@ -2567,6 +2568,20 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream) -->
"\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,
@@ -2580,7 +2595,7 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream) -->
MaybeSharedLibFileName, " \\\n",
"\t\t$(", MakeVarName, ".ints) ",
"$(", MakeVarName, ".int3s) ",
"$(", MakeVarName, ".opts) ",
MaybeOptsVar, MaybeTransOptsVar,
InitFileName, "\n\n"
]),
@@ -2645,6 +2660,41 @@ generate_dep_file(SourceFileName, ModuleName, DepsMap, DepStream) -->
" $(", MakeVarName, ".qls)\n\n"
]),
module_name_to_lib_file_name("lib", ModuleName, ".install_ints", no,
LibInstallIntsTargetName),
{ InstallIntsRuleBody =
" for file in $$files; do \\
target=$(INSTALL_INT_DIR)/`basename $$file`; \\
if cmp -s $$file $$target; then \\
echo \"$$target unchanged\"; \\
else \\
echo \"installing $$target\"; \\
cp $$file $$target; \\
fi; \\
done
# The following is needed to support the `--use-subdirs' option
# We try using `ln -s', but if that fails, then we just use `cp'.
for ext in int int2 int3 opt trans_opt; do \\
dir=$${ext}s; \\
rm -f $(INSTALL_INT_DIR)/Mercury/$$dir; \\
ln -s .. $(INSTALL_INT_DIR)/Mercury/$$dir || { \\
mkdir $(INSTALL_INT_DIR)/Mercury/$$dir && \\
cp $(INSTALL_INT_DIR)/*.$$ext \\
$(INSTALL_INT_DIR)/Mercury/$$dir; \\
} || exit 1; \\
done\n\n" },
io__write_strings(DepStream, [
".PHONY : ", LibInstallIntsTargetName, "\n",
LibInstallIntsTargetName, " : $(", MakeVarName, ".ints) $(",
MakeVarName, ".int3s) ", MaybeOptsVar,
MaybeTransOptsVar, "install_lib_dirs\n",
"\tfiles=""$(", MakeVarName, ".ints) $(", MakeVarName,
".int3s) ", MaybeOptsVar, MaybeTransOptsVar,
"""; \\\n",
InstallIntsRuleBody
]),
module_name_to_file_name(SourceModuleName, ".check", no,
CheckTargetName),
module_name_to_file_name(ModuleName, ".ints", no, IntsTargetName),

View File

@@ -427,6 +427,15 @@ This will build a static object library, a shared object library
(for platforms that support it), and the necessary interface files.
For more information, see @ref{Libraries}.
@item lib@var{main-module}.install
Builds and installs a library whose top-level module is @var{main-module}.
This target will build and install a static object library and
(for platforms that support it) a shared object library,
for the default grade and also for the additional grades specified
in the LIBGRADES variable. It will also build and install 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 +570,20 @@ For example the library including the files @file{libfoo.a} and
@item EXTRA_LIB_DIRS
A list of extra Mercury library directory hierarchies to search when
looking for extra libraries.
@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.
@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
@@ -684,7 +707,8 @@ will look something like this:
@example
libmypackage: libmypackage.a libmypackage.so \
$(mypackage.ints) $(mypackage.opts) mypackage.init
$(mypackage.ints) $(mypackage.int3s) \
$(mypackage.opts) $(mypackage.trans_opts) mypackage.init
libmypackage.a: $(mypackage.os)
rm -f libmypackage.a
@@ -714,15 +738,18 @@ the library, while the @samp{MLLIBS} variable should contain a list of
Note that to use a library, as well as the shared or static object library,
you also need the interface files. That's why the
@samp{libmypackage} target builds @samp{$(mypackage.ints)}.
@samp{libmypackage} target builds @samp{$(mypackage.ints)} and
@samp{$(mypackage.int3s)}.
If the people using the library are going to use intermodule
optimization, you will also need the intermodule optimization interfaces.
That's why the @samp{libmypackage} target builds @samp{$(mypackage.opts)}.
If the people using the library are going to use transitive intermodule
optimization, you will also need the transitive intermodule optimization
interfaces. Currently these are @emph{not} built by default; if
you want to build them, you will need to include @samp{--trans-intermod-opt}
in your @samp{MCFLAGS} variable.
The @samp{libmypackage} target will build @samp{$(mypackage.opts)} if
@samp{--intermodule-optimization} is specified in your @samp{MCFLAGS}
variable (this is recommended).
Similarly, if the people using the library are going to use transitive
intermodule optimization, you will also need the transitive intermodule
optimization interfaces (@samp{$(mypackage.trans_opt)}).
These will be built if @samp{--trans-intermod-opt} is specified in your
@samp{MCFLAGS} variable.
In addition, with certain compilation grades, programs will need to
execute some startup code to initialize the library; the
@@ -815,15 +842,41 @@ Mercury implementation does not require that.
@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.
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.
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:
@example
INSTALL_PREFIX = /my/install/dir
LIBGRADES = asm_fast asm_fast.gc.tr.debug
@end example
This specifies that libraries should be installed in
@file{/my/install/dir/lib/mercury}, in the default grade plus
@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@var{foo}}, use the @samp{mmake}
target @samp{lib@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
@samp{lib@var{foo}} by setting the @samp{LIBGRADES-@var{foo}} variable,
or add to it by setting @samp{EXTRA_LIBGRADES-@var{foo}}.
Note that currently it 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 +886,8 @@ in the tree rooted at @samp{/some/directory/mypackage}) and the library
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

View File

@@ -1,11 +1,21 @@
#-----------------------------------------------------------------------------#
# Copyright (C) 1997-1998 The University of Melbourne.
# Copyright (C) 1997-1999 The University of Melbourne.
# This file may only be copied under the terms of the GNU Library General
# Public License - see the file COPYING.LIB in the Mercury distribution.
#-----------------------------------------------------------------------------#
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
@@ -14,6 +24,8 @@ check: libglobal
cd samples && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
cd tests && mmake $(MMAKEFLAGS) GRADEFLAGS="$(GRADEFLAGS)" check
install: libglobal.install
clean: clean_subdirs
.PHONY: clean_subdirs

View File

@@ -9,14 +9,9 @@ MAIN_TARGET = all
# 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

View File

@@ -321,3 +321,78 @@ realclean_local: clean_local
clean_local: clean_prof_files
#-----------------------------------------------------------------------------#
#
# Targets for building and installing libraries.
#
# Note: the `lib%.install_ints' rule is generated in each module's `.dep'
# file so it can be more easily customised based on the desired level of
# intermodule optimisation.
.PHONY: lib%.install
lib%.install: lib%.install_ints lib%.install_init lib%.install_library
$(MMAKE) lib$*.install_grades || ( mercury_cleanup_install && exit 1 )
.PHONY: lib%.install_split
lib%.install_split: lib%.install_ints lib%.install_init \
lib%.install_split_library
$(MMAKE) lib$*.install_split_grades || \
( mercury_cleanup_install && exit 1 )
.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 $($*.cs) $($*.os) $($*.pic_os) *.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 -f $($*.cs) $($*.os) $($*.pic_os) *.a *.so; \
fi; \
done && \
{ mv tmp_dir/*.c $(cs_subdir). ; \
mv tmp_dir/*.o $(os_subdir). ; \
mv tmp_dir/*.pic_o $(os_subdir). ; \
mv tmp_dir/* . ; rmdir tmp_dir ; true }
lib%.install_split_grades:
rm -rf tmp_dir && \
mkdir tmp_dir && \
{ mv -f $($*.dirs) *.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 $($*.dirs) *.a *.so; \
fi; \
done && \
{ mv tmp_dir/*.dir $(dirs_subdir). ; \
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)
#-----------------------------------------------------------------------------#

View File

@@ -188,6 +188,11 @@ ALL_RANLIBFLAGS = $(RANLIBFLAGS) $(EXTRA_RANLIBFLAGS) $(TARGET_RANLIBFLAGS)
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 @@ TARGET_EXTRA_LIBRARIES = \
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 =
@@ -323,6 +339,9 @@ TARGET_MSPFLAGS =
ifeq ($(MMAKE_USE_SUBDIRS),yes)
# If you change any of these, you may need to update
# `mercury_cleanup_install'.
SUBDIR=Mercury/
nos_subdir=$(SUBDIR)nos/
@@ -384,3 +403,66 @@ 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/$(GRADESTRING)/$(FULLARCH)
FINAL_INSTALL_MERC_LIB_DIR = \
$(FINAL_INSTALL_LIBDIR)/lib/$(GRADESTRING)/$(FULLARCH)
#-----------------------------------------------------------------------------#
# Specify the additional compilation models to install by default
LIBGRADES = @LIBGRADES@
#-----------------------------------------------------------------------------#

View File

@@ -16,7 +16,7 @@ include $(MERCURY_DIR)/Mmake.common
SCRIPTS = mmake mmc mdb c2init mgnuc ml mprof mprof_merge_runs \
sicstus_conv mtags vpath_find mercury_update_interface \
mkfifo_using_mknod
mkfifo_using_mknod mercury_cleanup_install
DEBUGGER_SCRIPTS = mdbrc
EMACS_SCRIPTS = gud.el

98
scripts/mercury_cleanup_install Executable file
View File

@@ -0,0 +1,98 @@
#! /bin/sh
#---------------------------------------------------------------------------#
# Copyright (C) 1999 Monash University.
# This file may only be copied under the terms of the GNU General
# Public License - see the file COPYING in the Mercury distribution.
#---------------------------------------------------------------------------#
#
# mercury_cleanup_install
#
# Author: Warwick Harvey <wharvey@cs.monash.edu.au>
#
# Checks for failed/aborted installation attempts, and tries to clean up
# after them, since simply re-starting the install may do the wrong thing.
#
# The main problem with restarting an install is when the install is
# interrupted during the building of alternative grades of the library,
# runtime, etc. When the alternative grades are being built, the versions
# of the compiled files needed for the compiler itself (as opposed to
# installed libraries) are moved into a `tmp_dir' subdirectory, with the
# alternative versions being built in the old location. This means that if
# the process is interrupted and then re-started, the build process will
# attempt to re-build the compiler using some files with the wrong grade.
#
# This script checks for the presence of subdirectories named `tmp_dir',
# and if it finds them, assumes that an install process has failed and
# needs to be cleaned up. Cleaning up the failed install consists simply
# of moving all the files in each `tmp_dir' back to where they came
# from, overwriting any alternative grade versions that may be there,
# and deleting the temporary directories.
#
# If there is an error while doing the clean-up, a more aggressive approach
# is used. An "mmake clean" is run on the directory in question, and then
# the `tmp_dir' is deleted completely. Note that for some directories (e.g.
# `library' and `browser'), this deletes some C files, which require a
# working version of Mercury to rebuild. However, if the installation got
# as far as building the different grades of the library, then the compiler
# (plus its default grade) has already been installed. The build scripts
# are smart enough to find and use this installed version even if it's not
# in the user's path, so the "mmake clean" is safe even if there is no
# existing Mercury installation (e.g. if the user is building it from
# release sources).
cleanup_failed_dirs=
for tmp in `find . -name tmp_dir -print` ; do
dir=`dirname $tmp`
echo "Cleaning up from apparent failed install in \`$dir'..."
if (
cd $dir && (
if [ -d Mercury/dirs ] ; then
dirs_subdir=Mercury/dirs/
else
dirs_subdir=
fi
# For every saved `.dir' directory, delete any existing one so
# it can be moved back (one can't just clobber directories).
(
cd tmp_dir &&
for dir in *.dir ; do
if [ "$dir" != "*.dir" ] ; then
rm -rf ../$dirs_subdir$dir
fi
done
)
[ -d Mercury/dirs ] && mv tmp_dir/*.dir $dirs_subdir
[ -d Mercury/cs ] && mv -f tmp_dir/*.c Mercury/cs
[ -d Mercury/os ] && mv -f tmp_dir/*.o tmp_dir/*.pic_o Mercury/os
mv -f tmp_dir/* .
rmdir tmp_dir
)
) ; then
echo "Done."
else
echo "Failed. Trying a more aggressive approach..."
if ( cd $dir && mmake clean && rm -rf tmp_dir ) ; then
echo "Succeeded."
else
echo "Failed again. :-("
cleanup_failed_dirs="$cleanup_failed_dirs $dir"
fi
fi
done
if [ -n "$cleanup_failed_dirs" ] ; then
cat <<END
Clean-up failed in the following directories:
$cleanup_failed_dirs
Either fix these directories by hand, or start over from scratch.
END
exit 1
fi
exit 0