[m-rev.] for review: mercury.bat

Fergus Henderson fjh at cs.mu.OZ.AU
Thu Apr 19 14:11:02 AEST 2001


Recently there has been some discussion about getting Mercury to work on
Windows without Cygwin.  The change enclosed below is not a complete solution.
But I'd appreciate comments about
- whether this is a worthwhile goal
- whether this approach is a reasonable approach to achieve that goal
- whether I should commit this part now,
  or whether we should wait until there is a solution
  to problem (1) [see below] before committing this

The main drawback, I think, is that solving (1) is likely to require
a fairly substantial amount of code duplication: scripts/ml is 1400
lines of Bourne shell script.

----------

Estimated hours taken: 4
Branches: main

A small start towards getting the Mercury compiler to run on Mingw,
without Cygwin: add a `mercury.bat' batch file for invoking the Mercury
compiler.

Note that currently Cygwin is still required:
	(1) For `c2init' and `ml'.
	(2) For `mmake'.
	(3) For installation (`configure' and `make install').

There are work-arounds for some but not all of these:
	(1) XXX Currently there's no work-around for `c2init' and `ml'
	(2) `mmake' is not strictly necessary; you can always invoke the
	    necessary commands by hand.  This is of course tedious and
	    error-prone, so we might eventually include more of mmake's
	    functionality into the Mercury compiler itself.
	(3) This would be easy enough to avoid; if we're willing to hard-code
	    the installation path, we could easily package up the installation
	    in a WinZip file or something similar.

scripts/mercury.bat.in:
	New file.  This is a rewrite of scripts/mmc.in using Windows batch
	file commands rather than Bourne shell.
	Note that this is named mercury.bat.in rather than mmc.bat.in
	because on Windows 2000 the name `mmc' is used for the
	Microsoft Management Console.

configure.in:
bindist/bindist.configure.in:
	Generate scripts/mercury.bat.
	Also add a new autoconf variable WINDOWS_LIBDIR, which is like
	LIBDIR except in Windows path format rather than Cygwin (Unix)
	path format; this is used by scripts/mercury.bat.in.

scripts/Mmakefile:
	Add mercury.bat to the list of scripts to install.

Index: configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/configure.in,v
retrieving revision 1.247.4.5
diff -u -d -u -r1.247.4.5 configure.in
--- configure.in	2001/03/15 12:44:14	1.247.4.5
+++ configure.in	2001/04/19 03:57:46
@@ -54,10 +54,12 @@
 	PREFIX="$prefix"
 fi
 LIBDIR="$PREFIX/lib/mercury"
+WINDOWS_LIBDIR="`cygpath -w $LIBDIR 2>/dev/null`"
 NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared}
 AC_SUBST(PREFIX)
 AC_SUBST(NONSHARED_LIB_DIR)
 AC_SUBST(LIBDIR)
+AC_SUBST(WINDOWS_LIBDIR)
 DEFAULT_MERCURY_DEBUGGER_INIT_DIR=$LIBDIR/mdb
 AC_SUBST(DEFAULT_MERCURY_DEBUGGER_INIT_DIR)
 #-----------------------------------------------------------------------------#
@@ -2843,8 +2845,8 @@
     rm -f confscratch $to_delete
 fi
 #-----------------------------------------------------------------------------#
-AC_OUTPUT(Mmake.common scripts/Mmake.vars scripts/mmc scripts/mprof
-scripts/mercury_update_interface scripts/mgnuc scripts/ml
+AC_OUTPUT(Mmake.common scripts/Mmake.vars scripts/mmc scripts/mercury.bat
+scripts/mprof scripts/mercury_update_interface scripts/mgnuc scripts/ml
 scripts/mmake scripts/c2init scripts/mdb scripts/mdbrc 
 scripts/sicstus_conv scripts/mkfifo_using_mknod bindist/bindist.build_vars
 ,
Index: bindist/bindist.configure.in
===================================================================
RCS file: /home/mercury1/repository/mercury/bindist/bindist.configure.in,v
retrieving revision 1.30.4.1
diff -u -d -u -r1.30.4.1 bindist.configure.in
--- bindist/bindist.configure.in	2001/03/15 11:59:45	1.30.4.1
+++ bindist/bindist.configure.in	2001/04/19 03:57:46
@@ -20,10 +20,12 @@
 	PREFIX="$prefix"
 fi
 LIBDIR="$PREFIX/lib/mercury"
+WINDOWS_LIBDIR="`cygpath -w $LIBDIR 2>/dev/null`"
 NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=$PREFIX/lib/nonshared}
 AC_SUBST(PREFIX)
-AC_SUBST(NONSHARED_LIB_DIR)
 AC_SUBST(LIBDIR)
+AC_SUBST(WINDOWS_LIBDIR)
+AC_SUBST(NONSHARED_LIB_DIR)
 DEFAULT_MERCURY_DEBUGGER_INIT_DIR=$LIBDIR/mdb
 AC_SUBST(DEFAULT_MERCURY_DEBUGGER_INIT_DIR)
 
@@ -219,7 +221,7 @@
 #-----------------------------------------------------------------------------#
 MERCURY_CHECK_READLINE
 #-----------------------------------------------------------------------------#
-AC_OUTPUT(Makefile scripts/mmc scripts/mprof
+AC_OUTPUT(Makefile scripts/mmc scripts/mercury.bat scripts/mprof
 scripts/mercury_update_interface scripts/mgnuc scripts/ml
 scripts/mmake scripts/c2init scripts/sicstus_conv
 scripts/mkfifo_using_mknod scripts/Mmake.vars
Index: scripts/Mmakefile
===================================================================
RCS file: /home/mercury1/repository/mercury/scripts/Mmakefile,v
retrieving revision 1.21
diff -u -d -u -r1.21 Mmakefile
--- scripts/Mmakefile	2000/12/18 07:17:43	1.21
+++ scripts/Mmakefile	2001/04/19 03:57:46
@@ -16,7 +16,8 @@
 
 SCRIPTS = mmake mmc mdb c2init mgnuc ml mprof mprof_merge_runs \
 	  sicstus_conv mtags vpath_find mercury_update_interface \
-	  mkfifo_using_mknod mercury_cleanup_install canonical_grade
+	  mkfifo_using_mknod mercury_cleanup_install canonical_grade \
+	  mercury.bat
 DEBUGGER_SCRIPTS = mdbrc
 EMACS_SCRIPTS = gud.el
 
Index: scripts/mercury.bat.in
===================================================================
RCS file: mercury.bat.in
diff -N mercury.bat.in
--- /dev/null	Wed Apr 18 14:39:12 2001
+++ mercury.bat.in	Thu Apr 19 13:57:46 2001
@@ -0,0 +1,73 @@
+ at echo off
+rem @configure_input@
+rem ---------------------------------------------------------------------------
+rem Copyright (C) 1994-1998, 2000-2001 The University of Melbourne.
+rem This file may only be copied under the terms of the GNU General
+rem Public License - see the file COPYING in the Mercury distribution.
+rem ---------------------------------------------------------------------------
+rem
+rem mercury.bat - Melbourne Mercury Compiler.
+rem
+rem Use `mercury -h' for help.
+rem
+rem Environment variables: MERCURY_INT_DIR, MERCURY_C_INCL_DIR,
+rem MERCURY_ALL_MC_C_INCL_DIRS,
+rem MERCURY_COMPILER, MERCURY_C_COMPILER,
+rem MERCURY_DEFAULT_GRADE, MERCURY_DEFAULT_OPT_LEVEL.
+rem ---------------------------------------------------------------------------
+rem This is a Windows batch file version of the `mmc' Bourne shell script.
+rem The idea is to eventually avoid the need to use Cygwin.
+rem XXX Note that currently Cygwin is still required:
+rem     (1) For `c2init' and `ml'.
+rem	(2) For `mmake'.
+rem	(3) For installation (`configure' and `make install').
+rem There are work-arounds for some but not all of these:
+rem	(1) Currently there's no work-around for `c2init' and `ml'
+rem	(2) `mmake' is not strictly necessary; you can always invoke the
+rem	    necessary commands by hand.  This is of course tedious and
+rem	    error-prone, so we might eventually include more of mmake's
+rem	    functionality into the Mercury compiler itself.
+rem	(3) This would be easy enough to avoid; if we're willing to hard-code
+rem	    the installation path, we could easily package up the installation
+rem         in a WinZip file or something similar.
+rem ---------------------------------------------------------------------------
+
+set INTDIR=%MERCURY_INT_DIR%
+if "%INTDIR%"=="" set INTDIR=@WINDOWS_LIBDIR@\ints
+
+set MERC_C_INCL_DIR=%MERCURY_C_INCL_DIR%
+if "%MERC_C_INCL_DIR%"=="" set MERC_C_INCL_DIR=@WINDOWS_LIBDIR@\inc
+
+set MERC_ALL_MC_C_INCL_DIRS=%MERCURY_ALL_MC_C_INCL_DIRS%
+if "%MERC_ALL_MC_C_INCL_DIRS%"=="" set MERC_ALL_MC_C_INCL_DIRS=--c-include-directory "%MERC_C_INCL_DIR%"
+
+set MC=%MERCURY_COMPILER%
+if "%MC%"=="" set MC=@WINDOWS_LIBDIR@\bin\@FULLARCH@\mercury_compile
+
+set DEFAULT_GRADE=%MERCURY_DEFAULT_GRADE%
+if "%DEFAULT_GRADE%"=="" set DEFAULT_GRADE=@DEFAULT_GRADE@
+
+set CC=%MERCURY_C_COMPILER%
+if "%CC%"=="" set CC=@CC@
+
+set CFLAGS_FOR_REGS=@CFLAGS_FOR_REGS@
+set CFLAGS_FOR_GOTOS=@CFLAGS_FOR_GOTOS@
+set CFLAGS_FOR_THREADS=@CFLAGS_FOR_THREADS@
+set CFLAG_TO_NAME_OBJECT_FILE=@OBJFILE_OPT@
+set OBJECT_FILE_EXTENSION=@OBJ_SUFFIX@
+set LOW_TAG_BITS=@LOW_TAG_BITS@
+set BITS_PER_WORD=@BITS_PER_WORD@
+set BYTES_PER_WORD=@BYTES_PER_WORD@
+set NUM_REAL_R_REGS=@NUM_REAL_R_REGS@
+set NUM_REAL_R_TEMPS=@NUM_REAL_R_TEMPS@
+set HAVE_DELAY_SLOT=@HAVE_DELAY_SLOT@
+set HAVE_BOXED_FLOATS=@HAVE_BOXED_FLOATS@
+
+set DEFAULT_OPT_LEVEL=%MERCURY_DEFAULT_OPT_LEVEL%
+if "%DEFAULT_OPT_LEVEL%"=="" set DEFAULT_OPT_LEVEL=-O2
+
+rem The default optimization level should be after
+rem all the options that describe the machine configuration.
+
+echo on
+%MC% %MERC_ALL_MC_C_INCL_DIRS% --cc "%CC%" --grade "%DEFAULT_GRADE%" --cflags-for-threads "%CFLAGS_FOR_THREADS%" --cflags-for-regs "%CFLAGS_FOR_REGS%" --cflags-for-gotos "%CFLAGS_FOR_GOTOS%" --c-flag-to-name-object-file "%CFLAG_TO_NAME_OBJECT_FILE%" --object-file-extension "%OBJECT_FILE_EXTENSION%" --num-real-r-regs "%NUM_REAL_R_REGS%" --num-real-r-temps "%NUM_REAL_R_TEMPS%" --conf-low-tag-bits "%LOW_TAG_BITS%" --bits-per-word "%BITS_PER_WORD%" --bytes-per-word "%BYTES_PER_WORD%" %HAVE_DELAY_SLOT% %HAVE_BOXED_FLOATS% %DEFAULT_OPT_LEVEL% -I "%INTDIR%" %1 %2 %3 %4 %5 %6 %7 %8 %9

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list