Files
mercury/scripts/mod2init.sh
Fergus Henderson 7e5d4c2d89 Moved these scripts from the code directory to the scripts directory.
mgnuc.sh mod2c mod2init.sh:
	Moved these scripts from the code directory to the scripts directory.
	Changed mgnuc to use the MERCURY_C_INCL_DIR environment variable.
	Changed mod2init to use MERCURY_MOD_LIB_DIR and MERCURY_MOD_LIB_MODS.
	Changed ml to use MERCURY_C_LIB_DIR rather than MERCURY_CLIB_DIR.
1995-02-02 05:57:16 +00:00

45 lines
914 B
Bash

#!/bin/sh
# This script outputs an appropriate init.c, given the .mod files.
MERCURY_MOD_LIB_DIR=${MERCURY_MOD_LIB_DIR:-@LIBDIR@/modules}
MERCURY_MOD_LIB_MODS=${MERCURY_MOD_LIB_MODS:-@LIBDIR@/modules}
defentry=NULL
while getopts w: c
do
case $c in
w) defentry="\"$OPTARG\"";;
\?) echo "Usage: mod2init -[wentry] modules ..."
exit 1;;
esac
shift `expr $OPTIND - 1`
done
files="$*"
for file in
modules="`sed -n '/^BEGIN_MODULE(\(.*\)).*$/s//\1/p' $*`"
echo "/*";
echo "** This code was automatically generated by mod2init.";
echo "** Do not edit.";
echo "**"
echo "** Input files:"
echo "** $*"
echo "*/";
echo "";
echo '#include <stddef.h>';
echo '#include "init.h"';
echo "";
echo "const char *default_entry = $defentry;";
echo "";
for mod in $modules; do
echo "extern void $mod(void);";
done
echo "";
echo "void init_modules(void)";
echo "{";
for mod in $modules; do
echo " $mod();";
done
echo "}";