diff --git a/README.MinGW b/README.MinGW index cdc061a93..6066e1514 100644 --- a/README.MinGW +++ b/README.MinGW @@ -26,9 +26,13 @@ To build the source distribution under MSYS follow these steps: and the following MSYS packages: * MSYS-1.0.10.exe * msysDTK-1.0.1.exe + * msys-autoconf-2.59.tar.bz2 Later versions of the above packages may also work, but earlier versions should be avoided. + You also need to download and install the flex and bison packages + from GnuWin32 . + 2. Open an MSYS session and unpack the source distribution with a command like: diff --git a/configure.in b/configure.in index 8da648e69..8aa3f93a6 100644 --- a/configure.in +++ b/configure.in @@ -31,19 +31,22 @@ AC_PREREQ(2.58) # The environment variable `SUPPRESS_LOG_FILE_RECURSION' is used to prevent # infinite recursion. # -if test "$SUPPRESS_LOG_FILE_RECURSION" != "yes"; then - SUPPRESS_LOG_FILE_RECURSION=yes - export SUPPRESS_LOG_FILE_RECURSION - trap 0 1 2 3 13 15 - rm -f configure.exit_status - { case $# in - 0) ${CONFIG_SHELL-/bin/sh} "$0" ;; - *) ${CONFIG_SHELL-/bin/sh} "$0" "$@" ;; - esac; echo $? > configure.exit_status; } | exec tee configure.log - status=`cat configure.exit_status` - rm -f configure.exit_status - exit $status -fi + +# XXX Currently this is commented out because autoconf 2.60 breaks +# how this works. +#if test "$SUPPRESS_LOG_FILE_RECURSION" != "yes"; then +# SUPPRESS_LOG_FILE_RECURSION=yes +# export SUPPRESS_LOG_FILE_RECURSION +# trap 0 1 2 3 13 15 +# rm -f configure.exit_status +# { case $# in +# 0) ${CONFIG_SHELL-/bin/sh} "$0" ;; +# *) ${CONFIG_SHELL-/bin/sh} "$0" "$@" ;; +# esac; echo $? > configure.exit_status; } | exec tee configure.log +# status=`cat configure.exit_status` +# rm -f configure.exit_status +# exit $status +#fi #-----------------------------------------------------------------------------# # Work out the default arguments to configure when reconfiguring, @@ -932,7 +935,7 @@ mercury_check_for_functions \ getpid setpgid fork execlp wait kill \ grantpt unlockpt ptsname tcgetattr tcsetattr ioctl \ access sleep opendir readdir closedir mkdir symlink readlink \ - gettimeofday + gettimeofday setenv putenv _putenv #-----------------------------------------------------------------------------# MERCURY_CHECK_FOR_HEADERS( \ diff --git a/runtime/mercury_conf.h.in b/runtime/mercury_conf.h.in index e43b4dc7f..9bdf79a52 100644 --- a/runtime/mercury_conf.h.in +++ b/runtime/mercury_conf.h.in @@ -245,6 +245,9 @@ ** MR_HAVE_SYMLINK we have the symlink function. ** MR_HAVE_READLINK we have the readlink function. ** MR_HAVE_GETTIMEOFDAY we have the gettimeofday function. +** MR_HAVE_SETENV we have the setenv() function. +** MR_HAVE_PUTENV we have the putenv() function. +** MR_HAVE__PUTENV we have the _putenv() function. */ #undef MR_HAVE_GETPID #undef MR_HAVE_SETPGID @@ -301,6 +304,9 @@ #undef MR_HAVE_SYMLINK #undef MR_HAVE_READLINK #undef MR_HAVE_GETTIMEOFDAY +#undef MR_HAVE_SETENV +#undef MR_HAVE_PUTENV +#undef MR_HAVE__PUTENV /* ** We use mprotect() and signals to catch stack and heap overflows. diff --git a/runtime/mercury_runtime_util.c b/runtime/mercury_runtime_util.c index 869bfcb99..c9a5852d9 100644 --- a/runtime/mercury_runtime_util.c +++ b/runtime/mercury_runtime_util.c @@ -85,3 +85,36 @@ MR_checked_atexit(void (*func)(void)) exit(EXIT_FAILURE); } } + +#if ! defined(MR_HAVE_PUTENV) && defined(MR_HAVE__PUTENV) + #define putenv _putenv +#endif + +int +MR_setenv(const char *name, const char *value, int overwrite) +{ +#if defined(MR_HAVE_SETENV) + return setenv(name, value, overwrite); +#elif defined(MR_HAVE_PUTENV) || defined(MR_HAVE__PUTENV) + char *env; + int length; + + if (!overwrite && getenv(name) != NULL) { + return 0; + } + + length = strlen(name) + strlen(value) + 2; + env = MR_NEW_ARRAY(char, length); + + env[0] = '\0'; + strcat(env, name); + strcat(env, "="); + strcat(env, value); + + MR_free(env); + + return putenv(env); +#else + #error "MR_setenv: unable to define" +#endif +} diff --git a/runtime/mercury_runtime_util.h b/runtime/mercury_runtime_util.h index 64cd6190a..d40fb2bd0 100644 --- a/runtime/mercury_runtime_util.h +++ b/runtime/mercury_runtime_util.h @@ -1,5 +1,5 @@ /* -** Copyright (C) 2001 The University of Melbourne. +** Copyright (C) 2001,2006 The University of Melbourne. ** This file may only be copied under the terms of the GNU Library General ** Public License - see the file COPYING.LIB in the Mercury distribution. */ @@ -17,5 +17,6 @@ extern FILE *MR_checked_fopen(const char *filename, const char *message, const char *mode); extern void MR_checked_fclose(FILE *file, const char *filename); extern void MR_checked_atexit(void (*func)(void)); +extern int MR_setenv(const char *name, const char *value, int overwrite); #endif /* MERCURY_RUNTIME_UTIL_H */ diff --git a/runtime/mercury_trace_base.c b/runtime/mercury_trace_base.c index 11f0c3681..446b304ec 100644 --- a/runtime/mercury_trace_base.c +++ b/runtime/mercury_trace_base.c @@ -415,9 +415,9 @@ MR_trace_record_label_exec_counts(void *dummy) old_options = getenv("MERCURY_OPTIONS"); if (old_options != NULL) { - (void) setenv("MERCURY_OPTIONS", "", MR_TRUE); + (void) MR_setenv("MERCURY_OPTIONS", "", MR_TRUE); summary_status = system(cmd); - (void) setenv("MERCURY_OPTIONS", old_options, MR_TRUE); + (void) MR_setenv("MERCURY_OPTIONS", old_options, MR_TRUE); } else { summary_status = system(cmd); } diff --git a/trace/Mmakefile b/trace/Mmakefile index e5ff26ab4..6e4cdae43 100644 --- a/trace/Mmakefile +++ b/trace/Mmakefile @@ -153,7 +153,7 @@ ALLOW_MDBCOMP_PREFIX=no BISON = bison BISON_OPTS = -v FLEX = flex -FLEX_OPTS = --8bit +FLEX_OPTS = -8 MERCURY_DIR=.. LINK_STDLIB_ONLY=yes @@ -241,10 +241,10 @@ mercury_event_parser.c mercury_event_parser.h: mercury_event_parser.y mercury_event_scanner.c mercury_event_scanner.h: \ mercury_event_scanner.l mercury_event_parser.h - $(FLEX) $(FLEX_OPTS) -s -P mercury_event_ \ - -o mercury_event_scanner.c \ - --header-file=mercury_event_scanner.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)