105 lines
2.5 KiB
Bash
Executable File
105 lines
2.5 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# This script writes to stdout, a single source file (e.g. jimsh0.c)
|
|
# which can be compiled to provide a bootstrap version of jimsh.
|
|
# e.g. cc -o jimsh0 jimsh0.c
|
|
|
|
makeext()
|
|
{
|
|
source="$1"
|
|
basename=`basename "$source" .tcl`
|
|
cat <<EOF
|
|
int Jim_${basename}Init(Jim_Interp *interp)
|
|
{
|
|
if (Jim_PackageProvide(interp, "$basename", "1.0", JIM_ERRMSG))
|
|
return JIM_ERR;
|
|
|
|
return Jim_EvalSource(interp, "$source", 1,
|
|
EOF
|
|
|
|
# Note: Keep newlines so that line numbers match in error messages
|
|
sed -e 's/^[ ]*#.*//' -e 's@\\@\\\\@g' -e 's@"@\\"@g' -e 's@^\(.*\)$@"\1\\n"@' $source
|
|
|
|
echo ");"
|
|
echo "}"
|
|
}
|
|
|
|
makeloadexts()
|
|
{
|
|
cat <<EOF
|
|
int Jim_InitStaticExtensions(Jim_Interp *interp)
|
|
EOF
|
|
echo "{"
|
|
for ext in $*; do
|
|
echo "extern int Jim_${ext}Init(Jim_Interp *);"
|
|
done
|
|
for ext in $*; do
|
|
echo "Jim_${ext}Init(interp);"
|
|
done
|
|
echo "return JIM_OK;"
|
|
echo "}"
|
|
}
|
|
|
|
cexts="aio readdir regexp file exec clock array"
|
|
tclexts="bootstrap initjimsh glob stdlib tclcompat"
|
|
|
|
# Note ordering
|
|
allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompat"
|
|
|
|
echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.berlios.de/ */"
|
|
|
|
# define some core features
|
|
for i in _GNU_SOURCE JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do
|
|
echo "#define $i"
|
|
done
|
|
echo '#define TCL_LIBRARY "."'
|
|
# and extensions
|
|
for i in $allexts; do
|
|
echo "#define jim_ext_$i"
|
|
done
|
|
|
|
# Can we make a bootstrap jimsh work even on mingw32?
|
|
cat <<EOF
|
|
#if defined(__MINGW32__)
|
|
#define TCL_PLATFORM_OS "mingw"
|
|
#define TCL_PLATFORM_PLATFORM "windows"
|
|
#define TCL_PLATFORM_PATH_SEPARATOR ";"
|
|
#define HAVE_MKDIR_ONE_ARG
|
|
#define HAVE_SYSTEM
|
|
#define WIN32_LEAN_AND_MEAN
|
|
#include <windows.h>
|
|
#else
|
|
#define TCL_PLATFORM_OS "unknown"
|
|
#define TCL_PLATFORM_PLATFORM "unix"
|
|
#define TCL_PLATFORM_PATH_SEPARATOR ":"
|
|
#define HAVE_VFORK
|
|
#define HAVE_WAITPID
|
|
#endif
|
|
EOF
|
|
|
|
outputsource()
|
|
{
|
|
sed -e '/#include.*jim/d' -e '/#include.*utf8/d' \
|
|
-e '/^#.*if.*JIM_BOOTSTRAP/,/^#endif.*JIM_BOOTSTRAP/d' \
|
|
-e 's/\/\*.*\*\///' -e '/^[ ]*\/\*/,/\*\//d' $1
|
|
}
|
|
|
|
# Now output header files, removing references to jim header files
|
|
for i in utf8.h jim.h jim-subcmd.h jimregexp.h ; do
|
|
outputsource $i
|
|
done
|
|
|
|
# Now extension source code
|
|
for i in $tclexts; do
|
|
makeext $i.tcl
|
|
done
|
|
for i in $cexts; do
|
|
outputsource jim-$i.c
|
|
done
|
|
makeloadexts $allexts
|
|
|
|
# And finally the core source code
|
|
for i in jim.c jim-subcmd.c utf8.c jim-interactive.c jim-format.c jimregexp.c jimsh.c; do
|
|
outputsource $i
|
|
done
|