appveyor.yml: update OpenSSL DLL paths
[jimtcl.git] / make-bootstrap-jim
blob7484b11f981df67717f93efd01b909055a72fdaa
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 regexp file glob exec clock array stdlib tclcompat"
49 echo "/* This is single source file, bootstrap version of Jim Tcl. See http://jim.tcl.tk/ */"
51 # define some core features
52 for i in JIM_TCL_COMPAT 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 cat <<EOF
62 #if defined(_MSC_VER)
63 #define TCL_PLATFORM_OS "windows"
64 #define TCL_PLATFORM_PLATFORM "windows"
65 #define TCL_PLATFORM_PATH_SEPARATOR ";"
66 #define HAVE_MKDIR_ONE_ARG
67 #define HAVE_SYSTEM
68 #elif defined(__MINGW32__)
69 #define TCL_PLATFORM_OS "mingw"
70 #define TCL_PLATFORM_PLATFORM "windows"
71 #define TCL_PLATFORM_PATH_SEPARATOR ";"
72 #define HAVE_MKDIR_ONE_ARG
73 #define HAVE_SYSTEM
74 #define HAVE_SYS_TIME_H
75 #define HAVE_DIRENT_H
76 #define HAVE_UNISTD_H
77 #define HAVE_UMASK
78 #include <sys/stat.h>
79 #ifndef S_IRWXG
80 #define S_IRWXG 0
81 #endif
82 #ifndef S_IRWXO
83 #define S_IRWXO 0
84 #endif
85 #else
86 #define TCL_PLATFORM_OS "unknown"
87 #define TCL_PLATFORM_PLATFORM "unix"
88 #define TCL_PLATFORM_PATH_SEPARATOR ":"
89 #ifdef _MINIX
90 #define vfork fork
91 #define _POSIX_SOURCE
92 #else
93 #define _GNU_SOURCE
94 #endif
95 #define HAVE_VFORK
96 #define HAVE_WAITPID
97 #define HAVE_ISATTY
98 #define HAVE_MKSTEMP
99 #define HAVE_LINK
100 #define HAVE_SYS_TIME_H
101 #define HAVE_DIRENT_H
102 #define HAVE_UNISTD_H
103 #define HAVE_UMASK
104 #endif
107 # get JIM_VERSION from auto.def
108 sed -n -e 's/^\(define JIM_VERSION.*\)/#\1/p' auto.def
110 outputsource()
112 sed -e '/#include.*jim/d' -e '/#include.*utf8/d' \
113 -e '/^#.*if.*JIM_BOOTSTRAP/,/^#endif.*JIM_BOOTSTRAP/d' \
114 -e 's/[ ]*\/\*.*\*\///' -e '/^[ ]*\/\*/,/\*\//d' $1
117 # Now output header files, removing references to jim header files
118 for i in jim-win32compat.h utf8.h jim.h jim-subcmd.h jimregexp.h jim-signal.h jimiocompat.h; do
119 outputsource $i
120 done
122 # Now extension source code
123 for i in $tclexts; do
124 makeext $i.tcl
125 done
126 for i in $cexts; do
127 outputsource jim-$i.c
128 done
129 makeloadexts $allexts
131 # And finally the core source code
132 for i in jim.c jim-subcmd.c utf8.c jim-format.c jimregexp.c jimiocompat.c jim-win32compat.c jim-nosignal.c; do
133 outputsource $i
134 done
135 echo "#ifndef JIM_BOOTSTRAP_LIB_ONLY"
136 outputsource jim-interactive.c
137 outputsource jimsh.c
138 echo "#endif"