Files
mercury/scripts/c2init.in
Fergus Henderson a6357c33bb Fix a small quoting bug in my previous change.
Estimated hours taken: 0.1

scripts/c2init.in:
	Fix a small quoting bug in my previous change.
1997-09-06 12:04:15 +00:00

82 lines
2.3 KiB
Bash
Executable File

#! /bin/sh
# @configure_input@
#---------------------------------------------------------------------------#
# Copyright (C) 1995-1997 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] modules ...
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.)
-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=""
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;;
-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 \
$MERCURY_MOD_LIB_MODS
;;
*) exec $MKINIT -w"$defentry" -c"$maxcalls" $library_opt \
"$@" $MERCURY_MOD_LIB_MODS
;;
esac