Get the sytem building under mingw and cygwin.

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.
This commit is contained in:
Peter Ross
2006-11-28 06:57:43 +00:00
parent f9b21c8933
commit bc85aed613
7 changed files with 68 additions and 21 deletions

View File

@@ -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 <http://sourceforge.net/projects/gnuwin32/>.
2. Open an MSYS session and unpack the source distribution with a command
like:

View File

@@ -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( \

View File

@@ -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.

View File

@@ -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
}

View File

@@ -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 */

View File

@@ -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);
}

View File

@@ -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)