Correct PPTP server firewall rules chain.
[tomato/davidwu.git] / release / src / router / usbmodeswitch / jim / make-bootstrap-jim
blobcc2cd5d9324492d3579cd8a99cdfeb2988202709
1 #!/bin/sh
3 # This script writes to stdout, a single source file (e.g. jimsh0.c)
4 # which can be compiled to provide a bootstrap version of jimsh.
5 # e.g. cc -o jimsh0 jimsh0.c
7 makeext()
9 source="$1"
10 basename=`basename "$source" .tcl`
11 cat <<EOF
12 int Jim_${basename}Init(Jim_Interp *interp)
14 if (Jim_PackageProvide(interp, "$basename", "1.0", JIM_ERRMSG))
15 return JIM_ERR;
17 return Jim_EvalSource(interp, "$source", 1,
18 EOF
20 # Note: Keep newlines so that line numbers match in error messages
21 sed -e 's/^[ ]*#.*//' -e 's@\\@\\\\@g' -e 's@"@\\"@g' -e 's@^\(.*\)$@"\1\\n"@' $source
23 echo ");"
24 echo "}"
27 makeloadexts()
29 cat <<EOF
30 int Jim_InitStaticExtensions(Jim_Interp *interp)
31 EOF
32 echo "{"
33 for ext in $*; do
34 echo "extern int Jim_${ext}Init(Jim_Interp *);"
35 done
36 for ext in $*; do
37 echo "Jim_${ext}Init(interp);"
38 done
39 echo "return JIM_OK;"
40 echo "}"
43 cexts="aio readdir regexp file exec clock array"
44 tclexts="bootstrap initjimsh glob stdlib tclcompat"
46 # Note ordering
47 allexts="bootstrap aio readdir glob regexp file exec clock array stdlib tclcompat"
49 echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.berlios.de/ */"
51 # define some core features
52 for i in _GNU_SOURCE JIM_TCL_COMPAT JIM_REFERENCES JIM_ANSIC JIM_REGEXP HAVE_NO_AUTOCONF _JIMAUTOCONF_H; do
53 echo "#define $i"
54 done
55 echo '#define TCL_LIBRARY "."'
56 # and extensions
57 for i in $allexts; do
58 echo "#define jim_ext_$i"
59 done
61 # Can we make a bootstrap jimsh work even on mingw32?
62 cat <<EOF
63 #if defined(__MINGW32__)
64 #define TCL_PLATFORM_OS "mingw"
65 #define TCL_PLATFORM_PLATFORM "windows"
66 #define TCL_PLATFORM_PATH_SEPARATOR ";"
67 #define HAVE_MKDIR_ONE_ARG
68 #define HAVE_SYSTEM
69 #define WIN32_LEAN_AND_MEAN
70 #include <windows.h>
71 #else
72 #define TCL_PLATFORM_OS "unknown"
73 #define TCL_PLATFORM_PLATFORM "unix"
74 #define TCL_PLATFORM_PATH_SEPARATOR ":"
75 #define HAVE_VFORK
76 #define HAVE_WAITPID
77 #endif
78 EOF
80 outputsource()
82 sed -e '/#include.*jim/d' -e '/#include.*utf8/d' \
83 -e '/^#.*if.*JIM_BOOTSTRAP/,/^#endif.*JIM_BOOTSTRAP/d' \
84 -e 's/\/\*.*\*\///' -e '/^[ ]*\/\*/,/\*\//d' $1
87 # Now output header files, removing references to jim header files
88 for i in utf8.h jim.h jim-subcmd.h jimregexp.h ; do
89 outputsource $i
90 done
92 # Now extension source code
93 for i in $tclexts; do
94 makeext $i.tcl
95 done
96 for i in $cexts; do
97 outputsource jim-$i.c
98 done
99 makeloadexts $allexts
101 # And finally the core source code
102 for i in jim.c jim-subcmd.c utf8.c jim-interactive.c jim-format.c jimregexp.c jimsh.c; do
103 outputsource $i
104 done