Files
mercury/ssdb/Mmakefile
Ian MacLarty 23d6d4a392 Get the java.ssdebug grade installing and compiling hello world.
Estimated hours taken: 2
Branches: main

Get the java.ssdebug grade installing and compiling hello world.
Note that currently the jars for the java.ssdebug grade are installed in the
same location as the non-ssdebug jars.  That's not a problem for now,
because the standard library currently has the ssdebug transformations
turned off when it's compiled in the ssdebug grade, so the java.ssdebug
jars are the same as the java jars.  Changing it so that the java.ssdebug
jars are installed in a different location requires getting mmc to
adjust the classpath depending on the grade, which doesn't seem worth
it at this stage.

Also note that the interface files for the ssdb, browser and mdbcomp
libraries need to be installed in the ssdebug grade otherwise mmc
complains that it cannot find files like ssdb.m when compiling
a program.  These interface files are currently only installed
when there is an ssdebug grade.

browser/MDB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Generate .module_dep files (needed to compile ssdebug transformed
    programs).

browser/Mmakefile:
    Build and install mer_browser.jar.
    Install the interface files when in an ssdebug grade.

browser/browse.m:
    Avoid a determinism warning.

browser/cterm.m:
browser/declarative_execution.m:
browser/listing.m:
    Get this code compiling in java grades.
    The "if (1 == 1)" before throwing an exception is to avoid
    "unreachable code" errors from the Java compiler.

library/Mmakefile:
    Mention that the ssdebug jars are installed in the
    same spot as the non-ssdebug jars.

mdbcomp/Mmakefile:
    Build and install mer_mdbcomp.jar.
    Install the interface files when in an ssdebug grade.

mdbcomp/rtti_access.m:
    Get this code compiling in Java grades.

scripts/Mercury.config.in:
    Add the ssdb, mdbcomp and browser jars to the classpath.
    If they are not installed they will just be ignored.

ssdb/Mmakefile:
    Build and install mer_ssdb.jar.
    Install the interface files when in an ssdebug grade.

ssdb/ssdb.m:
    Get this code compiling in java grades.
    Flush the output buffers after displaying the prompt so that
    it's always displayed.
2009-09-14 05:58:23 +00:00

329 lines
9.9 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 2007, 2009 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.
#-----------------------------------------------------------------------------#
# ssdb/Mmakefile - this is the Mmakefile for building the Mercury
# ssdb library, which also includes other functionality needed
# by the source to source Mercury debugger.
# 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_ssdb.mhs)
CHECK_OBJS = $(mer_ssdb.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.ssdb.params
# Override the default rule in `mmake --use-mmc-make' that asks `mmc' to
# create a missing optional params file.
Mmake.ssdb.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=$(SSDB_LIB_NAME)
MERCURY_MAIN_MODULES=$(MERCURY_MAIN_LIB_MODULES)
VPATH = $(LIBRARY_DIR) $(MDBCOMP_DIR) $(BROWSER_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.ssdb.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
MLLIBS += $(SOCKET_LIBRARY) $(NSL_LIBRARY) $(DL_LIBRARY) \
$(READLINE_LIBRARIES)
MCFLAGS += --flags SSDB_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_ssdb.dylib = -install_name \
$(FINAL_INSTALL_MERC_LIB_DIR)/libmer_ssdb.dylib
#-----------------------------------------------------------------------------#
JAVACFLAGS = -classpath $(LIBRARY_DIR):$(MDBCOMP_DIR):$(BROWSER_DIR)
MTAGS = $(SCRIPTS_DIR)/mtags
LN = ln
#-----------------------------------------------------------------------------#
# The IL, 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 il% 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$(SSDB_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
ifeq ("$(findstring java,$(GRADE))","java")
library: jars
else
library: $(LIBS)
endif
.PHONY: depend
depend: SSDB_FLAGS $(DEPENDS)
$(DEPENDS): Mercury.modules
.NOTPARALLEL:
# $(SSDB_LIB_NAME).dep $(SSDB_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$(SSDB_LIB_NAME).so: lib$(MDBCOMP_LIB_NAME).so
# lib$(SSDB_LIB_NAME).dylib: lib$(MDBCOMP_LIB_NAME).dylib
# lib$(SSDB_LIB_NAME): lib$(MDBCOMP_LIB_NAME)
# lib$(SSDB_LIB_NAME).int3s: lib$(MDBCOMP_LIB_NAME).int3s
# lib$(SSDB_LIB_NAME).ints: lib$(MDBCOMP_LIB_NAME).ints
# lib$(SSDB_LIB_NAME).cs: lib$(MDBCOMP_LIB_NAME).cs
# lib$(SSDB_LIB_NAME).ss: lib$(MDBCOMP_LIB_NAME).ss
# lib$(SSDB_LIB_NAME).ils: lib$(MDBCOMP_LIB_NAME).ils
# lib$(SSDB_LIB_NAME).javas: lib$(MDBCOMP_LIB_NAME).javas
# lib$(SSDB_LIB_NAME).check: lib$(MDBCOMP_LIB_NAME).check
# $($(SSDB_LIB_NAME).ints): $($(MDBCOMP_LIB_NAME).ints)
# $($(SSDB_LIB_NAME).cs): $($(MDBCOMP_LIB_NAME).cs)
# $($(SSDB_LIB_NAME).ss): $($(MDBCOMP_LIB_NAME).ss)
# $($(SSDB_LIB_NAME).ils): $($(MDBCOMP_LIB_NAME).ils)
# $($(SSDB_LIB_NAME).javas): $($(MDBCOMP_LIB_NAME).java_dates)
# $($(SSDB_LIB_NAME).c_dates): $($(MDBCOMP_LIB_NAME).c_dates)
# $($(SSDB_LIB_NAME).s_dates): $($(MDBCOMP_LIB_NAME).s_dates)
# $($(SSDB_LIB_NAME).il_dates): $($(MDBCOMP_LIB_NAME).il_dates)
# $($(SSDB_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: SSDB_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) $($(SSDB_LIB_NAME).ms)
$(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m
.PHONY: tags_file_exists
tags_file_exists:
@if test ! -f tags; then echo making tags; \
$(MTAGS) $($(SSDB_LIB_NAME).ms) ../mdbcomp/*.m ../library/*.m ; fi
$(SSDB_LIB_NAME).stats: $(COMPILER_DIR)/source_stats.awk \
$($(SSDB_LIB_NAME).ms)
awk -f $(COMPILER_DIR)/source_stats.awk \
`vpath_find $($(SSDB_LIB_NAME).ms)` > $@
#-----------------------------------------------------------------------------#
.PHONY: dates
dates:
touch $($(SSDB_LIB_NAME).dates)
#-----------------------------------------------------------------------------#
JARS = $(SSDB_LIB_NAME).jar
.PHONY: jars
jars: classes
echo jmercury/*.class > $(SSDB_LIB_NAME).classes
$(JAR) $(JAR_CREATE_FLAGS) $(SSDB_LIB_NAME).jar @$(SSDB_LIB_NAME).classes
$(JAR) i $(SSDB_LIB_NAME).jar
$(RM) $(SSDB_LIB_NAME).classes
JAVAS = $(wildcard jmercury/*.java)
.PHONY:
classes: javas
$(JAVAC) $(ALL_JAVACFLAGS) $(JAVAS)
javas: $(SSDB_LIB_NAME).javas
#-----------------------------------------------------------------------------#
.PHONY: os cs ss ils
ifneq ($(MMAKE_USE_MMC_MAKE),yes)
os: $($(SSDB_LIB_NAME).os)
cs: $($(SSDB_LIB_NAME).cs)
ss: $($(SSDB_LIB_NAME).ss)
ils: $($(SSDB_LIB_NAME).ils)
else
os: $(SSDB_LIB_NAME).os
cs: $(SSDB_LIB_NAME).cs
ss: $(SSDB_LIB_NAME).ss
ils: $(SSDB_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 SSDB_FLAGS SSDB_FLAGS.date
#-----------------------------------------------------------------------------#
# Installation targets
.PHONY: install
install: install_library install_ints install_hdrs
.PHONY: install_dirs
install_dirs:
[ -d $(INSTALL_MODULE_DIR) ] || mkdir -p $(INSTALL_MODULE_DIR)
[ -d $(INSTALL_GRADE_MODULE_DIR) ] || \
mkdir -p $(INSTALL_GRADE_MODULE_DIR)
[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
ifneq ("$(filter il% erlang%,$(GRADE))","")
# there is no ssdb in the .NET or Erlang backends
.PHONY: install_ints
install_ints:
.PHONY: install_hdrs
install_hdrs:
.PHONY: install_init
install_init:
.PHONY: install_library
install_library:
else ifneq (,$(findstring java,$(GRADE)))
.PHONY: install_ints
install_ints: lib$(SSDB_LIB_NAME).install_ints
.PHONY: install_init
install_init:
.PHONY: install_hdrs
install_hdrs: lib$(SSDB_LIB_NAME).install_hdrs
.PHONY: install_library
install_library: jars
mkdir -p $(INSTALL_JAVA_LIBRARY_DIR)
cp $(JARS) $(INSTALL_JAVA_LIBRARY_DIR)
else
.PHONY: install_ints
install_ints: lib$(SSDB_LIB_NAME).install_ints
.PHONY: install_hdrs
install_hdrs: lib$(SSDB_LIB_NAME).install_hdrs
.PHONY: install_init
install_init: $(SSDB_LIB_NAME).init install_dirs
cp `vpath_find $(SSDB_LIB_NAME).init` $(INSTALL_GRADE_MODULE_DIR)
.PHONY: install_library
install_library: lib$(SSDB_LIB_NAME) \
install_init \
install_dirs
cp `vpath_find lib$(SSDB_LIB_NAME).$A \
lib$(SSDB_LIB_NAME).$(EXT_FOR_SHARED_LIB)` \
$(INSTALL_MERC_LIB_DIR)
$(RANLIB) $(INSTALL_MERC_LIB_DIR)/lib$(SSDB_LIB_NAME).$A
endif