Files
mercury/scripts/msc.in
Fergus Henderson 8ce103cc76 Add Unix-style man pages for most of the Mercury development tools.
scripts/c2init.in:
scripts/mmake.in:
scripts/msc.in:
	Small changes to the help messages to make them come out
	better when converted to man pages.

scripts/mgnuc.in:
	Add a `--help' option.
1997-02-07 14:17:41 +00:00

112 lines
2.6 KiB
Bash
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#! /bin/sh
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 1995 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.
#---------------------------------------------------------------------------#
# MSC - Mercury SICStus Compiler.
#
# Compiles Mercury programs to SICStus Prolog object code (*.ql).
#
# Use `msc -h' for help.
sicstus_compile=\
${MERCURY_SICSTUS_COMPILER=@LIBDIR@/sicstus/@FULLARCH@/sicstus_compile}
help=false
compile_mode=compactcode
target=
while true; do
case "$1" in
-h|--help)
help=true
break
;;
-o|--output)
target="$2"
shift; shift
;;
-m|--mode)
compile_mode="$2"
shift; shift
;;
--)
shift
break
;;
-*)
echo "$0: unrecognized option \`$1'" 1>&2
exit 1
;;
*)
break
;;
esac
done
if [ $# -lt 1 ] || $help; then
# IMPORTANT: the manpage is produced automatically from this help
# message, so if you change the help message, don't forget to check
# that the manpage still looks OK.
cat << 'EOF'
Name: msc - Mercury SICStus Compiler.
Compiles Mercury programs to SICStus Prolog object code (*.ql).
Usage: msc [<options>] file(s)
Options:
-h, --help
Print this help message
-o <target>, --output <target>
Name the output file <target>.
-m <compile-mode>, --mode <compile-mode>
Use the specified mode of compilation.
<compile-mode> should be either compactcode, fastcode,
or profiledcode.
Environment variables: MERCURY_SICSTUS_COMPILER
EOF
exit 0
fi
for file in "$@"; do
echo "msc: compiling \`$file'"
dir="`dirname $file`"
case $file in
*.m) base="`basename $file .m`" ;;
*.nl) base="`basename $file .nl`" ;;
*) base="`basename $file`" ;;
esac
rootname="$dir/$base"
tmp=/tmp/msc$$
trap 'rm -f $tmp.pl $tmp.ql; exit 1' 1 2 3 13 15
# This sed script is used to convert from Mercury/NU-Prolog to Sicstus Prolog
# It does three things: delete the `:- module' line,
# expand backslash escapes, and replace the use
# of `^' for xor in calls to is/2 with `#'.
# It also removes '%' comments, to avoid problems with quotes in them.
# Obviously this is not the most robust method of translation imaginable!
sed '
/ is /s/\^/#/g
/^:- *module/d
/^[ ]*%/s/.*//
/\\\\/s//\\/g
/\\a/s///g
/\\b/s///g
/\\r/s//
/g
/\\f/s// /g
/\\t/s// /g
/\\n/s//\
/g
/\\v/s// /g
' $file > $tmp.pl
$sicstus_compile $compile_mode $tmp.pl
rm $tmp.pl
case "$target" in
"") mv $tmp.ql "$rootname.ql" ;;
*) mv $tmp.ql "$target" ;;
esac
done