mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-16 18:03:36 +00:00
Estimated hours taken: 2 Fix some bugs which meant that building NU-Prolog or SICStus Prolog executables with MMAKE_USE_SUBDIRS set to `yes' did not work. scripts/mnc.in: scripts/msc.in: Add support for a `--use-subdirs' option. scripts/Mmake.rules: If MMAKE_USE_SUBDIRS=yes, then add `--use-subdirs' to $(MNCFLAGS) and $(MSCFLAGS). scripts/mnl.in: Add support for new environment variable MERCURY_NU_DEBUG_LIB_OBJS, for use by library/Mmakefile. library/Mmakefile: Fix places where .no and .ql files where hard-coded as being in the current directory instead of in $(nos_subdir) or $(qls_subdir).
85 lines
1.9 KiB
Bash
85 lines
1.9 KiB
Bash
#! /bin/sh
|
|
# @configure_input@
|
|
#---------------------------------------------------------------------------#
|
|
# Copyright (C) 1995-1996, 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.
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# MNC - Mercury NU-Prolog Compiler.
|
|
#
|
|
# Compiles Mercury programs to NU-Prolog object code (*.no).
|
|
#
|
|
# Usage: same as for `nc'.
|
|
#
|
|
# Environment variables: MERCURY_NC_BUILTIN
|
|
|
|
nc_builtin_nl=${MERCURY_NC_BUILTIN=@LIBDIR@/nuprolog/nc_builtin.nl}
|
|
|
|
options=
|
|
target=
|
|
use_subdirs=${MMAKE_USE_SUBDIRS=no}
|
|
|
|
while true; do
|
|
case "$1" in
|
|
--use-subdirs)
|
|
use_subdirs=yes
|
|
shift
|
|
;;
|
|
--no-use-subdirs)
|
|
use_subdirs=no
|
|
shift
|
|
;;
|
|
-F) options="$options $1 $2"
|
|
shift; shift
|
|
;;
|
|
-o) target="$2"
|
|
shift; shift
|
|
;;
|
|
-*) options="$options $1"
|
|
shift
|
|
;;
|
|
*) break 2
|
|
;;
|
|
esac
|
|
done
|
|
|
|
case "$use_subdirs" in
|
|
yes)
|
|
[ -d Mercury/nos ] || mkdir -p Mercury/nos
|
|
;;
|
|
esac
|
|
|
|
for file in "$@"; do
|
|
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/mnc$$
|
|
trap 'rm -f $tmp.nl $tmp.ns $tmp.no; exit 1' 1 2 3 13 15
|
|
cat "$nc_builtin_nl" > $tmp.nl
|
|
# as a special-case hack, if there is a .pp file we use it instead,
|
|
# after preprocessing away any #if NU_PROLOG commands in it
|
|
if [ -f "$rootname.pp" ]; then
|
|
echo "mnc: compiling \`$rootname.pp'"
|
|
sed -e '/^#if *NU_PROLOG/s/.*//' -e '/^#endif/s/.*//' \
|
|
"$rootname.pp" >> $tmp.nl
|
|
else
|
|
echo "mnc: compiling \`$file'"
|
|
cat "$file" >> $tmp.nl
|
|
fi
|
|
nc -c $options $tmp.nl
|
|
rm $tmp.nl $tmp.ns
|
|
case "$target" in
|
|
"") case "$use_subdirs" in
|
|
no) mv $tmp.no "$dir/$base.no" ;;
|
|
yes) mv $tmp.no "$dir/Mercury/nos/$base.no" ;;
|
|
esac
|
|
;;
|
|
*) mv $tmp.no "$target" ;;
|
|
esac
|
|
done
|