Include Mmake.params and Mmake.workspace next to each other.

Mmake.common.in:
    Before this diff, there were a whole bunch of definitions between
    the inclusion of Mmake.workspace and the inclusion of Mmake.params.
    Move all those definitions elsewhere. Specifically, move the definitions
    whose right hand sides are autoconfigured values, and which are NOT
    also set by Mmake.workspace, to before both inclusions, moving related
    non-autoconfigure variable definitions with them, while moving
    other definitions to after both inclusions.

    Document the cause of the "phasing problem" that kept the inclusion
    of Mmake.params after the inclusion of Mmake.workspace (the definition
    of MC), and a possible solution.

tools/stdlines_for_sh:
    Add a version of stdlines for sh scripts.
This commit is contained in:
Zoltan Somogyi
2025-08-12 06:58:44 +02:00
parent 33e3a3bf7b
commit 0638d7769b
2 changed files with 140 additions and 70 deletions

View File

@@ -1,11 +1,11 @@
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
# Copyright (C) 1995-2006, 2009-2012 The University of Melbourne.
# Copyright (C) 2013-2014, 2016-2017, 2019-2020, 2022-2025 The Mercury team.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
# Mmake.common - this is the part of the makefiles for building the Mercury
# implementation that is shared between all the subdirectories. It also
@@ -17,21 +17,28 @@
# definitions here, so if you want to change one of the values here
# it is best to just add a definition to Mmake.params.
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
include $(MERCURY_DIR)/VERSION
# The rpath for the libraries needs to be set to the final installation
# directory, not $(MERCURY_DIR)/runtime etc.
SET_RPATH=no
#---------------------------------------------------------------------------#
#
# Make variables whose values are set *only* by the configure script.
#
# Note that the Make variable MC, whose values are set by the configure script
# and *also* by Mmake.workspace, has its definition after the inclusion
# of Mmake.workspace, in order to maintain the traditional ordering.
#
# XXX It would be nice if the definitions of related variables
# in this section were next to each other.
#
# This affects the tools set in Mmake.workspace so must be set first.
#---------------------#
# This affects the tools set in Mmake.workspace, so must be set first.
CROSS_COMPILING=@CROSS_COMPILING@
WORKSPACE=$(MERCURY_DIR)
include $(MERCURY_DIR)/Mmake.workspace
#-----------------------------------------------------------------------------#
#---------------------#
# The host triplet is used to configure libatomic_ops.
FULLARCH=@FULLARCH@
@@ -42,14 +49,13 @@ FULLARCH=@FULLARCH@
# upstream.
HOSTCC=@BUILD_C_PROGS_FOR_BUILD_SYSTEM@
#-----------------------------------------------------------------------------#
# Specify the Mercury compiler to use for bootstrapping.
MC = @BOOTSTRAP_MC_COMPILER@
#---------------------#
# Specify the compilation model to use for compiling the compiler.
GRADE = @GRADE@
#---------------------#
# Specify EXT_FOR_EXE is `.exe' on MS-Windows and empty elsewhere.
EXT_FOR_EXE = @EXT_FOR_EXE@
@@ -151,8 +157,6 @@ FINAL_INSTALL_PREFIX = @prefix@
INSTALLABLE_PREFIX = @INSTALLABLE_PREFIX@
#-----------------------------------------------------------------------------#
INSTALL_MERC_GC_LIB_DIR = $(INSTALL_MERC_GRADELESS_LIB_DIR)
FINAL_INSTALL_MERC_GC_LIB_DIR = $(FINAL_INSTALL_MERC_GRADELESS_LIB_DIR)
@@ -192,48 +196,7 @@ BOEHM_NEED_ATOMIC_OPS_ASM = @BOEHM_NEED_ATOMIC_OPS_ASM@
# (This is only relevant when using MSVC.)
BOEHM_WINDOWS_CPU_TYPE = @BOEHM_WINDOWS_CPU_TYPE@
# Do we want to deal with intermodule information when building the library?
# By default yes, since this way we note immediately when intermodule
# optimization breaks, and always at installation time, since we must install
# the library's .opt and .trans_opt files as well. However, during development
# some problems are easier to track down without intermodule optimization
# complicating things.
# Some test cases assume that the library is compiled intermodule optimization,
# so it is not a good idea to disable it in a bootcheck.
LIBRARY_INTERMODULE = yes
# Do we want to compile the library with --trace minimum?
# By default yes, since the library is pretty well debugged. However,
# when it is being modified, it may have bugs we may want to chase down,
# so we allow the user to override this by setting LIBRARY_TRACE_MINIMUM to no.
# However, the test cases assume that the library is compiled with --trace
# minimum, so if you do that, expect test case failures in the debugger
# directory.
LIBRARY_TRACE_MINIMUM = yes
# Enable building of the deep profiler?
# The value of ENABLE_DEEP_PROFILER is either yes or no.
ENABLE_DEEP_PROFILER=@ENABLE_DEEP_PROFILER@
# Making the tags file for a directory containing Mercury source files
# requires giving mmake access to the list of source files in the directory.
# We normally do this by having the programs' and/or libraries .dv files
# define make variables such as "mer_std.ms".
#
# Mmc --make does not create .dv files, so these make variable don't get
# defined. The resulting invocation of mtags with an empty argument list
# (the default value of an undefined make variable) would yield an error.
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
TAGS_FILE_EXISTS =
else
ifdef ALWAYS_MMAKE_TAGS_FILE
TAGS_FILE_EXISTS = tags_file_exists
else
TAGS_FILE_EXISTS =
endif
endif
#-----------------------------------------------------------------------------#
#---------------------#
INSTALL_INFO=@INSTALL_INFO@
INFO=@INFO@
@@ -245,12 +208,12 @@ LYNX=@LYNX@
PERL=@PERL@
NM=@NM@
#-----------------------------------------------------------------------------#
#---------------------#
# Should we install batch files (and other Windows specific files)?
INSTALL_WINDOWS_SCRIPTS=@INSTALL_WINDOWS_SCRIPTS@
#-----------------------------------------------------------------------------#
#---------------------#
# The linker option to use to link in the math library, if any.
# Typically `-lm'.
@@ -283,7 +246,85 @@ USING_MICROSOFT_CL_COMPILER=@USING_MICROSOFT_CL_COMPILER@
# Is getopt() available?
HAVE_GETOPT=@HAVE_GETOPT@
#-----------------------------------------------------------------------------#
# Enable building of the deep profiler?
# The value of ENABLE_DEEP_PROFILER is either yes or no.
ENABLE_DEEP_PROFILER=@ENABLE_DEEP_PROFILER@
#---------------------------------------------------------------------------#
#
# The inclusion of Mmake.workspace.
#
# We should swap the sections that include Mmake.workspace and Mmake.params,
# as this should allow the instructions in README.java.md and README.CSharp.md
# to be simplified.
#
# The rpath for the libraries needs to be set to the final installation
# directory, not $(MERCURY_DIR)/runtime etc.
SET_RPATH=no
WORKSPACE=$(MERCURY_DIR)
include $(MERCURY_DIR)/Mmake.workspace
#---------------------------------------------------------------------------#
#
# The inclusion of Mmake.params.
#
# We define LIBRARY_INTERMODULE and LIBRARY_TRACE_MINIMUM here explicitly
# because we expect that sometimes, Mmake.params will override the
# default values we set here.
#
# Do we want to deal with intermodule information when building the library?
# By default yes, since this way we note immediately when intermodule
# optimization breaks, and always at installation time, since we must install
# the library's .opt and .trans_opt files as well. However, during development
# some problems are easier to track down without intermodule optimization
# complicating things.
# Some test cases assume that the library is compiled intermodule optimization,
# so it is not a good idea to disable it in a bootcheck.
LIBRARY_INTERMODULE = yes
# Do we want to compile the library with --trace minimum?
# By default yes, since the library is pretty well debugged. However,
# when it is being modified, it may have bugs we may want to chase down,
# so we allow the user to override this by setting LIBRARY_TRACE_MINIMUM to no.
# However, the test cases assume that the library is compiled with --trace
# minimum, so if you do that, expect test case failures in the debugger
# directory.
LIBRARY_TRACE_MINIMUM = yes
# The Mmake.params file can be used to override definitions in this file
-include $(MERCURY_DIR)/Mmake.params
# Avoid trying to make this file with `mmc --make' if it doesn't exist.
$(MERCURY_DIR)/Mmake.params: ;
#---------------------------------------------------------------------------#
#
# While we set MC here, Mmake.workspace also sets it above,
# to point to $(SCRIPTS_DIR)/mmc.
#
# We want to ensure that
#
# - the definition here is active when compiling stage 1, while
#
# - the definition in Mmake.workspace is active in mmakefiles
# that include Mmake.workspace but do NOT include this file.
#
# XXX We should have a definition BOOTSTRAP_MC=@BOOTSTRAP_MC_COMPILER@
# before the inclusions of Mmake.workspace/Mmake.params, and then
# MC = $(BOOTSTRAP_MC) after them. Likewise, Mmake.workspace should have
# a definition WORKSPACE_MC=$(SCRIPTS_DIR)/mmc, followed by MC=$(WORKSPACE_MC).
# This would give us names (handles) on the two possible definitions of MC,
# both for us developers when talking about them, and for Mmakefiles
# that include either Mmake.workspace, or this file, or both.
# Specify the Mercury compiler to use for bootstrapping.
MC = @BOOTSTRAP_MC_COMPILER@
#---------------------------------------------------------------------------#
# Module-specific options should go in Mercury.options,
# so they can be found by `mmc --make'.
@@ -294,13 +335,27 @@ $(MERCURY_DIR)/Mercury.options:
touch $(MERCURY_DIR)/Mercury.options; \
fi
# The Mmake.params file can be used to override definitions in this file
-include $(MERCURY_DIR)/Mmake.params
#---------------------------------------------------------------------------#
# Avoid trying to make this file with `mmc --make' if it doesn't exist.
$(MERCURY_DIR)/Mmake.params: ;
# Making the tags file for a directory containing Mercury source files
# requires giving mmake access to the list of source files in the directory.
# We normally do this by having the programs' and/or libraries .dv files
# define make variables such as "mer_std.ms".
#
# Mmc --make does not create .dv files, so these make variable don't get
# defined. The resulting invocation of mtags with an empty argument list
# (the default value of an undefined make variable) would yield an error.
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
TAGS_FILE_EXISTS =
else
ifdef ALWAYS_MMAKE_TAGS_FILE
TAGS_FILE_EXISTS = tags_file_exists
else
TAGS_FILE_EXISTS =
endif
endif
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
#
# `mmake check_namespace' performs various checks on the header files
# and object files to make sure that they conform with our coding standards.
@@ -546,11 +601,11 @@ clean_check:
endif
# The endif is for "ifdef CHECK_OBJS" a long way above.
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#
%_FLAGS: %_FLAGS.in ../config.status
@if test -f $*_FLAGS; then chmod u+w $*_FLAGS; fi
@../config.status --file $*_FLAGS
@chmod a-w $*_FLAGS
#-----------------------------------------------------------------------------#
#---------------------------------------------------------------------------#

15
tools/stdlines_for_sh Executable file
View File

@@ -0,0 +1,15 @@
#!/bin/sh
# vim: ts=4 sw=4 wm=0
# Ensure that all divider lines (lines that match the regular expression #--*#)
# in shell scripts are of two standard lengths, one short, one long.
# The long lines are intended to separate major sections of a file, while
# the short ones separate just the different parts of a section.
for f in "$@"
do
echo "${f}"
tmpf="${f}.tmp"
sed -e '/^#------------------------*#$/s//#===========================================================================#/' -e '/^#--*#$/s//#---------------------#/' < "${f}" > "${tmpf}"
sed -e 's/#===========================================================================#/#---------------------------------------------------------------------------#/' < "${tmpf}" > "${f}"
/bin/rm ${tmpf}
done