mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-11 20:03:28 +00:00
Estimated hours taken: 7
Branches: main, release
Fix the bug with initialisers/finalisers in libraries not being called ( and
as consequence also fixes the bug with mutables not being given their correct
initial value). The problem was that the directives necessary to call them
were not being included in the libraries' .init file.
The fix is to add a new mode of operation to mkinit that given a list of
.c files that make up some Mercury library, constructs the .init file for
that library. In particular, it now constructs the .init file so that
it contains any REQUIRED_{INIT,FINAL} directives needed by the library.
The new mode of operation is invoked when mkinit is given the `-k' option.
Modify the build systems (i.e. mmake and mmc --make) to conform to the
above change.
compiler/modules.m:
Change the rule mmake uses to build .init files so that it calls
mkinit -k on all the .c files generated for the library.
scripts/Mmake.vars.in:
Add a new mmake variable MKLIBINIT. This is the program used to
create .init files. (It will nearly always be mkinit.)
compiler/compile_target_code.m:
Change how .init files are built. We now have to call mkinit -k to
scan all of the .c files to write out the correct set of INIT,
REQUIRED_INIT and REQUIRED_FINAL directives. The code here is
that used by mmc --make for creating the .init files.
compiler/make.program_target.m:
Build the .init file after building the .c files, since building
it before will no longer work.
794 lines
28 KiB
Plaintext
794 lines
28 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1996-2006 The University of Melbourne.
|
|
# This file may only be copied under the terms of the GNU General
|
|
# Public License - see the file COPYING in the Mercury distribution.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Mmake.vars - variables for building Mercury programs
|
|
|
|
# This file gives the default values for certain variables.
|
|
# The values here can be overridden by individual Mmake files.
|
|
|
|
# Ensure that commands use /bin/sh not the user's shell
|
|
SHELL = /bin/sh
|
|
|
|
ALL_EXTRA_LIBRARIES = $(TARGET_EXTRA_LIBRARIES) $(EXTRA_LIBRARIES)
|
|
EXTRA_LIB_DIRS =
|
|
EXTRA_LIBRARIES =
|
|
|
|
ifneq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
EXTRA_INT_DIRS = $(patsubst %,%/ints,$(EXTRA_LIB_DIRS))
|
|
MERCURY_EXTRA_INT_DIRS = $(EXTRA_INT_DIRS)
|
|
EXTRA_C_LIB_DIRS = \
|
|
$(patsubst %,%/lib/$(GRADESTRING),$(EXTRA_LIB_DIRS)) \
|
|
$(patsubst %,%/lib,$(EXTRA_LIB_DIRS))
|
|
EXTRA_C_INCL_DIRS = \
|
|
$(patsubst %,%/lib/$(GRADESTRING)/inc,$(EXTRA_LIB_DIRS)) \
|
|
$(patsubst %,%/inc,$(EXTRA_LIB_DIRS))
|
|
EXTRA_INIT_DIRS = $(patsubst %,%/modules,$(EXTRA_LIB_DIRS))
|
|
MERCURY_EXTRA_INIT_DIRS = $(EXTRA_INIT_DIRS)
|
|
else
|
|
# mmc handles these itself when invoked with `--make'.
|
|
EXTRA_INT_DIRS =
|
|
MERCURY_EXTRA_INT_DIRS =
|
|
EXTRA_C_LIB_DIRS =
|
|
EXTRA_C_INCL_DIRS =
|
|
EXTRA_INIT_DIRS =
|
|
MERCURY_EXTRA_INIT_DIRS =
|
|
endif
|
|
|
|
# Set the directory search path.
|
|
# (See the GNU Make manual for documentation about VPATH and GPATH.)
|
|
# We need to substitute all spaces with colons for the VPATH to work.
|
|
# Getting a space to be recognised as the first argument of the subst
|
|
# function is problematic; hence the `$(nullstring)' hack.
|
|
# As VPATH uses colon as the seperator we also need to convert all the
|
|
# directories into cygwin unix format if they are in windows format.
|
|
# XXX Note that directory names with spaces in them (e.g. under Windows)
|
|
# will cause problems for the VPATH settings below, as well as every
|
|
# occurrence of $(patsubst ...), since GNU Make does not respect quotes.
|
|
UNIX_MERCURY_EXTRA_INT_DIRS = $(foreach dir, $(MERCURY_EXTRA_INT_DIRS),\
|
|
$(shell @CYGPATHU@ "$(dir)"))
|
|
UNIX_MERC_INT_DIR = $(shell @CYGPATHU@ "$(MERC_INT_DIR)")
|
|
UNIX_MERCURY_EXTRA_INIT_DIRS = $(foreach dir, $(MERCURY_EXTRA_INIT_DIRS),\
|
|
$(shell @CYGPATHU@ "$(dir)"))
|
|
|
|
nullstring =
|
|
MMAKE_VPATH = $(subst $(nullstring) ,:,$(strip \
|
|
$(UNIX_MERCURY_EXTRA_INT_DIRS) $(UNIX_MERC_INT_DIR)\
|
|
$(UNIX_MERCURY_EXTRA_INIT_DIRS)))
|
|
VPATH = $(MMAKE_VPATH) # do not remove the `:' from this comment!!!
|
|
# the above comment works around a misfeature of
|
|
# autoconf which causes it to delete assignments to
|
|
# VPATH unless they contain a `:'
|
|
GPATH = $(VPATH)
|
|
|
|
DEFAULT_GRADE = $(MERCURY_DEFAULT_GRADE)
|
|
GRADE = $(DEFAULT_GRADE)
|
|
GRADESTRING = $(shell $(MCOGS) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS))
|
|
|
|
# This may be overridden on the command line
|
|
TARGET_ASM = no
|
|
|
|
ifeq ($(TARGET_ASM),yes)
|
|
ASM_OPT = --target asm
|
|
else
|
|
ASM_OPT =
|
|
endif
|
|
|
|
MERCURY_MAIN_MODULES =
|
|
|
|
#
|
|
# Files which should be built using `mmc --make' rather than `make'
|
|
# when `--use-mmc-make' is passed on the mmake command line.
|
|
#
|
|
ALL_MC_BUILD_FILES = $(MERCURY_MAIN_MODULES) \
|
|
$(MERCURY_MAIN_MODULES:%=%$(EXT_FOR_EXE)) \
|
|
$(MERCURY_MAIN_MODULES:%=lib%.$A) \
|
|
$(MERCURY_MAIN_MODULES:%=lib%.so) \
|
|
$(MERCURY_MAIN_MODULES:%=%.clean) \
|
|
$(MERCURY_MAIN_MODULES:%=%.realclean) \
|
|
$(MERCURY_MAIN_MODULES:%=%.depend) \
|
|
$(MERCURY_MAIN_MODULES:%=lib%.install) \
|
|
$(MC_BUILD_FILES)
|
|
MC_BUILD_FILES =
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# The following variables hold the names of various programs and
|
|
# the options which should be passed to them.
|
|
#
|
|
#-----------------------------------------------------------------------------#
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff which is not specific to any back-end
|
|
#
|
|
|
|
ALL_GRADEFLAGS = $(USUAL_GRADEFLAGS) $(ASM_OPT)
|
|
USUAL_GRADEFLAGS = $(GRADEFLAGS) $(EXTRA_GRADEFLAGS) $(TARGET_GRADEFLAGS)
|
|
GRADEFLAGS = --grade $(GRADE)
|
|
EXTRA_GRADEFLAGS =
|
|
|
|
MC = mmc
|
|
ALL_MCFLAGS = $(MCFLAGS) $(EXTRA_MCFLAGS) $(TARGET_MCFLAGS) $(LIB_MCFLAGS)
|
|
MCFLAGS =
|
|
EXTRA_MCFLAGS =
|
|
LIB_MCFLAGS = $(patsubst %,--mld %,$(EXTRA_LIB_DIRS)) \
|
|
$(patsubst %,--ml %,$(EXTRA_LIBRARIES))
|
|
|
|
# Flags for use with `mmc --make'.
|
|
# Pass the options as a Mercury.options file on stdin rather
|
|
# than on the command line. This avoids problems with quoting
|
|
# and unwanted word splitting.
|
|
ECHO_MERCURY_OPTIONS = { \
|
|
echo MCFLAGS += '$(ALL_GRADEFLAGS) $(ALL_MCFLAGS)'; \
|
|
echo MCFLAGS += '$(MC_MAKE_FLAGS) $(EXTRA_MC_MAKE_FLAGS)'; \
|
|
echo CFLAGS += '$(ALL_CFLAGS)'; \
|
|
echo JAVACFLAGS += '$(ALL_JAVACFLAGS)'; \
|
|
echo MS_CLFLAGS += '$(ALL_MS_CLFLAGS)'; \
|
|
echo MS_ILASMFLAGS += '$(ALL_MS_ILASMFLAGS)'; \
|
|
echo C2INITARGS += '$(ALL_C2INITARGS)'; \
|
|
echo MLLIBS += '$(ALL_MLLIBS)'; \
|
|
echo MLOBJS += '$(ALL_MLOBJS)'; \
|
|
echo LDFLAGS += '$(ALL_LDFLAGS)'; \
|
|
echo LD_LIBFLAGS += '$(ALL_LD_LIBFLAGS)'; \
|
|
echo EXTRA_LIBRARIES += '$(EXTRA_LIBRARIES)'; \
|
|
echo EXTRA_LIB_DIRS += '$(EXTRA_LIB_DIRS)'; \
|
|
echo LIBGRADES = '$(ALL_LIBGRADES)'; \
|
|
echo INSTALL_PREFIX = '$(INSTALL_PREFIX)'; \
|
|
echo LINKAGE = '$(LINKAGE)'; \
|
|
echo MERCURY_LINKAGE = '$(MERCURY_LINKAGE)'; \
|
|
}
|
|
|
|
MC_MAKE_FLAGS =
|
|
EXTRA_MC_MAKE_FLAGS =
|
|
|
|
MCG = $(MC) --compile-to-c
|
|
MCE = $(MC) --errorcheck-only
|
|
MCD = $(MC) --generate-dependencies
|
|
MCI = $(MC) --make-interface
|
|
MCPI = $(MC) --make-private-interface
|
|
MCSI = $(MC) --make-short-interface
|
|
MCOI = $(MC) --make-optimization-interface
|
|
MCTOI = $(MC) --make-transitive-optimization-interface
|
|
MCOGS = $(MC) --output-grade-string
|
|
MCM = $(ECHO_MERCURY_OPTIONS) | $(MC) --make --options-file -
|
|
|
|
ALL_MCIFLAGS = $(MCIFLAGS) $(EXTRA_MCIFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCPIFLAGS = $(MCPIFLAGS) $(EXTRA_MCPIFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCSIFLAGS = $(MCSIFLAGS) $(EXTRA_MCSIFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCOIFLAGS = $(MCOIFLAGS) $(EXTRA_MCOIFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCTOIFLAGS = $(MCTOIFLAGS) $(EXTRA_MCTOIFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCDFLAGS = $(MCDFLAGS) $(EXTRA_MCDFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCGFLAGS = $(MCGFLAGS) $(EXTRA_MCGFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS)
|
|
ALL_MCSFLAGS = $(MCSFLAGS) $(EXTRA_MCSFLAGS) $(TARGET_MCFLAGS) \
|
|
$(LIB_MCFLAGS) --cflags "$(ALL_CFLAGS)"
|
|
|
|
MCIFLAGS = $(MCFLAGS)
|
|
MCPIFLAGS = $(MCFLAGS)
|
|
MCSIFLAGS = $(MCFLAGS)
|
|
MCOIFLAGS = $(MCFLAGS)
|
|
MCTOIFLAGS = $(MCFLAGS)
|
|
MCDFLAGS = $(MCFLAGS)
|
|
MCGFLAGS = $(MCFLAGS)
|
|
MCSFLAGS = $(MCFLAGS)
|
|
|
|
EXTRA_MCIFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCPIFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCSIFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCOIFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCTOIFLAGS= $(EXTRA_MCFLAGS)
|
|
EXTRA_MCDFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCGFLAGS = $(EXTRA_MCFLAGS)
|
|
EXTRA_MCSFLAGS = $(EXTRA_MCFLAGS)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff which is specific to the C back-ends
|
|
#
|
|
|
|
# FIX_PATH_FOR_<foo> should be set to a script which converts path names
|
|
# from Unix/Cygwin format into a format suitable for the <foo> command.
|
|
# If <foo> is a Unix/Cygwin command that expects Unix-style path names,
|
|
# FIX_PATH_FOR_<foo> should be set to "echo".
|
|
# If <foo> is a Windows command that expects Windows-style path names,
|
|
# FIX_PATH_FOR_<foo> should be set to "cygpath -w".
|
|
FIX_PATH_FOR_CC = @FIX_PATH_FOR_CC@
|
|
|
|
MGNUC = mgnuc
|
|
ALL_MGNUCFLAGS = $(MGNUCFLAGS) $(EXTRA_MGNUCFLAGS) $(TARGET_MGNUCFLAGS) \
|
|
-- $(ALL_CFLAGS)
|
|
MGNUCFLAGS =
|
|
EXTRA_MGNUCFLAGS =
|
|
|
|
ALL_CFLAGS = $(CFLAGS) $(EXTRA_CFLAGS) $(TARGET_CFLAGS) $(LIB_CFLAGS)
|
|
CFLAGS =
|
|
EXTRA_CFLAGS =
|
|
LIB_CFLAGS = $(patsubst %,-I %,$(EXTRA_C_INCL_DIRS))
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff for the .NET back-end
|
|
#
|
|
|
|
# MS_CL is the command line version of Microsoft Visual C++, which we
|
|
# use to compile Managed C++ code in the .NET backend.
|
|
FIX_PATH_FOR_CL = @CYGPATH@
|
|
MS_CL = @MS_CL@
|
|
MS_VISUALCPP_DIR = @MS_VISUALCPP_DIR@
|
|
ALL_MS_CLFLAGS = $(MS_CLFLAGS) $(EXTRA_MS_CLFLAGS) $(TARGET_MS_CLFLAGS) \
|
|
$(LIB_MS_CLFLAGS)
|
|
MS_CLFLAGS =
|
|
EXTRA_MS_CLFLAGS =
|
|
# The $(shell ...) here is to cause make to evaluate the command substitution
|
|
# when the variable is expanded. This is necessary because the result
|
|
# will be single-quoted when passed to the shell via ECHO_MERCURY_OPTIONS
|
|
# to preserve possible double-quotes, so the command substitution won't
|
|
# be run then.
|
|
MS_VC_INCLUDE_DIR = $(shell $(FIX_PATH_FOR_CL) "$(MS_VISUALCPP_DIR)/include")
|
|
MS_VC_INCLUDES = -I"$(MS_VC_INCLUDE_DIR)"
|
|
LIB_MS_CLFLAGS = $(MS_VC_INCLUDES) $(patsubst %,-I %,$(EXTRA_C_INCL_DIRS))
|
|
|
|
# MS_CL_NOASM can be used to turn off assembly generation. Use
|
|
# MS_CL_NOASM=:noAssembly to turn it off, leave it blank to turn it on.
|
|
MS_CL_NOASM =
|
|
MS_DOTNET_SDK_DIR=@MS_DOTNET_SDK_DIR@
|
|
# The system libraries were once needed here, but are currently unnecessary.
|
|
MS_CL_LIBS =
|
|
|
|
# MERCURY_STDLIB_DIR should be set by the `mmake' script.
|
|
MERC_C_INCL_DIR = $(MERCURY_STDLIB_DIR)/inc
|
|
MERC_DLL_DIR = $(MERCURY_STDLIB_DIR)/lib/$(GRADESTRING)
|
|
|
|
# MS_ILASM is the Microsoft IL assembler, which turns IL assembly code
|
|
# into bytecode.
|
|
# XXX we should also support the Portable.NET version of ILASM,
|
|
# which has a different command-line interface.
|
|
# (Is there a Mono ILASM too? What about Rotor?)
|
|
MS_ILASM = @ILASM@
|
|
ALL_MS_ILASMFLAGS= $(MS_ILASMFLAGS) $(EXTRA_MS_ILASMFLAGS) \
|
|
$(TARGET_MS_ILASMFLAGS) $(LIB_MS_ILASMFLAGS) $(ILASM_KEYFLAG)
|
|
MS_ILASMFLAGS =
|
|
EXTRA_MS_ILASMFLAGS =
|
|
LIB_MS_ILASMFLAGS= $(patsubst %,-I %,$(EXTRA_C_INCL_DIRS))
|
|
|
|
# MS_AL is the Microsoft assembly linker, which creates assemblies.
|
|
MS_AL = @MS_AL@
|
|
|
|
# MS_CSC is the command line version of C# compiler
|
|
# XXX we should also support the Portable.NET and Mono C# compilers,
|
|
# which have a different command-line interface.
|
|
# (What about Rotor?)
|
|
|
|
FIX_PATH_FOR_CSC = @CYGPATH@
|
|
MS_CSC = @MS_CSC@
|
|
ALL_MS_CSCFLAGS = $(MS_CSCFLAGS) $(EXTRA_MS_CSCFLAGS) $(TARGET_MS_CSCFLAGS) \
|
|
$(LIB_MS_CSCFLAGS)
|
|
MS_CSCFLAGS =
|
|
EXTRA_MS_CSCFLAGS =
|
|
LIB_MS_CSCFLAGS =
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff for the Java back-end
|
|
#
|
|
|
|
# JAVAC is the command line java compiler;
|
|
# it should generate .class files from .java files.
|
|
JAVAC = @JAVAC@
|
|
ALL_JAVACFLAGS = $(JAVACFLAGS) $(EXTRA_JAVACFLAGS) $(TARGET_JAVACFLAGS) \
|
|
$(LIB_JAVACFLAGS)
|
|
JAVACFLAGS =
|
|
EXTRA_JAVACFLAGS =
|
|
# XXX Should we set LIB_JAVACFLAGS?
|
|
LIB_JAVACFLAGS =
|
|
|
|
# JAVA_INTERPRETER is the command line Java interpreter;
|
|
# it should be able to run Java bytecode files.
|
|
JAVA_INTERPRETER = @JAVA_INTERPRETER@
|
|
|
|
# JAR is the command line Java archive tool;
|
|
# it should generate .jar files.
|
|
JAR = @JAR@
|
|
JAR_CREATE_FLAGS = cf
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff related to linking (for the C and assembler back-ends).
|
|
#
|
|
|
|
C2INIT = c2init
|
|
ALL_C2INITFLAGS = $(C2INIT_AND_MLFLAGS)
|
|
C2INITFLAGS =
|
|
EXTRA_C2INITFLAGS =
|
|
LIB_C2INITFLAGS = $(patsubst %,--init-file-directory %,$(EXTRA_INIT_DIRS))
|
|
|
|
ALL_C2INITARGS = $(C2INITARGS) $(EXTRA_C2INITARGS) $(TARGET_C2INITARGS) \
|
|
$(LIB_C2INITARGS)
|
|
C2INITARGS =
|
|
EXTRA_C2INITARGS =
|
|
LIB_C2INITARGS = $(patsubst %,%.init,$(ALL_EXTRA_LIBRARIES))
|
|
|
|
# $(EXTRA_INIT_COMMAND) should expand to a command to generate extra entries
|
|
# in the `.init' file for a library. It may expand to the empty string.
|
|
EXTRA_INIT_COMMAND =
|
|
|
|
# c2init and ml take the same arguments.
|
|
C2INIT_AND_MLFLAGS = $(MLFLAGS) $(C2INITFLAGS) \
|
|
$(EXTRA_MLFLAGS) $(EXTRA_C2INITFLAGS) \
|
|
$(TARGET_MLFLAGS) $(TARGET_C2INITFLAGS) \
|
|
$(LIB_MLFLAGS) $(LIB_C2INITFLAGS)
|
|
|
|
ML = ml
|
|
ALL_MLFLAGS = $(C2INIT_AND_MLFLAGS)
|
|
MLFLAGS =
|
|
EXTRA_MLFLAGS =
|
|
LIB_MLFLAGS = $(patsubst %,-R%,$(EXTRA_C_LIB_DIRS)) \
|
|
$(patsubst %,-L%,$(EXTRA_C_LIB_DIRS))
|
|
|
|
ALL_LDFLAGS = $(LDFLAGS) $(EXTRA_LDFLAGS) $(TARGET_LDFLAGS)
|
|
LDFLAGS =
|
|
EXTRA_LDFLAGS =
|
|
|
|
# Flags to use when linking a shared library.
|
|
ALL_LD_LIBFLAGS = $(LD_LIBFLAGS) $(EXTRA_LD_LIBFLAGS) $(TARGET_LD_LIBFLAGS)
|
|
LD_LIBFLAGS =
|
|
EXTRA_LD_LIBFLAGS =
|
|
|
|
ALL_MLOBJS = $(MLOBJS) $(EXTRA_MLOBJS) $(TARGET_MLOBJS)
|
|
MLOBJS =
|
|
EXTRA_MLOBJS =
|
|
ALL_MLPICOBJS = $(ALL_MLOBJS:.o=.$(EXT_FOR_PIC_OBJECTS))
|
|
|
|
ALL_MLLIBS = $(MLLIBS) $(EXTRA_MLLIBS) $(TARGET_MLLIBS) $(LIB_MLLIBS)
|
|
# XXX ALL_MLLIBS_DEP should contain a list of the file names of the
|
|
# libraries specified in ALL_MLLIBS, but I can't see how to know whether
|
|
# they should be `.a' or `.so' libraries, so for now we leave it empty.
|
|
#ALL_MLLIBS_DEP = $(patsubst -l%,lib%.???,$(ALL_MLLIBS))
|
|
ALL_MLLIBS_DEP =
|
|
MLLIBS =
|
|
EXTRA_MLLIBS =
|
|
LIB_MLLIBS = $(patsubst %,-l%,$(ALL_EXTRA_LIBRARIES))
|
|
|
|
# Program used to create the .init file for a library.
|
|
# This is usually just mkinit invoked with the `-k' option.
|
|
MKLIBINIT = mkinit -k
|
|
|
|
# These only have an effect with `mmc --make'.
|
|
LINKAGE = shared
|
|
MERCURY_LINKAGE = @DEFAULT_LINKAGE@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# Stuff related to creating libraries
|
|
#
|
|
|
|
AR = @AR@
|
|
ALL_ARFLAGS = $(ARFLAGS) $(EXTRA_ARFLAGS) $(TARGET_ARFLAGS)
|
|
ARFLAGS = @ARFLAGS@
|
|
EXTRA_ARFLAGS =
|
|
AR_LIBFILE_OPT = @AR_LIBFILE_OPT@
|
|
|
|
RANLIB = @RANLIB@
|
|
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)
|
|
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.)
|
|
CFLAGS_FOR_PIC = @CFLAGS_FOR_PIC@
|
|
|
|
# $(GCCFLAGS_FOR_PIC) is passed to the GCC back-end when creating
|
|
# `.pic_s' files.
|
|
GCCFLAGS_FOR_PIC = -fpic
|
|
|
|
# $(EXT_FOR_PIC_OBJECTS) will be either `.o', if $(CFLAGS_FOR_PIC) is empty,
|
|
# or `.pic_o', if special flags are required for compiling files that
|
|
# will be put in shared libraries.
|
|
EXT_FOR_PIC_OBJECTS = @EXT_FOR_PIC_OBJECTS@
|
|
|
|
# $(EXT_FOR_SHARED_LIB) will be the extension for shared libraries,
|
|
# if the system supports them (e.g. `.so'), or the extension used
|
|
# for non-shared libraries (e.g. `.a') if the system doesn't support
|
|
# shared libraries.
|
|
EXT_FOR_SHARED_LIB = @EXT_FOR_SHARED_LIB@
|
|
|
|
# XXX RM_C is not used any more (it used to control whether
|
|
# the intermediate C files were removed).
|
|
# It may still be referred to by `.d' files generated before
|
|
# support for RM_C was removed from the compiler.
|
|
RM_C = :
|
|
|
|
# lists of targets that depend on $(ALL_MLOBJS) and $(ALL_MLPICOBJS)
|
|
MLOBJS_DEPS =
|
|
MLPICOBJS_DEPS =
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# `TARGET_<prog>FLAGS' is used to pass different flags to <prog> for
|
|
# different targets. By setting MCFLAGS-foo, for example, you can add
|
|
# extra values to TARGET_MCFLAGS that will used only for compiling foo.m.
|
|
#
|
|
# For each program <prog>, `TARGET_<prog>FLAGS' expands to
|
|
# `$(<prog>FLAGS-$@)' and/or `$(<prog>FLAGS-$*)'.
|
|
# $@ and $* are the builtin variables that expand to the
|
|
# current target and (for pattern rules) the base name of the current target,
|
|
# respectively. So $* is used for flags variables used by pattern rules,
|
|
# whereas $@ is used for flags variables used by hard-coded rules,
|
|
# including the ones in the generated .dep files.
|
|
#
|
|
# The code below uses some tricky GNU Make hacks to avoid expanding
|
|
# <prog>FLAGS-$* and <prog>FLAGS-$@ if these vars are not defined,
|
|
# so that we can avoid spurious warnings if the warning about
|
|
# undefined variables is enabled.
|
|
|
|
TARGET_GRADEFLAGS = \
|
|
$(maybe-base-GRADEFLAGS-$(findstring undefined,\
|
|
$(origin GRADEFLAGS-$(patsubst %_init,%,$*)))) \
|
|
$(maybe-target-GRADEFLAGS-$(findstring undefined,\
|
|
$(origin GRADEFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))))
|
|
maybe-base-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst %_init,%,$*))
|
|
maybe-base-GRADEFLAGS-undefined =
|
|
maybe-target-GRADEFLAGS- = $(GRADEFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))
|
|
maybe-target-GRADEFLAGS-undefined =
|
|
|
|
TARGET_MCFLAGS = \
|
|
$(maybe-target-MCFLAGS-$(findstring undefined,\
|
|
$(origin MCFLAGS-$(notdir $(basename $@)))))
|
|
maybe-target-MCFLAGS- = $(MCFLAGS-$(notdir $(basename $@)))
|
|
maybe-target-MCFLAGS-undefined =
|
|
|
|
TARGET_C2INITFLAGS = \
|
|
$(maybe-target-C2INITFLAGS-$(findstring undefined,\
|
|
$(origin C2INITFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))))
|
|
maybe-target-C2INITFLAGS- = $(C2INITFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))
|
|
maybe-target-C2INITFLAGS-undefined =
|
|
|
|
TARGET_C2INITARGS = \
|
|
$(maybe-base-C2INITARGS-$(findstring undefined,\
|
|
$(origin C2INITARGS-$*))) \
|
|
$(maybe-target-C2INITARGS-$(findstring undefined,\
|
|
$(origin C2INITARGS-$(patsubst $(cs_subdir)%_init.c,%,$@))))
|
|
maybe-base-C2INITARGS- = $(C2INITARGS-$*)
|
|
maybe-base-C2INITARGS-undefined =
|
|
maybe-target-C2INITARGS- = $(C2INITARGS-$(patsubst $(cs_subdir)%_init.c,%,$@))
|
|
maybe-target-C2INITARGS-undefined =
|
|
|
|
TARGET_MGNUCFLAGS = \
|
|
$(maybe-base-MGNUCFLAGS-$(findstring undefined,$(origin MGNUCFLAGS-$*)))
|
|
maybe-base-MGNUCFLAGS- = $(MGNUCFLAGS-$*)
|
|
maybe-base-MGNUCFLAGS-undefined =
|
|
|
|
TARGET_CFLAGS = \
|
|
$(maybe-base-CFLAGS-$(findstring undefined,$(origin CFLAGS-$*))) \
|
|
$(maybe-target-CFLAGS-$(findstring undefined,$(origin CFLAGS-$@)))
|
|
maybe-base-CFLAGS- = $(CFLAGS-$*)
|
|
maybe-base-CFLAGS-undefined =
|
|
maybe-target-CFLAGS- = $(CFLAGS-$@)
|
|
maybe-target-CFLAGS-undefined =
|
|
|
|
# Note we strip any trailing `_init.c' from `$@' so we get the appropriate
|
|
# "base" name, regardless of whether this variable ends up being used as
|
|
# an argument of a `c2init' rule or an `ml' rule.
|
|
TARGET_MLFLAGS = \
|
|
$(maybe-target-MLFLAGS-$(findstring undefined,\
|
|
$(origin MLFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))))
|
|
maybe-target-MLFLAGS- = $(MLFLAGS-$(patsubst $(cs_subdir)%_init.c,%,$@))
|
|
maybe-target-MLFLAGS-undefined =
|
|
|
|
TARGET_LDFLAGS = \
|
|
$(maybe-target-LDFLAGS-$(findstring undefined,$(origin LDFLAGS-$@)))
|
|
maybe-target-LDFLAGS- = $(LDFLAGS-$@)
|
|
maybe-target-LDFLAGS-undefined =
|
|
|
|
TARGET_LD_LIBFLAGS = \
|
|
$(maybe-target-LD_LIBFLAGS-$(findstring undefined,$(origin LD_LIBFLAGS-$@)))
|
|
maybe-target-LD_LIBFLAGS- = $(LD_LIBFLAGS-$@)
|
|
maybe-target-LD_LIBFLAGS-undefined =
|
|
|
|
TARGET_MLOBJS = \
|
|
$(maybe-target-MLOBJS-$(findstring undefined,$(origin MLOBJS-$@)))
|
|
maybe-target-MLOBJS- = $(MLOBJS-$@)
|
|
maybe-target-MLOBJS-undefined =
|
|
|
|
TARGET_MLLIBS = \
|
|
$(maybe-target-MLLIBS-$(findstring undefined,$(origin MLLIBS-$@)))
|
|
maybe-target-MLLIBS- = $(MLLIBS-$@)
|
|
maybe-target-MLLIBS-undefined =
|
|
|
|
TARGET_ARFLAGS = \
|
|
$(maybe-target-ARFLAGS-$(findstring undefined,$(origin ARFLAGS-$@)))
|
|
maybe-target-ARFLAGS- = $(ARFLAGS-$@)
|
|
maybe-target-ARFLAGS-undefined =
|
|
|
|
TARGET_RANLIBFLAGS = \
|
|
$(maybe-target-RANLIBFLAGS-$(findstring undefined,$(origin RANLIBFLAGS-$@)))
|
|
maybe-target-RANLIBFLAGS- = $(RANLIBFLAGS-$@)
|
|
maybe-target-RANLIBFLAGS-undefined =
|
|
|
|
# Note we strip any trailing `_init.c' from `$@' so we get the appropriate
|
|
# "base" name, regardless of whether this variable ends up being used as
|
|
# an argument of a `c2init' rule or an `ml' rule.
|
|
TARGET_EXTRA_LIBRARIES = \
|
|
$(maybe-target-EXTRA_LIBRARIES-$(findstring undefined,\
|
|
$(origin EXTRA_LIBRARIES-$(patsubst $(cs_subdir)%_init.c,%,$@))))
|
|
maybe-target-EXTRA_LIBRARIES- = \
|
|
$(EXTRA_LIBRARIES-$(patsubst $(cs_subdir)%_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 =
|
|
|
|
TARGET_MS_CLFLAGS = \
|
|
$(maybe-base-MS_CLFLAGS-$(findstring undefined,$(origin MS_CLFLAGS-$*)))
|
|
maybe-base-MS_CLFLAGS- = $(MS_CLFLAGS-$*)
|
|
maybe-base-MS_CLFLAGS-undefined =
|
|
|
|
TARGET_MS_CSCFLAGS = \
|
|
$(maybe-base-MS_CSCFLAGS-$(findstring undefined,$(origin MS_CSCFLAGS-$*)))
|
|
maybe-base-MS_CSCFLAGS- = $(MS_CSCFLAGS-$*)
|
|
maybe-base-MS_CSCFLAGS-undefined =
|
|
|
|
TARGET_MS_ILASMFLAGS = \
|
|
$(maybe-base-MS_ILASMFLAGS-$(findstring undefined,$(origin MS_ILASMFLAGS-$*)))
|
|
maybe-base-MS_ILASMFLAGS- = $(MS_ILASMFLAGS-$*)
|
|
maybe-base-MS_ILASMFLAGS-undefined =
|
|
|
|
ILASM_KEYFLAG = \
|
|
$(maybe-target-ILASM_KEYFLAG-$(findstring undefined,$(origin ILASM_KEYFLAG-$*)))
|
|
maybe-target-ILASM_KEYFLAG- = $(ILASM_KEYFLAG-$*)
|
|
maybe-target-ILASM_KEYFLAG-undefined =
|
|
|
|
TARGET_JAVACFLAGS = \
|
|
$(maybe-base-JAVACFLAGS-$(findstring undefined,$(origin JAVACFLAGS-$*)))
|
|
maybe-base-JAVACFLAGS- = $(JAVACFLAGS-$*)
|
|
maybe-base-JAVACFLAGS-undefined =
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
#
|
|
# The following variables specify the names of the subdirectories used,
|
|
# so that you can write code which works both with and without the
|
|
# `--use-subdirs' option.
|
|
#
|
|
|
|
# Extensions for which the subdirectory contains grade-dependent files
|
|
# which need to be moved away or deleted before building a library
|
|
# in another grade. There must be a $(main_module.$(ext)s) variable
|
|
# for each of these extensions.
|
|
GRADE_SUBDIR_EXTS = \
|
|
mih optdate trans_opt trans_opt_date c c_date java java_date \
|
|
class il il_date dll s s_date pic_s pic_s_date o pic_o
|
|
|
|
ifeq ($(MMAKE_USE_SUBDIRS),yes)
|
|
|
|
# If you change any of these, you may need to update
|
|
# `mercury_cleanup_install'.
|
|
|
|
SUBDIR=Mercury/
|
|
|
|
deps_subdir=$(SUBDIR)deps/
|
|
ds_subdir=$(SUBDIR)ds/
|
|
module_deps_subdir=$(SUBDIR)module_deps/
|
|
int0s_subdir=$(SUBDIR)int0s/
|
|
ints_subdir=$(SUBDIR)ints/
|
|
int2s_subdir=$(SUBDIR)int2s/
|
|
int3s_subdir=$(SUBDIR)int3s/
|
|
opts_subdir=$(SUBDIR)opts/
|
|
trans_opts_subdir=$(SUBDIR)trans_opts/
|
|
analysiss_subdir=$(SUBDIR)analysiss/
|
|
requests_subdir=$(SUBDIR)requests/
|
|
imdgs_subdir=$(SUBDIR)imdgs/
|
|
date0s_subdir=$(SUBDIR)date0s/
|
|
dates_subdir=$(SUBDIR)dates/
|
|
date3s_subdir=$(SUBDIR)date3s/
|
|
optdates_subdir=$(SUBDIR)optdates/
|
|
trans_opt_dates_subdir=$(SUBDIR)trans_opt_dates/
|
|
useds_subdir=$(SUBDIR)useds/
|
|
mihs_subdir=$(SUBDIR)mihs/
|
|
cs_subdir=$(SUBDIR)cs/
|
|
dlls_subdir=$(SUBDIR)dlls/
|
|
ss_subdir=$(SUBDIR)ss/
|
|
pic_ss_subdir=$(SUBDIR)pic_ss/
|
|
os_subdir=$(SUBDIR)os/
|
|
ils_subdir=$(SUBDIR)ils/
|
|
javas_subdir=$(SUBDIR)javas/
|
|
dirs_subdir=$(SUBDIR)dirs/
|
|
c_dates_subdir=$(SUBDIR)c_dates/
|
|
s_dates_subdir=$(SUBDIR)s_dates/
|
|
pic_s_dates_subdir=$(SUBDIR)pic_s_dates/
|
|
il_dates_subdir=$(SUBDIR)il_dates/
|
|
java_dates_subdir=$(SUBDIR)java_dates/
|
|
classes_subdir=$(SUBDIR)classs/
|
|
err_dates_subdir=$(SUBDIR)err_dates/
|
|
|
|
else
|
|
|
|
SUBDIR=
|
|
|
|
deps_subdir=
|
|
ds_subdir=
|
|
module_deps_subdir=
|
|
int0s_subdir=
|
|
ints_subdir=
|
|
int2s_subdir=
|
|
int3s_subdir=
|
|
opts_subdir=
|
|
trans_opts_subdir=
|
|
analysiss_subdir=
|
|
requests_subdir=
|
|
imdgs_subdir=
|
|
date0s_subdir=
|
|
dates_subdir=
|
|
date3s_subdir=
|
|
optdates_subdir=
|
|
trans_opt_dates_subdir=
|
|
useds_subdir=
|
|
mihs_subdir=
|
|
cs_subdir=
|
|
dlls_subdir=
|
|
ss_subdir=
|
|
pic_ss_subdir=
|
|
os_subdir=
|
|
rlos_subdir=
|
|
ils_subdir=
|
|
javas_subdir=
|
|
dirs_subdir=
|
|
c_dates_subdir=
|
|
s_dates_subdir=
|
|
pic_s_dates_subdir=
|
|
il_dates_subdir=
|
|
java_dates_subdir=
|
|
classes_subdir=
|
|
err_dates_subdir=
|
|
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# This needs to go here so that user Mmake files can add new suffixes.
|
|
|
|
.SUFFIXES: # reset sufix list to be empty
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
MAIN_TARGET =
|
|
|
|
default_target: main_target
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Specify commands for installing things.
|
|
|
|
INSTALL = cp
|
|
INSTALL_MKDIR = mkdir -p
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Specify the locations for installing things.
|
|
# These directories can all be modified independently.
|
|
# 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_JAVA_LIBRARY_DIR= $(INSTALL_PREFIX)/lib/mercury/lib/java
|
|
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_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 = @CGIDIR@
|
|
|
|
# You should not need to override anything below here
|
|
|
|
INSTALL_CONF_DIR = $(INSTALL_LIBDIR)/conf
|
|
INSTALL_RECONF_DIR = $(INSTALL_LIBDIR)/reconf
|
|
INSTALL_MODULE_DIR = $(INSTALL_LIBDIR)/modules
|
|
INSTALL_INT_DIR = $(INSTALL_LIBDIR)/ints
|
|
INSTALL_GRADE_INT_DIR = $(INSTALL_LIBDIR)/ints/$(GRADESTRING)
|
|
INSTALL_INC_DIR = $(INSTALL_LIBDIR)/inc
|
|
INSTALL_MMAKE_DIR = $(INSTALL_LIBDIR)/mmake
|
|
FULLARCH = @FULLARCH@
|
|
INSTALL_MERC_BIN_DIR = $(INSTALL_PREFIX)/bin
|
|
INSTALL_MERC_GRADELESS_LIB_DIR = $(INSTALL_LIBDIR)/lib
|
|
FINAL_INSTALL_MERC_GRADELESS_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib
|
|
INSTALL_MERC_LIB_DIR = $(INSTALL_LIBDIR)/lib/$(GRADESTRING)
|
|
INSTALL_GRADE_INC_DIR = $(INSTALL_LIBDIR)/lib/$(GRADESTRING)/inc
|
|
INSTALL_GRADE_INC_SUBDIR = $(INSTALL_GRADE_INC_DIR)/Mercury/mihs
|
|
FINAL_INSTALL_MERC_LIB_DIR = $(FINAL_INSTALL_LIBDIR)/lib/$(GRADESTRING)
|
|
|
|
ENABLE_DEEP_PROFILER = @ENABLE_DEEP_PROFILER@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Specify the compilation models to install by default.
|
|
# This list will include the default grade.
|
|
LIBGRADES = @LIBGRADES@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The command to use to make symlinks, `false' if we shouldn't use
|
|
# symlinks (e.g. because Windows executables don't understand them).
|
|
LN_S = @LN_S@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# We need to use $(empty_string) here to prevent Make from truncating
|
|
# any trailing spaces in @OBJFILE_OPT@
|
|
empty_string=
|
|
OBJFILE_OPT=@OBJFILE_OPT@$(empty_string)
|
|
|
|
EXT_FOR_EXE=@EXEEXT@
|
|
O=@OBJ_SUFFIX@
|
|
A=@LIB_SUFFIX@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# This variable contains the shell syntax to redirect the output of
|
|
# a compilation command to a file. Normally the file chosen is *.err.
|
|
# However, you can override this variable to modify that behaviour.
|
|
# Setting this variable to the empty string will cause all errors to
|
|
# go to stdout/stderr.
|
|
# Setting this variable to ">> allerrs 2>&1" will cause errors
|
|
# to be accumulated into a single file.
|
|
ERR_REDIRECT = > $(*F).err 2>&1
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# If this variable is set to no, then mmake doesn't automatically include
|
|
# the ".d" files in the current directory in the Mmakefile.
|
|
MMAKE_AUTO_INCLUDE_DS=yes
|
|
|
|
#-----------------------------------------------------------------------------#
|