2006-02-04 00:57:04 +00:00
|
|
|
|
#!/bin/sh
|
2006-07-21 11:15:14 +00:00
|
|
|
|
# Prime Mover
|
|
|
|
|
#
|
|
|
|
|
# © 2006 David Given.
|
|
|
|
|
# Prime Mover is licensed under the MIT open source license. To get the full
|
|
|
|
|
# license text, run this file with the '--license' option.
|
|
|
|
|
#
|
|
|
|
|
# $Id: shell 10 2006-07-20 14:50:06Z dtrg $
|
|
|
|
|
|
2006-02-04 00:57:04 +00:00
|
|
|
|
THISFILE="$0"
|
|
|
|
|
CC=cc
|
|
|
|
|
PMEXEC=./.pm-exec-`arch`
|
|
|
|
|
set -e
|
|
|
|
|
|
2006-07-21 11:15:14 +00:00
|
|
|
|
GZFILE=/tmp/pm-$$.gz
|
|
|
|
|
CFILE=/tmp/pm-$$.c
|
|
|
|
|
trap "rm -f $GZFILE $CFILE" EXIT
|
|
|
|
|
|
2006-02-04 00:57:04 +00:00
|
|
|
|
extract_section() {
|
2006-07-21 11:15:14 +00:00
|
|
|
|
sed -e "1,/^XXXXSTART$1/d" "$THISFILE" | (
|
2006-02-04 00:57:04 +00:00
|
|
|
|
read size
|
|
|
|
|
dd bs=1 count=$size 2>/dev/null
|
2006-07-21 11:15:14 +00:00
|
|
|
|
) > $GZFILE
|
|
|
|
|
cat $GZFILE | zcat
|
2006-02-04 00:57:04 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If the bootstrap's built, run it.
|
|
|
|
|
|
|
|
|
|
if [ $PMEXEC -nt $0 ]; then
|
|
|
|
|
extract_section script | $PMEXEC /dev/stdin "$@"
|
|
|
|
|
exit $?
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# Otherwise, compile it and restart.
|
|
|
|
|
|
|
|
|
|
echo "pm: bootstrapping..."
|
|
|
|
|
|
|
|
|
|
extract_section interpreter > /tmp/pm-$$.c
|
|
|
|
|
$CC $CFILE -o $PMEXEC && exec "$THISFILE" "$@"
|
|
|
|
|
|
|
|
|
|
echo "pm: bootstrap failed."
|
|
|
|
|
exit 1
|
|
|
|
|
|
|
|
|
|
XXXXSTARTscript
|
2006-07-21 11:15:14 +00:00
|
|
|
|
10348
|
|
|
|
|
<1F> |