mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-18 10:53:40 +00:00
This reduces the size of the output of tools/bootcheck by 3700+ lines,
or about 25%.
Mmake.common.in:
Don't print the actions implementing namespace cleanliness checks.
To allow the attribution of any violations of the namespace rules,
print the name of the C module before any list of detected
nonallowed symbols.
To avoid mmake printing the actions for creating the .o files
that some of the check_namespace actions later check, rename
the affected object files .pseudo_o files, so that we can specify
a rule for them that is a copy of the rule for .o files, differing
only in not printing the compilation command.
Mark the files involved in check_namespace actions as dependencies
of .SECONDARY, which means that mmake does not automatically delete them
after building them as intermediate files. The reason for this is that
there is no way to tell make to delete intermediate files *silently*,
i.e. without writing out the rm command that deletes them.
To make up for this, tools/bootcheck now cleans up each directory
immediately after "mmake check_namespace" with "mmake clean_check",
which invokes mmake rules that do not print the rm commands.
This change does have the effect that these intermediate files *will*
hang around if the check_namespace target is every invoked manually.
However,
- we just about never run check_namespace in a directory manually, and
- when we do, a simple "mmake clean_check" will do the required cleanup.
scripts/Mmake.rules:
Move the vim tag line to its usual place at the top.
Replace old-school rules such as .m.err with their modern equivalents
(such as %.err: %.m).
scripts/Mmakefile:
Instead of printing the rules that make test_mdbrc, print only a
"making test_mdbrc" message.
runtime/Mmakefile:
Conform to the change of the name of a make variable in Mmake.common.in.
ssdb/Mmakefile:
Fix an old bug that something else in this diff tickled: make the
.depend target of each main module depend on SSDB_FLAGS, *not* just
the phony general "depend" target. This was a bug because tools/bootcheck
- copied across to stage 2 ONLY SSDB_FLAGS.in, and NOT SSDB_FLAGS,
- did NOT explicitly make SSDB_FLAGS from SSDB_FLAGS.in, even though
pretty much invocations of the Mercury compiler in this directory
have "--flags SSDB_FLAGS" as an implicit argument, and then
- built dependencies in the ssdb directory by invoking the top
Mmakefile's dep_ssdb target, which (indirectly) invokes
$(SSDB_LIB_NAME).depend.
Due to all the above, I don't actually know how tools/bootcheck
could ever build stage2/ssdb until now :-(
tools/bootcheck:
Invoke "mmake clean_check" after each "mmake check_namespace".
Change the code that explicitly builds the directory-specific
X_FLAGS file in each directory (which is invoked only when using
mmc --make) to actually build all such files, when previously
it built only a subset.
tests/invalid/Mmakefile:
tests/invalid_nodepend/Mmakefile:
tests/invalid_onlydepend/Mmakefile:
tests/invalid_options_file/Mmakefile:
tests/invalid_purity/Mmakefile:
tests/invalid_submodules/Mmakefile:
tests/stm/Mmakefile:
Fix an unintended consequence of replacing the .m.err rule in
scripts/Mmake.rules with %.err: %.m, which is that the %.err: %.m
rules in these mmakefiles became ineffective, because they appear
in the makefile we construct *after* the rule in scripts/Mmake.rules,
which specify a different action (the rules here return a nonzero
status in the *absence* of failure, which would be ridiculous
for the rule in scripts/Mmake.rules). Apparently, the %.err: %.m rules
overrode the rule in scripts/Mmake.rules while it had the old form,
but do not do so now it has the new form.
The fix is to make replace all the "%.err: %.m" rules in these Mmakefiles
with "$(PROGS:%=%.err): %.err: %.m" rules, which specify that they
override the generic rule for the .err files of the test cases
in each directory.
In invalid_purity/Mmakefile, fix a bug: -nodepend suffixes make sense
in only in the name of a *test*, not the name of a *program*, so
move such a suffix from a program name to a test name. Without this,
the program's .err file would be included in the list of .err files
to which the ".err: .m" rule applies under the wrong name.
In invalid_submodules/Mmakefile, fix the misleading names of some
make variables, and fix a misspelt directory name.
Standardize on "$(PROGS:%=%.err)" notation, replacing earlier instances
of "$(addsuffix .err,$(PROGS))". The reason for this is that when I tried
using "$addsuffix .int_err,$(PROGS))" in tests/invalid/invalid_make_int,
it did not work. (A google search on "gnu make addsuffix" did not yield
any clues as to why. Maybe you can only add suffixes that do not contain
underscores?)
262 lines
7.6 KiB
Makefile
262 lines
7.6 KiB
Makefile
#-----------------------------------------------------------------------------#
|
|
# vim: ts=8 sw=8 noexpandtab ft=make
|
|
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 2007, 2009-2010, 2012 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.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# ssdb/Mmakefile - this is the Mmakefile for building the Mercury
|
|
# ssdb library, which also includes other functionality needed
|
|
# by the source to source Mercury debugger.
|
|
|
|
# Since the code in this directory is intended to be invoked only from
|
|
# the trace library, which turns off tracing in the Mercury code it calls,
|
|
# compiling the modules in this directory with tracing on only makes
|
|
# the generated code much bigger. However, since all Mercury code
|
|
# in an executable must be of the same grade, we need to be able to
|
|
# compile the modules in this directory in debug grades as well.
|
|
|
|
# Specify which files to check for namespace cleanliness, and which name
|
|
# prefixes are allowed.
|
|
|
|
CHECK_HDRS =
|
|
CHECK_MHDRS = $(mer_ssdb.mhs)
|
|
CHECK_OBJS = $(mer_ssdb.os)
|
|
ALLOW_LIB_PREFIX=yes
|
|
ALLOW_BROWSER_PREFIX=yes
|
|
ALLOW_MDBCOMP_PREFIX=yes
|
|
ALLOW_SSDB_PREFIX=yes
|
|
|
|
MERCURY_DIR=..
|
|
LINK_STDLIB_ONLY=yes
|
|
include $(MERCURY_DIR)/Mmake.common
|
|
-include Mmake.ssdb.params
|
|
|
|
# Override the default rule in `mmake --use-mmc-make' that asks `mmc' to
|
|
# create a missing optional params file.
|
|
Mmake.ssdb.params:
|
|
|
|
# Module-specific options should go in Mercury.options so they
|
|
# can be found by `mmc --make'.
|
|
include Mercury.options
|
|
|
|
MAIN_TARGET=main
|
|
|
|
MERCURY_MAIN_LIB_MODULES=$(SSDB_LIB_NAME)
|
|
MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES)
|
|
|
|
VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(BROWSER_DIR)
|
|
|
|
DEPENDS = $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
|
|
INTS_TARGETS = $(patsubst %,%.ints,$(MERCURY_MAIN_MODULES))
|
|
INT3S_TARGETS = $(patsubst %,%.int3s,$(MERCURY_MAIN_MODULES))
|
|
LIBS = $(patsubst %,lib%,$(MERCURY_MAIN_LIB_MODULES))
|
|
CHECKS = $(patsubst %,%.check,$(MERCURY_MAIN_LIB_MODULES))
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Specify which compilers to use to compile the library.
|
|
# Don't change these without good reason - if you want to do a temporary
|
|
# change, change ../Mmake.params, or create Mmake.ssdb.params.
|
|
|
|
CFLAGS += $(DLL_CFLAGS)
|
|
ifeq ($(INSTALLABLE_PREFIX),yes)
|
|
MLFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
|
|
-R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
|
|
MCFLAGS += -R$(FINAL_INSTALL_MERC_LIB_DIR) \
|
|
-R$(FINAL_INSTALL_MERC_GC_LIB_DIR)
|
|
endif
|
|
ifeq ("$(filter csharp% java%,$(GRADE))","")
|
|
MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
|
|
$(READLINE_LIBRARIES)
|
|
endif
|
|
|
|
MCFLAGS += --flags SSDB_FLAGS $(CONFIG_OVERRIDE)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Set the install name for Darwin shared libraries. We disable the
|
|
# --shlib-linker-use-install-name mmc option so that the -install_name linker
|
|
# option is not passed in the .dep files. We do this to avoid a problem when
|
|
# building from the C source distribution: if the C source distribution is
|
|
# generated on a non-Darwin system then the -install_name option is not passed
|
|
# in the .dep files, so it must be passed here, however if a C source
|
|
# distribution is generated on a Darwin system then by default the
|
|
# -install_name option will be passed in the .dep files which will cause it to
|
|
# be passed twice (here and in the .dep files) which is not allowed by the
|
|
# linker, so we disable the mmc option which causes the -install_name option
|
|
# to be passed in the .dep files.
|
|
|
|
ifeq "$(findstring apple-darwin,$(FULLARCH))" "apple-darwin"
|
|
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
MCFLAGS += --ld-libflags \
|
|
"-install_name $(FINAL_INSTALL_MERC_LIB_DIR)/lib$(SSDB_LIB_NAME).dylib"
|
|
else
|
|
LD_LIBFLAGS-libmer_ssdb.dylib = -install_name \
|
|
$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(SSDB_LIB_NAME).dylib
|
|
endif
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
MTAGS = $(SCRIPTS_DIR)/mtags
|
|
|
|
LN = ln
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The C# and Java implementations of the standard library are not yet
|
|
# complete, so we need to pass `--allow-stubs' to get them to compile.
|
|
# Since the standard library is compiled with `--halt-at-warn',
|
|
# we also need `--no-warn-stubs'.
|
|
ifneq ("$(filter csharp% java%,$(GRADE))","")
|
|
MCFLAGS += --allow-stubs --no-warn-stubs
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Stuff for Windows DLLS using gnu-win32
|
|
|
|
ifeq ($(USE_DLLS),yes)
|
|
|
|
# XXX what do we need here for MDBCOMP_LIB_NAME?
|
|
DLL_CFLAGS = -Dlib$(SSDB_LIB_NAME)_DEFINE_DLL
|
|
|
|
include $(MERCURY_DIR)/Makefile.DLLs
|
|
|
|
else
|
|
|
|
DLL_CFLAGS =
|
|
DLL_DEF_LIB =
|
|
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# targets
|
|
|
|
.PHONY: main
|
|
main: library $(TAGS_FILE_EXISTS)
|
|
|
|
.PHONY: all
|
|
all: library $(TAGS_FILE_EXISTS) browse_test declarative_test
|
|
|
|
.PHONY: library
|
|
library: $(LIBS)
|
|
|
|
.PHONY: depend
|
|
depend: $(DEPENDS)
|
|
$(DEPENDS): SSDB_FLAGS Mercury.modules
|
|
|
|
# This directory contains source files for which the module
|
|
# name doesn't match the file name, so smart recompilation
|
|
# won't work without the Mercury.modules file.
|
|
Mercury.modules: SSDB_FLAGS
|
|
$(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) -f *.m
|
|
|
|
.PHONY: check
|
|
check: $(CHECKS)
|
|
|
|
.PHONY: all-ints
|
|
all-ints: ints int3s
|
|
|
|
.PHONY: ints
|
|
ints: $(INTS_TARGETS)
|
|
|
|
.PHONY: int3s
|
|
int3s: $(INT3S_TARGETS)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
tags: .ssdb_tags
|
|
|
|
.ssdb_tags: $(MTAGS) $($(SSDB_LIB_NAME).ms) \
|
|
$(wildcard $(MDBCOMP_DIR)/*.m) $(wildcard $(LIBRARY_DIR)/*.m)
|
|
$(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m
|
|
@touch .ssdb_tags
|
|
|
|
.PHONY: tags_file_exists
|
|
tags_file_exists:
|
|
@if test ! -f tags; then echo making tags; \
|
|
$(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m; \
|
|
touch .ssdb_tags; \
|
|
fi
|
|
|
|
$(SSDB_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
|
|
$($(SSDB_LIB_NAME).ms)
|
|
awk -f $(COMPILER_DIR)/source_stats.awk \
|
|
`vpath_find $($(SSDB_LIB_NAME).ms)` > $@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: dates
|
|
dates:
|
|
touch $($(SSDB_LIB_NAME).dates)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The documentation of the reason for this set of rules
|
|
# can be found in library/Mmakefile.
|
|
|
|
.PHONY: os cs css javas
|
|
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
os: $(SSDB_LIB_NAME).os
|
|
cs: $(SSDB_LIB_NAME).cs
|
|
css: $(SSDB_LIB_NAME).css
|
|
javas: $(SSDB_LIB_NAME).javas
|
|
else
|
|
ifneq ($(origin $(SSDB_LIB_NAME).os),undefined)
|
|
os: $($(SSDB_LIB_NAME).os)
|
|
cs: $($(SSDB_LIB_NAME).cs)
|
|
css: $($(SSDB_LIB_NAME).css)
|
|
javas: $($(SSDB_LIB_NAME).javas)
|
|
else
|
|
os:
|
|
mmake depend; mmake os
|
|
|
|
cs:
|
|
mmake depend; mmake cs
|
|
|
|
css:
|
|
mmake depend; mmake css
|
|
|
|
javas:
|
|
mmake depend; mmake javas
|
|
endif
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Ensure we recompile mdb__version if VERSION is changed.
|
|
$(os_subdir)mdb.o \
|
|
$(os_subdir)mdb.pic_o \
|
|
: $(RUNTIME_DIR)/mercury_conf.h
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
realclean_local:
|
|
rm -f Mercury.modules tags SSDB_FLAGS SSDB_FLAGS.date
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Installation targets
|
|
|
|
.PHONY: install
|
|
install: install_library
|
|
|
|
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
|
|
.PHONY: install_library
|
|
install_library: lib$(SSDB_LIB_NAME).install
|
|
|
|
else
|
|
|
|
.PHONY: install_library
|
|
install_library: \
|
|
lib$(SSDB_LIB_NAME).install_library \
|
|
lib$(SSDB_LIB_NAME).install_ints \
|
|
lib$(SSDB_LIB_NAME).install_hdrs
|
|
|
|
endif
|