mirror of
https://github.com/Mercury-Language/mercury.git
synced 2026-04-17 02:13:54 +00:00
Estimated hours taken: 1 Fix a bug which caused link errors in some grades for some test cases where the module name wasn't the same as the file name, and which probably would have caused runtime errors in some grades for test cases using nested modules. compiler/modules.m: Call $(C2INIT) with $(foo.cs) instead of $(foo.ms). This is necessary now that a single .m file can get compiled to multiple .c files, if it contains nested modules, or to a .c file whose name reflects the module name rather than the source file name. util/mkinit.c: scripts/c2init.in: For efficiency, change c2init and mkinit so that when c2init's arguments are `.c' files, it computes the init function based on the filename (like it used to do with `.m' files), rather than by reading the file contents and searching for "** INIT" comments. Add a new option `-x' (`--extra-inits') which keeps the old behaviour. compiler/modules.m: scripts/Mmake.rules: Instead of deleting the `_init.c' file every time we recreate the `.dep' file, just tell make that the `_init.c' file depends on the `.dep' file, so that make will remake it if the `.dep' file changes. (I don't know why I didn't do it that way in the first place.)
93 lines
2.7 KiB
Bash
Executable File
93 lines
2.7 KiB
Bash
Executable File
#! /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.
|
|
#---------------------------------------------------------------------------#
|
|
|
|
# C2INIT - Convert *.c to *_init.c
|
|
#
|
|
# This script outputs an appropriate init.c, given the .c files.
|
|
# Type `c2init --help' for usage message.
|
|
#
|
|
|
|
# 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.
|
|
Help="\
|
|
Name: c2init - Create Mercury initialization file.
|
|
Usage: c2init [options] *.c *.init ...
|
|
Options:
|
|
-l, --library
|
|
Don't generate a \`main()' function.
|
|
Instead, generate a function
|
|
mercury_main(int argc, char **argv);
|
|
(declared in \"init.h\") that can be called from C code.
|
|
(A more fine-grained interface is also available;
|
|
see \"init.h\" for details.)
|
|
-x, --extra-inits
|
|
Search \`.c' files for extra initialization functions.
|
|
(This may be necessary if the C files contain
|
|
hand-coded C code with \`INIT' comments, rather than
|
|
containing only C code that was automatically generated
|
|
by the Mercury compiler.)
|
|
-c <n>, --max-calls <n>
|
|
Break up the initialization into groups of at most <n> function
|
|
calls. (Default value of <n> is 40.)
|
|
-w <label>, --entry-point <label>
|
|
Set entry point to <label>.
|
|
(Default value is \`mercury__main_2_0'.)
|
|
Environment variables:
|
|
MERCURY_MOD_LIB_DIR, MERCURY_MOD_LIB_MODS, MERCURY_MKINIT.
|
|
"
|
|
|
|
MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR=@LIBDIR@/modules}
|
|
MERCURY_MOD_LIB_MODS=${MERCURY_MOD_LIB_MODS="\
|
|
$MERCURY_MOD_LIB_DIR/libmercury.init\
|
|
$MERCURY_MOD_LIB_DIR/runtime.init\
|
|
"}
|
|
MKINIT=${MERCURY_MKINIT=mkinit}
|
|
|
|
# maximum number of calls to put in a single function
|
|
maxcalls=40
|
|
defentry=mercury__main_2_0
|
|
library_opt=""
|
|
extra_inits_opt=""
|
|
while true; do
|
|
case "$1" in
|
|
-c|--max-calls)
|
|
maxcalls="$2"; shift; shift;;
|
|
-w|--entry-point)
|
|
defentry="$2"; shift; shift;;
|
|
-l|--library)
|
|
library_opt="-l"; shift;;
|
|
-l-|--no-library)
|
|
library_opt=""; shift;;
|
|
-x|--extra-inits)
|
|
extra_inits_opt="-x"; shift;;
|
|
-x-|--no-extra-inits)
|
|
extra_inits_opt=""; shift;;
|
|
-h|--help|"-?")
|
|
echo "$Help"
|
|
exit 0;;
|
|
--)
|
|
shift; break;;
|
|
-*)
|
|
echo "`basename $0`: invalid option \`$1'" 1>&2;
|
|
echo "Try \`$0 --help' for help." 1>&2;
|
|
exit 1;;
|
|
*)
|
|
break;;
|
|
esac
|
|
done
|
|
|
|
case $# in
|
|
0) exec $MKINIT -w"$defentry" -c"$maxcalls" $library_opt \
|
|
$extra_inits_opt $MERCURY_MOD_LIB_MODS
|
|
;;
|
|
*) exec $MKINIT -w"$defentry" -c"$maxcalls" $library_opt \
|
|
$extra_inits_opt "$@" $MERCURY_MOD_LIB_MODS
|
|
;;
|
|
esac
|