Files
mercury/mfilterjavac/Mmakefile
Zoltan Somogyi b8b845a568 Fix mmakefile rules for os,cs,css,javas.
The main objective of this change is to get bootchecks in the csharp
and java grades to actually build the slice, profiler, deep_profiler
and mfilterjavac directories, which (due to the bug this diff fixes)
they weren't doing before.

However, since one side effect of this change is to eliminate
one source of annoying warnings from mmake about references to undefined
variables, a subsidiary objective is to eliminate other sources of such
warnings as well, which mostly come from the rules for making tags files.

browser/Mmakefile:
deep_profiler/Mmakefile:
library/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
    When creating stage 3, the bootcheck builds, in each directory,
    only the files that it wants to compare against their stage 2 versions.
    This means that it wants to build all the .c, .cs or .java files,
    which it does via the cs, css and javas mmake targets.

    The correct definitions of the rules of these targets depends on
    whether mmc --make is being used or not, so we need at least two
    sets of definitions: one for mmc --make, and for no mmc --make,
    and conditionally selecting the appropriate one. The latter definition
    has the problem that it refers to mmake variables that are intended
    to be defined in .dv files created by mmc --generate-dependencies,
    but until that has been run, those mmake variables are undefined.

    Until now, the only directories that had both the mmc --make
    and the no mmc --make definitions were the ones needed to build
    the compiler. Bootchecks in the csharp and java grades, which
    always use --make make, got errors when they tried to build
    the directories that bootcheck builds after the compiler:
    the slice, profiler, deep_prof and mfilterjavac directories.

    This diff ensures that all directories we build in bootcheck
    get all both versions of the os, cs, css, and javas targets.
    In fact, they get two subversions of the no mmc --make version:
    one for use in the presence of .dv files, and one for use in their
    absence. The latter just builds the .dv files and invokes mmake
    again. This avoids one source of warnings about undefined mmake
    variables.

    To avoid another source, make the rules for tags files and their
    proxies depends on *.m instead of mmake variables such as $(mcov.ms),
    since this makes sense even before making dependencies. The only price
    is that any untracked Mercury source files in the directory have to
    either be given some other suffix, or moved somewhere else.

    Where relevant, make the mtags invocation prefer the master versions
    of files that are copied from the mdbcomp directory to other directories,
    since this is the only writeable version.

    Make the os and cs rules consistently NOT build the _init.[co] files.
    The way we use those files in bootcheck, we never need them;
    when we need them, the right target to give is the executable anyway.

    In the slice directory, don't put mcov between mtc_union and mtc_diff.

    Eliminate unnecessary duplication, e.g. of sources in rules.

    Eliminate double negatives in conditionals.

    Fix formatting.

Mmake.common.in:
bindist/Mmakefile:
bytecode/Mmakefile:
compiler/Mmakefile:
doc/Mmakefile:
grade_lib/Mmakefile:
robdd/Mmakefile:
samples/Mmakefile:
scripts/Mmakefile:
tools/Mmakefile:
trace/Mmakefile:
util/Mmakefile:
    Add "ft=make" to vim modelines. This is redundant for the files whose
    names is Mmakefile, but it is needed for Mmake.common.
2020-04-11 20:10:38 +10:00

183 lines
5.0 KiB
Makefile

#-----------------------------------------------------------------------------#
# vim: ts=8 sw=8 noexpandtab ft=make
#-----------------------------------------------------------------------------#
# Copyright (C) 2013 The University of Melbourne.
# This file may only be copied under the terms of the GNU General
# Public Licence - see the file COPYING in the Mercury distribution.
#-----------------------------------------------------------------------------#
# This is the Mmakefile for building the mfilterjavac tool.
MERCURY_DIR=..
LINK_STATIC=yes
include $(MERCURY_DIR)/Mmake.common
#----------------------------------------------------------------------------#
-include Mmake.mfilterjavac.params
# Override the default rule in `mmake --use-mmc-make' that asks `mmc' to
# create a missing optional params file.
Mmake.mfilterjavac.params:
# Module-specific options should go in Mercury.options so they can be found
# by `mmc --make'. But this hasn't been used in this directory so far,
# so it is commented out.
# include Mercury.options
MAIN_TARGET = all
ALL_MODULES = mfilterjavac
MAIN_TARGET=all
MERCURY_MAIN_MODULES=$(ALL_MODULES)
DEPEND=$(patsubst %,%.depend,$(ALL_MODULES))
PDBS=$(patsubst %,%.pdb,$(ALL_MODULES))
VPATH = $(LIBRARY_DIR) $(SSDB_DIR)
#-----------------------------------------------------------------------------#
MLFLAGS += --shared
MCFLAGS += --flags MFILTERJAVAC_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% erlang%,$(GRADE))","")
MLOBJS =
endif
#-----------------------------------------------------------------------------#
.PHONY: nothing
nothing:
.PHONY: depend
depend: $(DEPEND)
$(DEPEND): MFILTERJAVAC_FLAGS
.PHONY: all
all: $(ALL_MODULES) $(TAGS_FILE_EXISTS)
#-----------------------------------------------------------------------------#
# Add some additional dependencies, so that Mmake knows to remake the
# profiler if one of the libraries changes.
ifeq ("$(filter csharp% java% erlang%,$(GRADE))","")
mfilterjavac: \
$(RUNTIME_DIR)/lib$(RT_LIB_NAME).$A \
$(LIBRARY_DIR)/lib$(STD_LIB_NAME).$A
endif
$(cs_subdir)mfilterjavac.c: $(UTIL_DIR)/mkinit$(EXT_FOR_EXE)
#-----------------------------------------------------------------------------#
.PHONY: check
check: DEPEND=$(patsubst %,%.check,$(ALL_MODULES))
.PHONY: ints
ints: DEPEND=$(patsubst %,%.ints,$(ALL_MODULES))
#-----------------------------------------------------------------------------#
# We need the shenanigans with .mfilterjavac_tags to avoid situations in
# which an "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.
.PHONY: tags
tags: .mfilterjavac_tags
.mfilterjavac_tags: $(MTAGS) $(wildcard *.m) $(wildcard $(LIBRARY_DIR)/*.m)
$(MTAGS) *.m $(LIBRARY_DIR)/*.m
@touch .mfilterjavac_tags
.PHONY: tags_file_exists
tags_file_exists:
@if test ! -f tags; \
then \
echo making tags; \
$(MTAGS) *.m $(LIBRARY_DIR)/*.m; \
touch .mfilterjavac_tags; \
fi
#-----------------------------------------------------------------------------#
.PHONY: dates
dates:
touch $(mfilterjavac.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: mfilterjavac.os
cs: mfilterjavac.cs
css: mfilterjavac.css
javas: mfilterjavac.javas
else
ifneq ($(origin mfilterjavac.os),undefined)
os: $(mfilterjavac.os)
cs: $(mfilterjavac.cs)
css: $(mfilterjavac.css)
javas: $(mfilterjavac.javas)
else
os:
mmake depend; mmake os
cs:
mmake depend; mmake cs
css:
mmake depend; mmake css
javas:
mmake depend; mmake javas
endif
endif
#-----------------------------------------------------------------------------#
realclean_local:
rm -f .mfilterjavac_tags tags \
MFILTERJAVAC_FLAGS MFILTERJAVAC_FLAGS.date $(PDBS) vc*.pdb
#-----------------------------------------------------------------------------#
# Installation target.
# See the comment above the 'install_compiler' target in compiler/Mmakefile
# for the reasons why we handle the java grade specially here.
#
ifeq ($(findstring java,$(GRADE)),java)
INSTALL_PROGRAM=mfilterjavac.jar
else
INSTALL_PROGRAM=mfilterjavac$(EXT_FOR_EXE)
endif
install: mfilterjavac
-[ -d $(INSTALL_MERC_BIN_DIR) ] || mkdir -p $(INSTALL_MERC_BIN_DIR)
cp `vpath_find $(INSTALL_PROGRAM)` $(INSTALL_MERC_BIN_DIR)/$(INSTALL_PROGRAM)
#-----------------------------------------------------------------------------#
.PHONY: uninstall
uninstall:
-rm -f $(INSTALL_MERC_BIN_DIR)/$(INSTALL_PROGRAM)
#-----------------------------------------------------------------------------#