mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-20 03:43:51 +00:00
... instead of building a bunch of .c files.
Our tradition of adding an "s" at the end of a suffix to mean "all of the
files with the original suffix" had a problem when we added C# as a target
language. Until then, just as "os" stood for ".o files" when it occurred
as either a mmake target, mmc --make target, or mmake variable name component.
"cs" likewise stood for ".c files", but was now also needed to mean ".cs file".
We coped by keeping "cs" meaning ".c files", and adding "csharp" as a target
name synonym to mean ".cs file".
This diff keeps that synonym, but it changes
- the name needed to refer to ".c files" from "cs" to "all_cs"
- the name needed to refer to ".o files" from "os" to "all_os"
- the name needed to refer to ".pic_o files" from "pic_os" to "all_pic_os"
- the name needed to refer to ".cs files" from "css" to "all_css"
- the name needed to refer to ".java files" from "javas" to "all_javas"
- the name needed to refer to ".opt files" from "opts" to "all_opts"
- the name needed to refer to ".trans_opt files"
from "trans_opts" to "all_trans_opts"
It would be nice if we could apply this same change to all other similar
target names and mmake variable name suffixes, such as "ints" and "int3s",
but some of those names are already in use to mean semantically different
things. All of the names above that used to have the form "<ext>s" and
now have the form "all_<ext>s" stood for all the files with extension
".<ext>" that are prerequisites for building a linked target, i.e.
an executable or a library. But the mmake variable name suffixes
".all_mihs", ".all_mhs" and ".all_int0s" each stand for something subtly
different: the names of files that *may or may not exist", but which,
if they do exist, should be deleted by a clean or realclean target.
To make this breaking change easier to handle by users, this diff does
not simply redefine the meaning of ".all_int0s". (It does change the meaning
of the "cs" target, but the fact this will happen at some time has been
announced ages ago.) Instead, it defines three new mmake var suffixes,
".mihs_to_clean", ".mhs_to_clean" and ".int0s_to_clean", which are
synonyms for ".all_mihs", ".all_mhs" and ".all_int0s" respectively,
and announces that ".all_mihs", ".all_mhs" and ".all_int0s" are being
deprecated, and will have the above change of semantics applied to them
in the future.
NEWS.md:
Announce the breaking change.
compiler/make.top_level.m:
Stop treating the target "cs" as meaning "build all the .c files
for this program".
The code of classify_target_2 has long been semidet, but only in a way
that was not apparent to the compiler. Change the code to allow the
compiler to see its semidet nature while keeping the algorithm the same,
except for the change in the paragraph above.
This includes keeping e.g. "ints" as meaning "build all the .int/.int2
files needed by this program".
compiler/write_deps_file.m:
Stop generating mmake variables with suffixes ".cs", ".os", ".pic_os",
".javas" and ".css". The mmake variables with suffixes ".all_cs",
".all_os", ".all_pic_os", ".all_javas" and ".all_css" already existed.
All had the same value as the mmake variable without the "all",
with one exception: ".cs". However, in this case, the old (and still
current) value of ".all_cs" is what the value of ".cs" *should* have been.
Simplify some code.
The following changes in compiler/*.m are only cosmetic, but they helped me
rule out possible sources of problems with incomplete versions of this diff.
compiler/file_names.m:
Add a version of a fact_table_file_name_return_dirs which does not
return directories, since most of its callers don't need that info.
compiler/make.program_target.m:
Clarify code by making variable names more descriptive,
compiler/make.file_names.m:
compiler/make.module_target.m:
Conform to the changes above,
browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
grade_lib/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
mfilterjavac/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
Rename os to all_os, cs to all_cs, css to all_css, javas to all_javas,
and opts to all_opts. (There were no occurrences of trans_opts to rename.)
Replace [s as sh command names in actions.
scripts/Mmake.vars.in:
Specify the names of mmake variables holding the names of sets of files
with a given extension directly, since for some of them, adding an "s"
at the end of the name of the extension does not generate the name
of the corresponding mmake variable anymore.
scripts/Mmake.rules:
Use the directly specified mmake variable names from Mmake.vars.in
in the rule for installing lbraries. Temporarily add some debugging
output to make suree that the updated nested mmake variable references
work as intended.
tools/bootcheck:
Specify the names of mmake targets for making all the files in a program
with a given extension directly, since adding an "s" at the end of the
name of the extension does not generate the name of the corresponding
mmake target anymore.
Print timestamps around the action of checking namespace cleanliness,
to allow the time taken by that action to be measured. (I kept track
of bootchecks as they happened while working on this diff, and found
this time to be nontrivial.)
175 lines
5.2 KiB
Makefile
175 lines
5.2 KiB
Makefile
#-----------------------------------------------------------------------------#
|
|
# vim: ts=8 sw=8 noexpandtab ft=make
|
|
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 2016 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.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
MERCURY_DIR=..
|
|
LINK_STATIC=yes
|
|
include $(MERCURY_DIR)/Mmake.common
|
|
-include ../Mmake.params
|
|
-include Mmake.grade_lib.params
|
|
|
|
# Override the default rule in `mmake --use-mmc-make' that asks `mmc' to
|
|
# create a missing optional params file.
|
|
Mmake.grade_lib.params:
|
|
|
|
# Module-specific options should go in Mercury.options so they can be found
|
|
# by `mmc --make'.
|
|
-include Mercury.options
|
|
|
|
MCFLAGS += --flags GRADE_LIB_FLAGS $(CONFIG_OVERRIDE)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Tell the C# compiler where the stdlib assembly is.
|
|
#
|
|
ifneq ("$(filter csharp%,$(GRADE))","")
|
|
CSCFLAGS=-lib:../library -r:mer_std.dll
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
ifneq ("$(filter csharp% java%,$(GRADE))","")
|
|
MLOBJS =
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The main targets are the executables of the utilities that use and test
|
|
# the grade library. The grade "library" itself is not a target, because
|
|
# it is intended to be used *only* by these utilities (and perhaps later,
|
|
# similar utilities) and by the compiler itself. The utilities use the
|
|
# modules of the library in this directory, while we intend to give
|
|
# the compiler access by copying the source files of the grade library,
|
|
# in read-only form, to the compiler directory, just the way we copy
|
|
# the modules of the mdbcomp library to the slice and deep_profiler
|
|
# directories. The source distribution will get those read-only copies
|
|
# as well. This arrangement has the advantage that the grade in which
|
|
# the compiler is compiled is independent of the grade of the utilities.
|
|
MAIN_TARGET = all
|
|
MERCURY_MAIN_MODULES = choose_grade test_grades try_all_grade_structs
|
|
# EXTRA_MCFLAGS = --trace-flag debug_solver
|
|
|
|
DEPENDS = Mercury.modules $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
|
|
DEPS = Mercury.modules $(patsubst %,%.dep,$(MERCURY_MAIN_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: GRADE_LIB_FLAGS
|
|
$(MC) $(ALL_GRADEFLAGS) $(ALL_MCFLAGS) -f *.m
|
|
|
|
.PHONY: all
|
|
all: $(MERCURY_MAIN_MODULES)
|
|
|
|
.PHONY: depend
|
|
depend: GRADE_LIB_FLAGS $(DEPENDS)
|
|
$(DEPENDS): GRADE_LIB_FLAGS
|
|
|
|
.PHONY: dep
|
|
dep: GRADE_LIB_FLAGS $(DEPS)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# We need the shenanigans with .grade_tags to avoid situations in which
|
|
# "mmake tags" in this directory does nothing even in the absence of a tags
|
|
# file in this directory, because mmake uses VPATH to find ../library/tags
|
|
# and believes it to be the tags file we are asking for.
|
|
#
|
|
# We give files in mdbcomp to mtags before the files in this directory
|
|
# because we want references to entities defined in the modules copied from the
|
|
# mdbcomp directory to this directory to go the actual, effective definitions,
|
|
# the definitions which can be changed *without* those changes going away
|
|
# on the next copy.
|
|
|
|
MTAGS = $(SCRIPTS_DIR)/mtags
|
|
|
|
tags: .grade_tags
|
|
|
|
.grade_tags: $(MTAGS) $(wildcard *.m) $(wildcard $(LIBRARY_DIR)/*.m)
|
|
$(MTAGS) *.m $(LIBRARY_DIR)/*.m
|
|
@touch .grade_tags
|
|
|
|
.PHONY: tags_file_exists
|
|
tags_file_exists:
|
|
@if test ! -f tags; \
|
|
then \
|
|
echo making tags; \
|
|
$(MTAGS) *.m $(LIBRARY_DIR)/*.m; \
|
|
touch .grade_tags; \
|
|
fi
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The documentation of the reason for this set of rules
|
|
# can be found in library/Mmakefile.
|
|
|
|
.PHONY: all_os all_cs all_css all_javas
|
|
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
all_os: \
|
|
choose_grade.all_os \
|
|
test_grades.all_os \
|
|
try_all_grade_structs.all_os
|
|
|
|
all_cs: \
|
|
choose_grade.all_cs \
|
|
test_grades.all_cs \
|
|
try_all_grade_structs.all_cs
|
|
|
|
all_css: \
|
|
choose_grade.all_css \
|
|
test_grades.all_css \
|
|
try_all_grade_structs.all_css
|
|
|
|
all_javas: \
|
|
choose_grade.all_javas \
|
|
test_grades.all_javas \
|
|
try_all_grade_structs.all_javas
|
|
|
|
else
|
|
ifneq ($(origin choose_grade.all_os),undefined)
|
|
all_os: \
|
|
$(choose_grade.all_os) \
|
|
$(test_grades.all_os) \
|
|
$(try_all_grade_structs.all_os)
|
|
|
|
all_cs: \
|
|
$(choose_grade.all_cs) \
|
|
$(test_grades.all_cs) \
|
|
$(try_all_grade_structs.all_cs)
|
|
|
|
all_css: \
|
|
$(choose_grade.all_css) \
|
|
$(test_grades.all_css) \
|
|
$(try_all_grade_structs.all_css)
|
|
|
|
all_javas: \
|
|
$(choose_grade.all_javas) \
|
|
$(test_grades.all_javas) \
|
|
$(try_all_grade_structs.all_javas)
|
|
|
|
else
|
|
all_os:
|
|
mmake depend; mmake all_os
|
|
|
|
all_cs:
|
|
mmake depend; mmake all_cs
|
|
|
|
all_css:
|
|
mmake depend; mmake all_css
|
|
|
|
all_javas:
|
|
mmake depend; mmake all_javas
|
|
endif
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
realclean_local:
|
|
rm -f Mercury.modules tags GRADE_LIB_FLAGS
|
|
|
|
#-----------------------------------------------------------------------------#
|