Files
mercury/trace/Mmakefile
Peter Wang fd76da59ff Add support for the csharp' grade to mmc --make', and make it possible to
Branches: main

Add support for the `csharp' grade to `mmc --make', and make it possible to
install the `csharp' grade with `mmake install'.

Also some miscellaneous fixes.


configure.in:
        Require a recent enough bootstrap compiler that recognises C# as a
        language for `pragma foreign_type'.

Mmakefile:
        Use `mmc --make' to install the standard library in csharp grade.

aclocal.m4:
        Search for the Mono C# compiler `gmcs', which is required for generics
        at this time.  Prefer it over the DotGNU C# compiler, which I have not
        tested.

        Search for `mono'.  If found, it will be used in shell scripts to
        launch executables generated via the csharp backend.

        Remove "MS_" prefixes on the variables MS_CSC and MS_ILASM, which are
        not Microsoft-specific.  More importantly, it should be less likely to
        make the mistake of adding an extra underscore to CSCFLAGS and
        ILASMFLAGS.

README.DotNet:
        Conform to variable renamings.

compiler/compile_target_code.m:
        Add new linked target types `csharp_executable', `java_launcher' and
        `erlang_launcher', instead of overloading `executable'.

        Link with `mer_std.dll' and other libraries when generating C#
        executables.  There is no `mer_rt.dll'.

        Pass "/debug" to the C# compiler if `--target-debug' is set.

        Create a shell script to launch the executable if necessary.

        Delete an unused predicate `standard_library_directory_option'.

compiler/file_names.m:
        `.cs' and `.cs_date' are grade-dependent.

compiler/handle_options.m:
        Force `.exe' as the executable file extension in csharp grades.

        Make the `erlang' grade component imply the same options as MLDS
        grades.

compiler/make.m:
        Classify executable target types based on the compilation target.

compiler/make.module_target.m:
        Handle `mmc --grade csharp --make <target>.dll'.

compiler/make.program_target.m:
        Install library DLLs in csharp grades.

        Make clean targets remove files for csharp grades.

        Conform to changes.

compiler/make.util.m:
        Add a stub foreign type.

        Conform to changes.

compiler/module_cmds.m:
        Factor out code to generate the shell scripts which launch programs
        compiled in Java, Erlang and C# grades.

compiler/options.m:
        Add `cli_interpreter' option to remember the name of the program which
        should be used to run CLI (.NET) programs.

        Add C#-related options to the help message.

compiler/options_file.m:
        Remove "MS_" prefixes on MS_ILASM_FLAGS and MS_CSC_FLAGS, and remove
        the extra underscore before "FLAGS".  In all uses of the variables,
        they were spelt without the extra underscore.

doc/user_guide.texi:
        Document options and file types related to the C# grade.

library/Mmakefile:
        Pass `mercury_dotnet.cs' to the C# compiler when building the standard
        library.  Suppress some warnings.

        Allow stubs in this directory for csharp grade.

        Conform to variable renamings.

library/builtin.m:
        Uncomment foreign language pragmas for C#.

        Handle null values in C# implementation of `deep_copy'.

library/private_builtin.m:
library/string.m:
        Compare strings by ordinals in C#, instead of culture-specific rules.
        Although the latter is allowed according to the documentation, it is
        likely to slower, and cause confusion when porting between backends.

        Handle negative index in string.set_char.

library/rtti_implementation.m:
        Uncomment foreign language pragmas for C#.

        `System.Type.GetType' only searches the current executing assembly or
        in mscorlib for a type.  As we have to be able to find types in other
        assemblies (e.g. mer_std.dll or user DLLs), explicitly search through
        a list of assemblies.

library/thread.semaphore.m:
        Uncomment foreign language pragmas for C#.

        Fix missing class qualification.

library/array.m:
library/bitmap.m:
library/bool.m:
library/dir.m:
library/exception.m:
library/io.m:
library/mutvar.m:
library/par_builtin.m:
library/region_builtin.m:
library/store.m:
library/thread.m:
library/time.m:
library/univ.m:
library/version_array.m:
        Uncomment foreign language pragmas for C#.

mdbcomp/rtti_access.m:
        Add type and procedure stubs.

runtime/mercury_dotnet.cs.in:
        Override `Equals(object)' methods in `TypeCtorInfo_Struct' and
        `TypeInfo_Struct' classes.  This requires we override `GetHashCode' as
        well.

        Handle nulls arguments to `Equals' methods as is the expected behaviour.

        Override `ToString' in `TypeCtorInfo_Struct' to produce more useful
        output during debugging.

scripts/Mercury.config.in:
        Record the configured CLI_INTERPRETER and pass that to the compiler as
        a flag.

        Conform to variable renamings.

scripts/Mmake.vars.in:
        Pass value of CSCFLAGS from Mmake through to `mmc --make'.

        Conform to variable renamings.

scripts/Mercury.config.bootstrap.in:
scripts/Mmake.rules:
        Conform to variable renaming.

scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
        Canonicalise high-level code, high-level-data, C# target code to the
        `csharp' grade.

        Handle erlang grades like other grades.

scripts/prepare_install_dir.in:
        Copy `.cs' files from the runtime directory when preparing an install
        directory.

browser/Mmakefile:
compiler/Mmakefile:
deep_profiler/Mmakefile:
mdbcomp/Mmakefile:
profiler/Mmakefile:
runtime/Mmakefile:
slice/Mmakefile:
ssdb/Mmakefile:
trace/Mmakefile:
        Do as other non-C grades in this directory.

        Conform to variable renamings.

tests/hard_coded/foreign_enum_dummy.m:
tests/hard_coded/sub-modules/non_word_mutable.m:
tests/hard_coded/sub-modules/sm_exp_bug.m:
        Make these tests work in C#.

tests/mmc_make/Mmakefile:
        Update a regular expression to account for `mmc --make' writing
        "Making rebuild.exe" on platforms where the .exe suffix is not normally
        used.

tests/mmc_make/complex_test.exp2:
        Add alternative output (minor difference in floating point precision).

tests/debugger/Mmakefile:
tests/debugger/declarative/Mmakefile:
tests/general/structure_reuse/Mmakefile:
tests/hard_coded/Mmakefile:
tests/hard_coded/sub-modules/Mmakefile:
tests/par_conj/Mmakefile:
tests/stm/Mmakefile:
        Disable some tests in the csharp grade.

tests/invalid/Mmakefile:
        Disable some tests in the csharp grade.

        Enable a test which should work in java grades.

tests/valid/Mmakefile:
        Do as other non-C grades in this directory.

        When testing the csharp grade in this directory, produce only the C#
        target files for now.

tests/run_one_test:
        Don't compress a failing test case executable when the executable is
        actually only a shell script.
2010-09-30 07:23:36 +00:00

377 lines
12 KiB
Plaintext

#-----------------------------------------------------------------------------#
# Copyright (C) 1998-2008 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.
#-----------------------------------------------------------------------------#
# Mmakefile for the Mercury trace library, which contains the runtime
# system components that are needed only if some procedures are traced.
#-----------------------------------------------------------------------------#
# The list of human-written C header files of the trace library.
# Keep this list in alphabetical order, please.
HAND_TRACE_HDRS = \
mercury_trace.h \
mercury_trace_alias.h \
mercury_trace_browse.h \
mercury_trace_cmd_backward.h \
mercury_trace_cmd_breakpoint.h \
mercury_trace_cmd_browsing.h \
mercury_trace_cmd_dd.h \
mercury_trace_cmd_developer.h \
mercury_trace_cmd_exp.h \
mercury_trace_cmd_help.h \
mercury_trace_cmd_misc.h \
mercury_trace_cmd_parameter.h \
mercury_trace_cmd_queries.h \
mercury_trace_cmd_table_io.h \
mercury_trace_cmds.h \
mercury_trace_command_queue.h \
mercury_trace_completion.h \
mercury_trace_declarative.h \
mercury_trace_external.h \
mercury_trace_help.h \
mercury_trace_hold_vars.h \
mercury_trace_internal.h \
mercury_trace_readline.h \
mercury_trace_source.h \
mercury_trace_spy.h \
mercury_trace_tables.h \
mercury_trace_util.h \
mercury_trace_vars.h
# The list of human-written C source files of the trace library.
# Keep this list in alphabetical order, please.
HAND_TRACE_SRCS = \
mercury_trace.c \
mercury_trace_alias.c \
mercury_trace_browse.c \
mercury_trace_cmd_backward.c \
mercury_trace_cmd_breakpoint.c \
mercury_trace_cmd_browsing.c \
mercury_trace_cmd_dd.c \
mercury_trace_cmd_developer.c \
mercury_trace_cmd_exp.c \
mercury_trace_cmd_forward.c \
mercury_trace_cmd_help.c \
mercury_trace_cmd_misc.c \
mercury_trace_cmd_parameter.c \
mercury_trace_cmd_queries.c \
mercury_trace_cmd_table_io.c \
mercury_trace_command_queue.c \
mercury_trace_completion.c \
mercury_trace_declarative.c \
mercury_trace_external.c \
mercury_trace_help.c \
mercury_trace_hold_vars.c \
mercury_trace_internal.c \
mercury_trace_readline.c \
mercury_trace_source.c \
mercury_trace_spy.c \
mercury_trace_tables.c \
mercury_trace_util.c \
mercury_trace_vars.c
# The list of human-written C header files of the eventspec library.
# Keep this list in alphabetical order, please.
HAND_EVENTSPEC_HDRS = \
mercury_event_spec.h
# The list of human-written C source files of the eventspec library.
# Keep this list in alphabetical order, please.
HAND_EVENTSPEC_SRCS = \
mercury_event_spec.c
# The list of automatically created C header files.
# Keep this list in alphabetical order, please.
GEN_EVENTSPEC_HDRS = \
mercury_event_parser.h \
mercury_event_scanner.h
# The list of automatically created C source files.
# Keep this list in alphabetical order, please.
GEN_EVENTSPEC_SRCS = \
mercury_event_parser.c \
mercury_event_scanner.c
TRACE_HDRS = $(HAND_TRACE_HDRS)
TRACE_SRCS = $(HAND_TRACE_SRCS)
EVENTSPEC_HDRS = $(HAND_EVENTSPEC_HDRS) $(GEN_EVENTSPEC_HDRS)
EVENTSPEC_SRCS = $(HAND_EVENTSPEC_SRCS) $(GEN_EVENTSPEC_SRCS)
HAND_HDRS = $(HAND_TRACE_HDRS) $(HAND_EVENTSPEC_HDRS)
HAND_SRCS = $(HAND_TRACE_SRCS) $(HAND_EVENTSPEC_SRCS)
HDRS = $(TRACE_HDRS) $(EVENTSPEC_HDRS)
SRCS = $(TRACE_SRCS) $(EVENTSPEC_SRCS)
# The object files in this directory depend on many of the header files
# in the runtime. However, changes to many of these header files require
# a global make clean. Here we list only the header files from the runtime
# whose changes don't usually require a make clean but which nevertheless
# require the trace library to be recompiled.
RUNTIME_HDRS = \
$(RUNTIME_DIR)/mercury_stack_layout.h \
$(RUNTIME_DIR)/mercury_trace_base.h \
$(RUNTIME_DIR)/mercury_trace_term.h
TRACE_OBJS = $(TRACE_SRCS:.c=.$O)
EVENTSPEC_OBJS = $(EVENTSPEC_SRCS:.c=.$O)
OBJS = $(SRCS:.c=.$O)
TRACE_PIC_OBJS = $(TRACE_SRCS:.c=.$(EXT_FOR_PIC_OBJECTS))
EVENTSPEC_PIC_OBJS = $(EVENTSPEC_SRCS:.c=.$(EXT_FOR_PIC_OBJECTS))
PIC_OBJS = $(SRCS:.c=.$(EXT_FOR_PIC_OBJECTS))
EVENTSPEC_LDFLAGS = -L$(BROWSER_DIR) -L$(MDBCOMP_DIR) -L$(LIBRARY_DIR) \
-L$(RUNTIME_DIR) -L$(BOEHM_GC_DIR) -L/usr/local/lib
EVENTSPEC_LDLIBS= -l$(BROWSER_LIB_NAME) -l$(MDBCOMP_LIB_NAME) \
$(MLLIBS) $(SOCKET_LIBRARY) \
$(NSL_LIBRARY) $(DL_LIBRARY) $(READLINE_LIBRARIES)
TRACE_LDFLAGS = -L$(TRACE_DIR) $(EVENTSPEC_LDFLAGS)
TRACE_LDLIBS = -l$(EVENTSPEC_LIB_NAME) $(EVENTSPEC_LDLIBS)
THREADLIBS = \
` case "$(GRADE)" in \
*.par*) echo "-lpthread" ;; \
esac \
`
MAIN_TARGET=all
# Specify which files to check for namespace cleanliness, and which name
# prefixes are allowed.
#
# The header files generated by flex and bison cannot pass any kind of
# namespace cleanliness test, and we don't have enough control over them
# to make them pass those tests.
CHECK_HDRS = $(HAND_HDRS)
CHECK_MHDRS =
CHECK_OBJS = $(OBJS)
ALLOW_LIB_PREFIX=no
ALLOW_BROWSER_PREFIX=no
ALLOW_MDBCOMP_PREFIX=no
ALLOW_SSDB_PREFIX=no
BISON = bison
BISON_OPTS = -v
FLEX = flex
FLEX_OPTS = -8
MERCURY_DIR=..
LINK_STDLIB_ONLY=yes
include $(MERCURY_DIR)/Mmake.common
-include Mmake.trace.params
# Avoid trying to make this file with `mmc --make' if it doesn't exist.
Mmake.trace.params: ;
#-----------------------------------------------------------------------------#
CFLAGS += $(DLL_CFLAGS)
MGNUCFLAGS += --c-debug --no-ansi
#-----------------------------------------------------------------------------#
# mercury_readline.c #includes the GNU readline headers, which
# lack prototypes and `const', so we need to disable warnings
# when compiling that file.
MGNUCFLAGS-mercury_trace_readline = --no-check
#-----------------------------------------------------------------------------#
# Stuff for Windows DLLs
ifeq ($(USE_DLLS),yes)
DLL_CFLAGS = -Dlib$(TRACE_LIB_NAME)_DEFINE_DLL
# the following header files are created automatically by Makefile.DLLs
LIB_DLL_H = lib$(TRACE_LIB_NAME)_dll.h
LIB_GLOBALS_H = lib$(TRACE_LIB_NAME)_globals.h
include $(MERCURY_DIR)/Makefile.DLLs
else
DLL_CFLAGS =
LIB_DLL_H =
LIB_GLOBALS_H =
DLL_DEF_LIB =
endif
#-----------------------------------------------------------------------------#
# Most object files do not depend on the automatically generated headers;
# for the ones that do, we list the dependency explicitly.
$(OBJS) $(PIC_OBJS): $(HAND_HDRS) $(RUNTIME_HDRS)
mercury_event_scanner.$(O): $(GEN_EVENTSPEC_HDRS)
mercury_event_scanner.$(EXT_FOR_PIC_OBJECTS): $(GEN_EVENTSPEC_HDRS)
mercury_event_parser.$(O): $(GEN_EVENTSPEC_HDRS)
mercury_event_parser.$(EXT_FOR_PIC_OBJECTS): $(GEN_EVENTSPEC_HDRS)
mercury_event_spec.$(O): $(GEN_EVENTSPEC_HDRS)
mercury_event_spec.$(EXT_FOR_PIC_OBJECTS): $(GEN_EVENTSPEC_HDRS)
#-----------------------------------------------------------------------------#
.PHONY: all
.PHONY: trace
ifneq ("$(filter il% csharp% java% erlang%,$(GRADE))","")
# there is no tracing in the .NET, Java, Erlang backends
all:
trace:
else
all: trace $(TAGS_FILE_EXISTS)
trace: lib$(EVENTSPEC_LIB_NAME).$A
trace: lib$(EVENTSPEC_LIB_NAME).$(EXT_FOR_SHARED_LIB)
trace: lib$(TRACE_LIB_NAME).$A
trace: lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB)
trace: $(LIB_DLL_H) $(LIB_GLOBALS_H)
endif
mercury_event_parser.c mercury_event_parser.h: mercury_event_parser.y
$(BISON) $(BISON_OPTS) -p mercury_event_ -d -o mercury_event_parser.c \
mercury_event_parser.y
mercury_event_scanner.c mercury_event_scanner.h: \
mercury_event_scanner.l mercury_event_parser.h
$(FLEX) $(FLEX_OPTS) -s -Pmercury_event_ \
-omercury_event_scanner.c \
mercury_event_scanner.l
echo "extern int mercury_event_lex(void);" > mercury_event_scanner.h
RPATH_1=$(SHLIB_RPATH_OPT)$(FINAL_INSTALL_MERC_LIB_DIR)
RPATH_2=$(SHLIB_RPATH_SEP)$(FINAL_INSTALL_MERC_GC_LIB_DIR)
lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).$A: \
$(TRACE_OBJS) lib$(EVENTSPEC_LIB_NAME)$(DLL_DEF_LIB).$A
rm -f lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).$A
$(AR) $(ALL_ARFLAGS) \
$(AR_LIBFILE_OPT)lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).$A \
$(TRACE_OBJS)
$(RANLIB) $(RANLIBFLAGS) lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).$A
lib$(EVENTSPEC_LIB_NAME)$(DLL_DEF_LIB).$A: $(EVENTSPEC_OBJS)
rm -f lib$(EVENTSPEC_LIB_NAME)$(DLL_DEF_LIB).$A
$(AR) $(ALL_ARFLAGS) \
$(AR_LIBFILE_OPT)lib$(EVENTSPEC_LIB_NAME)$(DLL_DEF_LIB).$A \
$(EVENTSPEC_OBJS)
$(RANLIB) lib$(EVENTSPEC_LIB_NAME)$(DLL_DEF_LIB).$A
lib$(TRACE_LIB_NAME).so: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).so
$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
-o lib$(TRACE_LIB_NAME).so $(TRACE_PIC_OBJS) \
$(RPATH_1)$(RPATH_2) \
$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS) \
$(SHARED_LIBS)
lib$(EVENTSPEC_LIB_NAME).so: $(EVENTSPEC_PIC_OBJS)
$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
-o lib$(EVENTSPEC_LIB_NAME).so $(EVENTSPEC_PIC_OBJS) \
$(RPATH_1)$(RPATH_2) \
$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS) \
$(SHARED_LIBS)
# For Darwin:
lib$(TRACE_LIB_NAME).dylib: $(TRACE_PIC_OBJS) lib$(EVENTSPEC_LIB_NAME).dylib
$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
-o lib$(TRACE_LIB_NAME).dylib $(TRACE_PIC_OBJS) \
-install_name \
$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(TRACE_LIB_NAME).dylib \
$(TRACE_LDFLAGS) $(TRACE_LDLIBS) $(THREADLIBS) \
$(SHARED_LIBS)
lib$(EVENTSPEC_LIB_NAME).dylib: $(EVENTSPEC_PIC_OBJS)
$(LINK_SHARED_OBJ) $(ERROR_UNDEFINED) \
-o lib$(EVENTSPEC_LIB_NAME).dylib $(EVENTSPEC_PIC_OBJS) \
-install_name \
$(FINAL_INSTALL_MERC_LIB_DIR)/lib$(EVENTSPEC_LIB_NAME).dylib \
$(EVENTSPEC_LDFLAGS) $(EVENTSPEC_LDLIBS) $(THREADLIBS) \
$(SHARED_LIBS)
.PHONY: cs
cs: $(SRCS)
tags: $(HAND_SRCS) $(HAND_HDRS)
ctags $(HAND_SRCS) $(HAND_HDRS) $(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h
.PHONY: tags_file_exists
tags_file_exists:
@if test ! -f tags; then echo making tags; \
ctags $(HAND_SRCS) $(HAND_HDRS) \
$(RUNTIME_DIR)/*.c $(RUNTIME_DIR)/*.h ; \
fi
#-----------------------------------------------------------------------------#
# installation rules
.PHONY: install
install: install_headers install_lib
ifneq ("$(filter il% csharp% java% erlang%,$(GRADE))","")
# there is no tracing in the .NET, Java, Erlang backends
.PHONY: install_headers
install_headers:
.PHONY: install_lib
install_lib:
else
.PHONY: install_headers
install_headers: $(HDRS) $(LIB_GLOBALS_H)
cp `vpath_find $(HDRS) $(LIB_GLOBALS_H)` $(INSTALL_INC_DIR)
.PHONY: install_lib
install_lib: \
lib$(TRACE_LIB_NAME).$A \
lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
lib$(EVENTSPEC_LIB_NAME).$A \
lib$(EVENTSPEC_LIB_NAME).$(EXT_FOR_SHARED_LIB)
-[ -d $(INSTALL_MERC_LIB_DIR) ] || mkdir -p $(INSTALL_MERC_LIB_DIR)
cp `vpath_find \
lib$(TRACE_LIB_NAME).$A \
lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
lib$(EVENTSPEC_LIB_NAME).$A \
lib$(EVENTSPEC_LIB_NAME).$(EXT_FOR_SHARED_LIB) \
` \
$(INSTALL_MERC_LIB_DIR)
$(RANLIB) $(RANLIBFLAGS) \
$(INSTALL_MERC_LIB_DIR)/lib$(TRACE_LIB_NAME).$A
$(RANLIB) $(RANLIBFLAGS) \
$(INSTALL_MERC_LIB_DIR)/lib$(EVENTSPEC_LIB_NAME).$A
endif
#-----------------------------------------------------------------------------#
clean_local: clean_o clean_check
.PHONY: clean_o
clean_o:
rm -f $(OBJS) $(PIC_OBJS)
.PHONY: realclean_local
realclean_local:
rm -f lib$(TRACE_LIB_NAME).$A
rm -f lib$(TRACE_LIB_NAME).$(EXT_FOR_SHARED_LIB)
rm -f lib$(EVENTSPEC_LIB_NAME).$A
rm -f lib$(EVENTSPEC_LIB_NAME).$(EXT_FOR_SHARED_LIB)
rm -f $(GEN_EVENTSPEC_SRCS) $(GEN_EVENTSPEC_HDRS)
#-----------------------------------------------------------------------------#