[m-rev.] diff: get system building under cygwin and mingw
Peter Ross
pro at missioncriticalit.com
Tue Nov 28 17:49:42 AEDT 2006
Hi,
===================================================================
Estimated hours taken: 6
Branches: main
Get the sytem building under mingw and cygwin.
README.MinGW:
Document the new packages you need to install for the
system to build.
configure.in:
runtime/mercury_conf.h.in:
Test for the presence of the setenv and putenv functions.
configure.in:
Comment out some code which breaks with autoconf 2.60.
runtime/mercury_runtime_util.c:
runtime/mercury_runtime_util.h:
Add MR_setenv which is an implementation of setenv in terms
of either setenv or putenv.
runtime/mercury_trace_base.c:
Call MR_setenv.
trace/Mmakefile:
Mingw and cygwin only have flex 2.5.4 available, so use
the options compatible with that version.
Index: README.MinGW
===================================================================
RCS file: /home/mercury1/repository/mercury/README.MinGW,v
retrieving revision 1.5
diff -U5 -r1.5 README.MinGW
--- README.MinGW 12 Sep 2006 00:29:13 -0000 1.5
+++ README.MinGW 28 Nov 2006 06:47:02 -0000
@@ -24,13 +24,17 @@
* w32api-3.5.tar.gz
* binutils-2.15.91-20040904-1.tar.gz
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 <http://sourceforge.net/projects/gnuwin32/>.
+
2. Open an MSYS session and unpack the source distribution with a command
like:
tar -xvzf mercury-compiler-<VERSION>.tar.gz
Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.479
diff -U5 -r1.479 configure.in
--- configure.in 27 Nov 2006 14:58:41 -0000 1.479
+++ configure.in 28 Nov 2006 06:47:03 -0000
@@ -29,23 +29,26 @@
# Ensure that all messages are saved to a file `configure.log' by
# invoking ourself recursively without output piped into `tee configure.log'.
# 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" "$@" ;;
- 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" "$@" ;;
+# status=`cat configure.exit_status`
+# rm -f configure.exit_status
+# exit $status
+#fi
#-----------------------------------------------------------------------------#
# Work out the default arguments to configure when reconfiguring,
# for example when installing a binary distribution.
# Strip out --no-create and --no-recursion added by config.status.
@@ -930,11 +933,11 @@
snprintf _snprintf vsnprintf _vsnprintf strerror \
open close dup dup2 fdopen fileno fstat stat lstat isatty \
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( \
unistd.h sys/wait.h sys/siginfo.h sys/signal.h ucontext.h \
asm/sigcontext.h sys/param.h sys/time.h sys/times.h \
Index: runtime/mercury_conf.h.in
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_conf.h.in,v
retrieving revision 1.57
diff -U5 -r1.57 mercury_conf.h.in
--- runtime/mercury_conf.h.in 7 Aug 2006 06:57:38 -0000 1.57
+++ runtime/mercury_conf.h.in 28 Nov 2006 06:47:03 -0000
@@ -243,10 +243,13 @@
** MR_HAVE_CLOSEDIR we have the closedir() function.
** MR_HAVE_MKDIR we have the mkdir function.
** 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
#undef MR_HAVE_FORK
#undef MR_HAVE_EXECLP
@@ -299,10 +302,13 @@
#undef MR_HAVE_CLOSEDIR
#undef MR_HAVE_MKDIR
#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.
** In order to detect such overflows, we need to be able to figure
** out what address we were trying to read from or write to when we
Index: runtime/mercury_runtime_util.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_runtime_util.c,v
retrieving revision 1.4
diff -U5 -r1.4 mercury_runtime_util.c
--- runtime/mercury_runtime_util.c 14 Nov 2006 00:15:41 -0000 1.4
+++ runtime/mercury_runtime_util.c 28 Nov 2006 06:47:03 -0000
@@ -83,5 +83,38 @@
fprintf(stderr, "Mercury runtime: error in call to atexit: %s\n",
strerror(errno));
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
+}
Index: runtime/mercury_runtime_util.h
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_runtime_util.h,v
retrieving revision 1.2
diff -U5 -r1.2 mercury_runtime_util.h
--- runtime/mercury_runtime_util.h 13 Feb 2002 09:56:42 -0000 1.2
+++ runtime/mercury_runtime_util.h 28 Nov 2006 06:47:03 -0000
@@ -15,7 +15,8 @@
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 *, const char *, int);
#endif /* MERCURY_RUNTIME_UTIL_H */
Index: runtime/mercury_trace_base.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_trace_base.c,v
retrieving revision 1.77
diff -U5 -r1.77 mercury_trace_base.c
--- runtime/mercury_trace_base.c 24 Nov 2006 03:48:18 -0000 1.77
+++ runtime/mercury_trace_base.c 28 Nov 2006 06:47:03 -0000
@@ -413,13 +413,13 @@
strcat(cmd, " > /dev/null 2>&1");
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);
}
if (summary_status == 0) {
Index: trace/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/Mmakefile,v
retrieving revision 1.50
diff -U5 -r1.50 Mmakefile
--- trace/Mmakefile 27 Nov 2006 01:16:10 -0000 1.50
+++ trace/Mmakefile 28 Nov 2006 06:47:03 -0000
@@ -151,11 +151,11 @@
ALLOW_MDBCOMP_PREFIX=no
BISON = bison
BISON_OPTS = -v
FLEX = flex
-FLEX_OPTS = --8bit
+FLEX_OPTS = -8
MERCURY_DIR=..
LINK_STDLIB_ONLY=yes
include $(MERCURY_DIR)/Mmake.common
-include Mmake.trace.params
@@ -239,14 +239,14 @@
$(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 -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)
lib$(TRACE_LIB_NAME)$(DLL_DEF_LIB).$A: \
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list