mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Estimated hours taken: 3
Another --use-subdirs bug fix when using sicstus.
scripts/msl.in:
Detect the special case file 'sp_lib.ql' even when the file name has
leading directory info.
Also update the copyright notice.
157 lines
3.9 KiB
Bash
157 lines
3.9 KiB
Bash
#! /bin/sh
|
|
# @configure_input@
|
|
#---------------------------------------------------------------------------#
|
|
# Copyright (C) 1995-1998 The 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.
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# msl - Mercury SICStus Prolog Linker.
|
|
#
|
|
# Loads SICStus object files (*.ql) together with the Mercury library
|
|
# into the SICStus interpreter, and then saves the state to produce an
|
|
# executable binary.
|
|
#
|
|
# Usage: msl [<options>] files...
|
|
# Options:
|
|
# -v, --verbose
|
|
# -d, --debug
|
|
# -o, --output
|
|
# Environment variables:
|
|
# MERCURY_SP_LIB_DIR
|
|
# the name of the directory containing the object files
|
|
# MERCURY_SP_LIB_OBJS
|
|
# the names of the object files
|
|
# MERCURY_SP_OVERRIDING_LIB_OBJS
|
|
# the names of the object files that contain definitions which
|
|
# should override others
|
|
|
|
SPLIBDIR=${MERCURY_SP_LIB_DIR=@LIBDIR@/sicstus/@FULLARCH@}
|
|
SP=${MERCURY_SICSTUS_PROLOG=$SPLIBDIR/library.sicstus.debug}
|
|
LIBRARY_OBJS=${MERCURY_SP_LIB_OBJS=""}
|
|
OVERRIDING_LIBRARY_OBJS=${MERCURY_SP_OVERRIDING_LIB_OBJS=""}
|
|
|
|
verbose=false
|
|
debug=false
|
|
save_temp=false
|
|
target=a.out
|
|
|
|
while : ; do
|
|
case "$1" in
|
|
-v|--verbose)
|
|
verbose=true
|
|
shift
|
|
;;
|
|
-d|--debug)
|
|
debug=true
|
|
shift
|
|
;;
|
|
-o|--output)
|
|
target=$2
|
|
shift; shift
|
|
;;
|
|
-s|--save-temp)
|
|
save_temp=true
|
|
shift
|
|
;;
|
|
-*)
|
|
echo "$0: invalid option \`$1'" 1>&2
|
|
exit 1
|
|
;;
|
|
*) break 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
objlist=
|
|
for obj in $LIBRARY_OBJS 'kludge for broken shells'; do
|
|
if [ "$obj" = 'kludge for broken shells' ]; then
|
|
true
|
|
elif [ `basename $obj` = "sp_lib.ql" ]; then
|
|
sp_lib=$SPLIBDIR/$obj
|
|
elif echo "" "$objlist" "$@" "" | grep " $obj " > /dev/null; then
|
|
true
|
|
else
|
|
objlist="$objlist $SPLIBDIR/$obj"
|
|
fi
|
|
done
|
|
|
|
overriding_objlist=
|
|
for obj in $OVERRIDING_LIBRARY_OBJS 'kludge for broken shells'; do
|
|
if [ "$obj" = 'kludge for broken shells' ]; then
|
|
true
|
|
else
|
|
overriding_objlist="$overriding_objlist $SPLIBDIR/$obj"
|
|
fi
|
|
done
|
|
|
|
if $verbose; then
|
|
echo Linking $objlist "$@" $overriding_objlist $sp_lib
|
|
fi
|
|
if $save_temp; then
|
|
tmp=msl.tmp
|
|
else
|
|
tmp=/tmp/msl$$
|
|
trap 'rm -f $tmp; exit 1' 1 2 3 13 15
|
|
trap 'rm -f $tmp; exit 0' 0
|
|
fi
|
|
if $debug; then
|
|
cat > $tmp << EOF
|
|
assert((mercury_do_save :-
|
|
on_exception(Error, (
|
|
( prolog_flag(compiling, _, fastcode) -> true ; true ),
|
|
% if we're running SICStus version 3, then we need to
|
|
% disable character escapes (since the sed script in
|
|
% msc assumes that SICStus doesn't have them)
|
|
( prolog_flag(argv, _) ->
|
|
prolog_flag(character_escapes, _, off)
|
|
;
|
|
true
|
|
),
|
|
( prolog_flag(argv, Files) -> true ; unix(argv(Files)) ),
|
|
load(Files),
|
|
abolish(mercury_do_save),
|
|
garbage_collect,
|
|
save('$target', _),
|
|
version
|
|
), (print_message(error, Error), halt)))).
|
|
|
|
mercury_do_save.
|
|
|
|
EOF
|
|
case $# in
|
|
0) $SP $objlist $overriding_objlist $sp_lib < $tmp 2>&1 ;;
|
|
*) $SP $objlist "$@" $overriding_objlist $sp_lib < $tmp 2>&1 ;;
|
|
esac
|
|
else
|
|
cat > $tmp << EOF
|
|
on_exception(Error, (
|
|
( prolog_flag(compiling, _, fastcode) -> true ; true ),
|
|
% if we're running SICStus version 3, then we need to
|
|
% disable character escapes (since the sed script in
|
|
% msc assumes that SICStus doesn't have them)
|
|
( prolog_flag(argv, _) ->
|
|
prolog_flag(character_escapes, _, off)
|
|
;
|
|
true
|
|
),
|
|
( prolog_flag(argv, Files) -> true ; unix(argv(Files)) ),
|
|
load(Files),
|
|
garbage_collect,
|
|
save('$target', 1),
|
|
( prolog_flag(argv, Args) -> true ; unix(argv(Args)) ),
|
|
run([mmc|Args])
|
|
), print_message(error, Error)), halt ; halt.
|
|
e
|
|
e
|
|
e
|
|
e
|
|
EOF
|
|
case $# in
|
|
0) $SP $objlist $overriding_objlist $sp_lib < $tmp 2>&1 ;;
|
|
*) $SP $objlist "$@" $overriding_objlist $sp_lib < $tmp 2>&1 ;;
|
|
esac
|
|
fi # grep -v 'DOMAIN ERROR.*when_condition'
|
|
# We pipe the output through grep -v to suppress some spurious warnings
|
|
# caused by the NU-Prolog when declarations not matching Sicstus syntax.
|