Files
mercury/browser/Mmakefile
Zoltan Somogyi ecdc285bc7 Split the existing browser library into two libraries, by making the
Estimated hours taken: 10
Branches: main

Split the existing browser library into two libraries, by making the
program_representation module into its own library. This is useful because
the compiler refers to program_representation.m, whose code thus needs to be
linked into compiler executables even if the compiler isn't compiled with
debugging enabled. By creating a new library for this module, we avoid any
chance of the linker dragging in the rest of the modules in the browser
library. (This is a problem with an upcoming diff.).

The name of the new library is "mdbcomp", because the intention is that it
contain code that is shared between the debugger and the compiler. This means
mostly the definitions of data structures that the compiler generates for the
debugger, and the predicates that operate on them.

Mmake.common.in:
	Allow MDB_COMP_ as a prefix for symbol names in the browser directory.

Mmake.workspace:
	Add a make variable holding for the name of the new library, and
	add the name to the relevant lists of libraries.

	Avoid duplicating the lists of filenames that need to be updated
	when adding new libraries or changing their names.

Mmakefile:
	Use make variables to refer to library names.

browser/mdbcomp.m:
browser/mer_mdbcomp.m:
	Add these files as the top modules of the new library.

browser/program_representation.m:
	Make program_representation.m a submodule of mdbcomp, not mdb.

browser/program_representation.m:
browser/browser_info.m:
	Move a predicate from program_representation.m to browser_info.m
	to avoid the mdbcomp library depend on the browser library, since
	this would negate the point of the exercise.

browser/mdb.m:
	Delete program_representation.m from the list of submodules.

browser/Mmakefile:
	Update this file to handle the new module.

browser/Mercury.options:
	Mention the new module.

browser/*.m:
	Update the lists of imported modules. Import only one browser module
	per line.

compiler/notes/overall_design.html:
	Document the new library.

compiler/compile_target_code.m:
	Add the mdbcomp library to the list of libraries we need to link with.

compiler/prog_rep.m:
trace/mercury_trace_internal.c:
	Import program_representation.m by its new name.

scripts/c2init.in:
	Centralize knowledge about which files need to be updated when the list
	of libraries changes here.

scripts/c2init.in:
scripts/ml.in:
tools/binary:
tools/binary_step:
tools/bootcheck:
tools/linear:
tools/lml:
	Update the list of libraries programs are linked with.
2003-10-27 06:00:50 +00:00

214 lines
6.3 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 1998-2003 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
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=library
MERCURY_MAIN_LIB_MODULES=$(BROWSER_LIB_NAME) $(MDBCOMP_LIB_NAME)
MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES) browse_test declarative_test
DEPENDS = $(patsubst %,%.depend,$(MERCURY_MAIN_MODULES))
INTS = $(patsubst %,%.int,$(MERCURY_MAIN_MODULES))
INT3S = $(patsubst %,%.int3,$(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$(TRACE_DIR)
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)
MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
$(READLINE_LIBRARIES)
MTAGS = $(SCRIPTS_DIR)/mtags
LN = ln
#-----------------------------------------------------------------------------#
# Stuff for Windows DLLS using gnu-win32
ifeq ($(USE_DLLS),yes)
# XXX what do we need here for MDCOMP_LIB_NAME?
DLL_CFLAGS = -Dlib$(BROWSER_LIB_NAME)_DEFINE_DLL
include $(MERCURY_DIR)/Makefile.DLLs
else
DLL_CFLAGS =
DLL_DEF_LIB =
endif
#-----------------------------------------------------------------------------#
# targets
.PHONY: library
library: $(LIBS)
.PHONY: all
all: library browse_test declarative_test
.PHONY: depend
depend: $(DEPENDS)
$(DEPENDS): 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.
.PHONY: Mercury.modules
Mercury.modules:
$(MC) $(ALL_MCFLAGS) -f *.m
.PHONY: check
check: $(CHECKS)
.PHONY: all-ints
all-ints: ints int3s
.PHONY: ints
ints: $(INTS)
.PHONY: int3s
int3s: $(INT3S)
#-----------------------------------------------------------------------------#
tags: $(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms)
$(MTAGS) $($(BROWSER_LIB_NAME).ms) $($(MDBCOMP_LIB_NAME).ms) \
../library/*.m
$(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)` > $@
$(MDCOMP_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
$($(MDCOMP_LIB_NAME).ms)
awk -f $(COMPILER_DIR)/source_stats.awk \
`vpath_find $($(MDCOMP_LIB_NAME).ms)` > $@
#-----------------------------------------------------------------------------#
.PHONY: dates
dates:
touch $($(BROWSER_LIB_NAME).dates) $($(MDBCOMP_LIB_NAME).dates)
#-----------------------------------------------------------------------------#
.PHONY: os cs ss ils
ifeq ($(MMAKE_USE_MMC_MAKE),no)
os: $($(BROWSER_LIB_NAME).os) $($(MDBCOMP_LIB_NAME).os)
cs: $($(BROWSER_LIB_NAME).cs) $($(MDBCOMP_LIB_NAME).cs)
ss: $($(BROWSER_LIB_NAME).ss) $($(MDBCOMP_LIB_NAME).ss)
ils: $($(BROWSER_LIB_NAME).ils) $($(MDBCOMP_LIB_NAME).ils)
else
os: $(BROWSER_LIB_NAME).os $(MDBCOMP_LIB_NAME).os
cs: $(BROWSER_LIB_NAME).cs $(MDBCOMP_LIB_NAME).cs
ss: $(BROWSER_LIB_NAME).ss $(MDBCOMP_LIB_NAME).ss
ils: $(BROWSER_LIB_NAME).ils $(MDBCOMP_LIB_NAME).ils
endif
#-----------------------------------------------------------------------------#
# Ensure we recompile mdb__version if VERSION is changed.
$(os_subdir)mdb.o \
$(os_subdir)mdb.pic_o \
$(os_subdir)mdbcomp.o \
$(os_subdir)mdbcomp.pic_o \
: $(RUNTIME_DIR)/mercury_conf.h
#-----------------------------------------------------------------------------#
realclean_local:
rm -f Mercury.modules tags
#-----------------------------------------------------------------------------#
# 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)
ifeq ($(findstring il,$(GRADE)),il)
# there is no browser in the .NET backend
.PHONY: install_init
install_init:
.PHONY: install_library
install_library:
else
.PHONY: install_init
install_init: $(BROWSER_LIB_NAME).init $(MDBCOMP_LIB_NAME).init install_dirs
cp `vpath_find $(BROWSER_LIB_NAME).init` $(INSTALL_MODULE_DIR)
cp `vpath_find $(MDBCOMP_LIB_NAME).init` $(INSTALL_MODULE_DIR)
.PHONY: install_library
install_library: \
lib$(BROWSER_LIB_NAME).$A \
lib$(BROWSER_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
lib$(MDBCOMP_LIB_NAME).$A \
lib$(MDBCOMP_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)
cp `vpath_find lib$(MDBCOMP_LIB_NAME).$A \
lib$(MDBCOMP_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(BROWSER_LIB_NAME).$A
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(MDBCOMP_LIB_NAME).$A
endif