mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-15 05:44:58 +00:00
Estimated hours taken: 12 Branches: main Remove most of the junk from the command lines executed by make when building the compiler and by bootcheck when building test cases. We do this by moving the junk into files consulted via the --flags option. After this change, it is actually possible to see in a glance not just which files are being compiled but also with which options. The size of the output (measured in bytes) from a bootcheck is now only about 40% of what is was before. configure.in: Remember the path to the bootstrap compiler and the flags it should be invoked with separately. Put the flags into the FLAGS files in various directories. Test whether the default install directory actually exists, so that the -L and -R linker options referring to this directory are passed to the C compiler only if it does. Mmake.common.in: Comment out a bunch of additions of MCFLAGS, the ones whose contents are now in FLAGS files. Conform to the changes in configure.in. Add a template rule for the dependencies of the FLAGS files. Mmake.workspace: Comment out a bunch of additions of MCFLAGS, the ones whose contents are now in FLAGS files. In some cases, add references to the FLAGS files. Mmakefile: When rebuilding Mmake.common, rebuild only Mmake.common, not all files created by configure. analysis/ANALYSIS_FLAGS.in: browser/MDB_FLAGS.in: compiler/COMP_FLAGS.in: deep_profiler/PROF_FLAGS.in: library/LIB_FLAGS.in: mdbcomp/MDBCOMP_FLAGS.in: profiler/DEEP_FLAGS.in: slice/SLICE_FLAGS.in: tests/TESTS_FLAGS.in: Add these files, which each contain the junk flags (the flags which are the same on every invocation and mostly just clutter up compiler command lines) that are needed on each compiler invocation in the relevant directory. Besides the results of configuration (word size etc), and the paths to other parts of the system, these files mostly control which warnings are enabled. Restrict the list of directories in -I options to what is sensible; for example, don't specify -I../analysis in the deep_profiler directory. */.nocopyright: Don't require copyright notices in FLAGS files, since that would make them invalid. library/INTER_FLAGS: Add this file, which contains the flags enabled with intermodule optimization. tests/WS_FLAGS.ws: Add this file. Unlike the .in files, which processed by config.status based on the results of autoconfiguration, this one is processed to specify the location of the workspace being tested. analysis/Mmakefile: browser/Mmakefile: compiler/Mmakefile: deep_profiler/Mmakefile: library/Mmakefile: mdbcomp/Mmakefile: profiler/Mmakefile: tests/Mmakefile: Include the relevant directory's FLAGS file on the command line, to replace all the additions to MCFLAGS in ../Mmake.common and in ../Mmake.workspace, and in some cases, the directory-specific Mmakefile itself. Build the directory's FLAGS file before executing the depend target, since most compiler options beyond --generate-dependencies come from there. Delete the FLAGS files generated by config.status when doing "make clean". tests/Mmakefile: Allow the environment to define DIFF_OPTS. runtime/Mmakefile: Use an option to tell config.status what to rebuild, not some environment variables. tests/invalid/Mercury.options: For two test cases, reset an option that is set in tests/WS_FLAGS, to match the options the affected tests were compiled with before. tests/invalid/*.err2: Update these expected files to account for the use of error_util in error messages by previous changes to the compiler. These expected output files are used only with --use-subdirs. tests/warnings/Mmakefile: For all test cases, reset an option that is set in tests/WS_FLAGS, to match the options the tests were compiled with before. scripts/prepare_tmp_dir_grade_part Copy the flags files when creating the subdirectories of tmp_dir. scripts/mgnuc.in: Provide a mechanism, a per-directory .mgnuc_opts file, for specifying the options that are required for every C file in a directory. The intention is to use this for -I../library etc, but this is not done yet; one thing at a time. tools/bootcheck: Copy the FLAGS files when creating stage2 and stage3. Don't specify the compiler options that are now in FLAGS files. Fill in the location of the workspace in tests/WS_FLAGS before running the tests. Provide a mechanism (a file ~/.bootcheck_diff_opts) to allow the user to specify what options to invoke diff with. Move the setting of MMAKE_USE_SUBDIRS and MMAKE_USE_MMC_MAKE after we have built stage1, and always copy the profilers if --use-subdirs is set. The old ways of doing things caused problems if bootcheck was given --use-subdirs but stage1 doesn't use subdirs: the bootcheck modified the stage1 slice, profiler and deep_profiler directories.
302 lines
9.6 KiB
Plaintext
302 lines
9.6 KiB
Plaintext
#-----------------------------------------------------------------------------#
|
|
# Copyright (C) 1998-2005 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
|
|
|
|
MERCURY_DIR=..
|
|
LINK_STDLIB_ONLY=yes
|
|
include $(MERCURY_DIR)/Mmake.common
|
|
-include 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) \
|
|
-I$(MDBCOMP_DIR) -I$(MDBCOMP_DIR)/$(mihs_subdir) \
|
|
-I$(TRACE_DIR)
|
|
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
|
|
MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
|
|
$(READLINE_LIBRARIES)
|
|
|
|
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.
|
|
|
|
LD_LIBFLAGS-libmer_browser.dylib = -install_name \
|
|
$(FINAL_INSTALL_MERC_LIB_DIR)/libmer_browser.dylib
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
JAVACFLAGS = -classpath $(LIBRARY_DIR)
|
|
|
|
MTAGS = $(SCRIPTS_DIR)/mtags
|
|
|
|
LN = ln
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
# The IL 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 il% 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$(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) browse_test declarative_test
|
|
|
|
.PHONY: library
|
|
library: $(LIBS)
|
|
|
|
.PHONY: depend
|
|
depend: MDB_FLAGS $(DEPENDS)
|
|
$(DEPENDS): Mercury.modules
|
|
|
|
.NOTPARALLEL:
|
|
|
|
# $(BROWSER_LIB_NAME).dep $(BROWSER_LIB_NAME).depend:
|
|
# $(MCD) $(ALL_GRADEFLAGS) $(ALL_MCDFLAGS) $*
|
|
|
|
# The need for these dependencies should be obviated by the fact that the
|
|
# mdbcomp directory is brought up-to-date first.
|
|
|
|
# lib$(BROWSER_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
|
|
# lib$(BROWSER_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
|
|
# lib$(BROWSER_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
|
|
# lib$(BROWSER_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
|
|
# lib$(BROWSER_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
|
|
# lib$(BROWSER_LIB_NAME).cs: lib$(MDBCOMP_LIB_NAME).cs
|
|
# lib$(BROWSER_LIB_NAME).ss: lib$(MDBCOMP_LIB_NAME).ss
|
|
# lib$(BROWSER_LIB_NAME).ils: lib$(MDBCOMP_LIB_NAME).ils
|
|
# lib$(BROWSER_LIB_NAME).javas: lib$(MDBCOMP_LIB_NAME).javas
|
|
# lib$(BROWSER_LIB_NAME).check: lib$(MDBCOMP_LIB_NAME).check
|
|
# $($(BROWSER_LIB_NAME).ints): $($(MDBCOMP_LIB_NAME).ints)
|
|
# $($(BROWSER_LIB_NAME).cs): $($(MDBCOMP_LIB_NAME).cs)
|
|
# $($(BROWSER_LIB_NAME).ss): $($(MDBCOMP_LIB_NAME).ss)
|
|
# $($(BROWSER_LIB_NAME).ils): $($(MDBCOMP_LIB_NAME).ils)
|
|
# $($(BROWSER_LIB_NAME).javas): $($(MDBCOMP_LIB_NAME).java_dates)
|
|
# $($(BROWSER_LIB_NAME).c_dates): $($(MDBCOMP_LIB_NAME).c_dates)
|
|
# $($(BROWSER_LIB_NAME).s_dates): $($(MDBCOMP_LIB_NAME).s_dates)
|
|
# $($(BROWSER_LIB_NAME).il_dates): $($(MDBCOMP_LIB_NAME).il_dates)
|
|
# $($(BROWSER_LIB_NAME).java_dates): $($(MDBCOMP_LIB_NAME).java_dates)
|
|
|
|
# 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.
|
|
.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)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
tags: $(MTAGS) $($(BROWSER_LIB_NAME).ms)
|
|
$(MTAGS) $($(BROWSER_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m
|
|
|
|
.PHONY: tags_file_exists
|
|
tags_file_exists:
|
|
@if test ! -f tags; then echo making tags; \
|
|
$(MTAGS) $($(BROWSER_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m ; 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)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
#
|
|
# Some Java compilers require the Java source files to be put in directories
|
|
# which match their package names. But the Mercury compiler generates them
|
|
# with the package name prefixed to the file name with a ".", not a "/".
|
|
# So we copy the Java source files to where the Java compiler expects them
|
|
# to be.
|
|
#
|
|
# XXX This is a hack. We ought to change the Mercury compiler so that it
|
|
# generates the Java files with the right names in the first place.
|
|
#
|
|
|
|
mdb/%.java: mdb.%.java
|
|
[ -d mdb ] || mkdir mdb
|
|
cp $< $@
|
|
|
|
RENAMED_JAVAS = $($(BROWSER_LIB_NAME).javas:mdb.%.java=mdb/%.java)
|
|
|
|
RENAMED_CLASSES = $($(BROWSER_LIB_NAME).classes:mdb.%.class=mdb/%.class)
|
|
|
|
.PHONY: javas
|
|
javas: $(RENAMED_JAVAS)
|
|
|
|
.PHONY: classes
|
|
classes: $(RENAMED_JAVAS)
|
|
$(JAVAC) $(ALL_JAVACFLAGS) -d $(classes_subdir) $(RENAMED_JAVAS)
|
|
|
|
#-----------------------------------------------------------------------------#
|
|
|
|
.PHONY: os cs ss ils
|
|
ifneq ($(MMAKE_USE_MMC_MAKE),yes)
|
|
os: $($(BROWSER_LIB_NAME).os)
|
|
cs: $($(BROWSER_LIB_NAME).cs)
|
|
ss: $($(BROWSER_LIB_NAME).ss)
|
|
ils: $($(BROWSER_LIB_NAME).ils)
|
|
else
|
|
os: $(BROWSER_LIB_NAME).os
|
|
cs: $(BROWSER_LIB_NAME).cs
|
|
ss: $(BROWSER_LIB_NAME).ss
|
|
ils: $(BROWSER_LIB_NAME).ils
|
|
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_init install_library
|
|
|
|
.PHONY: install_dirs
|
|
install_dirs:
|
|
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
|
|
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
|
|
|
|
ifneq ("$(filter il% java%,$(GRADE))","")
|
|
|
|
# there is no browser in the .NET and Java backends
|
|
|
|
.PHONY: install_init
|
|
install_init:
|
|
|
|
.PHONY: install_library
|
|
install_library:
|
|
|
|
else
|
|
|
|
.PHONY: install_init
|
|
install_init: $(BROWSER_LIB_NAME).init install_dirs
|
|
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
|
|
|
|
.PHONY: install_library
|
|
install_library: \
|
|
lib$(BROWSER_LIB_NAME).$A \
|
|
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
|
|
install_dirs
|
|
cp `vpath_find lib$(BROWSER_LIB_NAME).$A \
|
|
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
|
|
$(INSTALL_MERC_LIB_DIR)
|
|
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(BROWSER_LIB_NAME).$A
|
|
|
|
endif
|