mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-15 01:13:30 +00:00
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.
302 lines
9.1 KiB
Makefile
302 lines
9.1 KiB
Makefile
#-----------------------------------------------------------------------------#
|
|
# vim: ts=8 sw=8 noexpandtab ft=make
|
|
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1998-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.
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# browser/Mmakefile - this is the Mmakefile for building the Mercury
|
|
# browser library, which also includes other functionality needed
|
|
# by Mercury debuggers.
|
|
|
|
# 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_browser.mhs)
|
|
CHECK_OBJS = $(mer_browser.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.browser.params
|
|
|
|
# Override the default rule in `mmake --use-mmc-make' that asks `mmc'
|
|
# to create a missing optional params file.
|
|
Mmake.browser.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=$(BROWSER_LIB_NAME)
|
|
MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES) browse_test declarative_test
|
|
|
|
VPATH = $(LIBRARY_DIR) $(MDBCOMP_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.browser.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% erlang%,$(GRADE))","")
|
|
MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
|
|
$(READLINE_LIBRARIES)
|
|
endif
|
|
|
|
MCFLAGS += --flags MDB_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$(BROWSER_LIB_NAME).dylib"
|
|
else
|
|
LD_LIBFLAGS-libmer_browser.dylib = -install_name \
|
|
$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(BROWSER_LIB_NAME).dylib
|
|
endif
|
|
endif
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
MTAGS = $(SCRIPTS_DIR)/mtags
|
|
|
|
LN = ln
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The C#, Java, Erlang 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% erlang%,$(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$(BROWSER_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)
|
|
|
|
.PHONY: library
|
|
|
|
library: $(LIBS)
|
|
|
|
.PHONY: depend
|
|
depend: MDB_FLAGS $(DEPENDS)
|
|
$(DEPENDS): Mercury.modules
|
|
|
|
# XXX To prevent bitrot, aux should list the auxiliary programs
|
|
# that are needed only during development, and not by ordinary users.
|
|
# However, we noticed this fact too late: fatal bit rot has already occurred.
|
|
# The browse_test program requires access to the mdbcomp package, whose
|
|
# modules are now in another directory, and the declarative_test program
|
|
# requires updates to its own source code.
|
|
# aux: browse_test declarative_test
|
|
.PHONY: aux
|
|
aux:
|
|
|
|
.PHONY: depend_aux
|
|
depend_aux: browse_test.depend declarative_test.depend
|
|
|
|
# This directory contains source files for which the module name
|
|
# does not match the file name, so smart recompilation won't work
|
|
# without the Mercury.modules file.
|
|
# XXX this .PHONY directive is required when building the source
|
|
# distribution -- why?
|
|
.PHONY: Mercury.modules
|
|
Mercury.modules: MDB_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)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# We need the shenanigans with .browser_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.
|
|
|
|
tags: .browser_tags
|
|
|
|
.browser_tags: $(MTAGS) $(wildcard *.m) \
|
|
$(wildcard $(MDBCOMP_DIR)/*.m) \
|
|
$(wildcard $(LIBRARY_DIR)/*.m)
|
|
$(MTAGS) $(MDBCOMP_DIR)/*.m *.m $(LIBRARY_DIR)/*.m
|
|
@touch .browser_tags
|
|
|
|
.PHONY: tags_file_exists
|
|
tags_file_exists:
|
|
@if test ! -f tags; \
|
|
then \
|
|
echo making tags; \
|
|
$(MTAGS) $(MDBCOMP_DIR)/*.m *.m $(LIBRARY_DIR)/*.m; \
|
|
touch .browser_tags; \
|
|
fi
|
|
|
|
$(BROWSER_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
|
|
$($(BROWSER_LIB_NAME).ms)
|
|
awk -f $(COMPILER_DIR)/source_stats.awk \
|
|
`vpath_find $($(BROWSER_LIB_NAME).ms)` > $@
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: dates
|
|
dates:
|
|
touch $($(BROWSER_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: $(BROWSER_LIB_NAME).os
|
|
cs: $(BROWSER_LIB_NAME).cs
|
|
css: $(BROWSER_LIB_NAME).css
|
|
javas: $(BROWSER_LIB_NAME).javas
|
|
else
|
|
ifneq ($(origin $(BROWSER_LIB_NAME).os),undefined)
|
|
os: $($(BROWSER_LIB_NAME).os)
|
|
cs: $($(BROWSER_LIB_NAME).cs)
|
|
css: $($(BROWSER_LIB_NAME).css)
|
|
javas: $($(BROWSER_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 MDB_FLAGS MDB_FLAGS.date
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# Installation targets
|
|
|
|
.PHONY: install
|
|
install: install_library
|
|
|
|
ifneq ("$(filter erlang%,$(GRADE))","")
|
|
|
|
# there is no browser in the .NET or Erlang backends
|
|
|
|
.PHONY: install_library
|
|
install_library:
|
|
|
|
else
|
|
ifeq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
|
|
.PHONY: install_library
|
|
install_library: lib$(BROWSER_LIB_NAME).install
|
|
|
|
else
|
|
|
|
.PHONY: install_library
|
|
install_library: \
|
|
lib$(BROWSER_LIB_NAME).install_library \
|
|
lib$(BROWSER_LIB_NAME).install_ints \
|
|
lib$(BROWSER_LIB_NAME).install_hdrs
|
|
|
|
endif
|
|
endif
|