mirror of
https://github.com/Mercury-Language/mercury.git
synced 2025-12-16 06:14:59 +00:00
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.
45 lines
914 B
Bash
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 "}";
|