2 param CFLAGS "-g -O2 -ansi -Wall -Wextra"
4 param JIM_CFLAGS [options { -D_GNU_SOURCE
10 -fno-asynchronous-unwind-tables
13 param JIM_STATIC_EXTS [list aio array clock exec file namespace pack \
14 package posix readdir regexp signal tclprefix \
15 binary glob nshelper oo stdlib tclcompat tree \
18 param SQLITE_CFLAGS [options { -DSQLITE_OMIT_LOAD_EXTENSION=1
20 -DSQLITE_DEFAULT_FILE_FORMAT=4
22 -DSQLITE_ENABLE_LOCKING_STYLE=0
23 -DSQLITE_OMIT_INCRBLOB
27 param MAKE_C_EXT "make-c-ext.tcl"
28 param MAKE_LOAD_STATIC_EXTS "make-load-static-exts.tcl"
30 param PREFIX "/usr/local"
39 proc tclgen {script tclfile cfile} {
43 if {![file exists $TCL]} {
50 if {![file exists $script]} {
51 set cmd "jimtcl/$script"
54 exec -flags @ echo "#define JIM_EMBEDDED" > $cfile
55 exec $tcl $cmd {*}$tclfile >> $cfile
60 set JIM_CSRC {_load-static-exts.c jim-subcmd.c jim-interactive.c jim-format.c
61 jim.c utf8.c jimregexp.c jim-aio.c jim-array.c jim-clock.c
62 jim-exec.c jim-file.c jim-namespace.c jim-pack.c jim-package.c
63 jim-posix.c jim-readdir.c jim-regexp.c jim-signal.c
64 jim-tclprefix.c _binary.c _glob.c _nshelper.c _oo.c _stdlib.c
67 set JIM_TCLSRC {binary.tcl glob.tcl nshelper.tcl oo.tcl stdlib.tcl
68 tclcompat.tcl tree.tcl initjimsh.tcl}
70 set JIMSH_SRC {jimsh.c _initjimsh.c}
72 if {[defined NO_BUILD_JIMTCL]} {
75 rule jim_bootstrap {[in-dir jimtcl/autosetup jimsh0.c]} {
77 cc -o jimtcl/jimsh0 $INPUTS 2>/dev/null
80 rule jim_exts {jim_bootstrap [in-dir jimtcl $JIM_TCLSRC]} {
81 global JIM_TCLSRC MAKE_C_EXT
84 foreach tclfile $JIM_TCLSRC {
85 tclgen $MAKE_C_EXT $tclfile _[replace-ext $tclfile .tcl .c]
90 rule _load-static-exts.c {jim_exts} {
91 global MAKE_LOAD_STATIC_EXTS JIM_STATIC_EXTS
94 tclgen $MAKE_LOAD_STATIC_EXTS $JIM_STATIC_EXTS _load-static-exts.c
98 rule jim_lib {jim_exts _load-static-exts.c [in-dir jimtcl $JIM_CSRC]} {
99 global JIM_CSRC JIM_CFLAGS
102 foreach cfile $JIM_CSRC {
103 cc {*}$JIM_CFLAGS -o [replace-ext $cfile .c .o] -c $cfile
106 exec ar cr libjim.a {*}[replace-ext $JIM_CSRC .c .o]
112 rule jimsh {jim_lib [in-dir jimtcl $JIMSH_SRC]} {
113 global JIMSH_SRC JIM_CFLAGS
116 cc {*}$JIM_CFLAGS -o $TARGET {*}$JIMSH_SRC libjim.a -lm
123 rule sqlite3.o {[in-dir jimtcl/sqlite3 sqlite3.c]} {
124 global CC SQLITE_CFLAGS
125 cc -o $TARGET -c $INPUTS {*}$SQLITE_CFLAGS
128 rule config.h {[glob build/checks/*.c]} {
129 foreach i [glob build/checks/*.c] {
130 cc -o [file rootname $i] $i
133 set TM_WORD [tcl::exec build/checks/wordsize]
135 tcl::exec echo "typedef $TM_WORD WORD;" > config.h
139 set H_SRC "tmake.h tm_crypto.h tm_target.h tm_update.h tm_core_cmds.h tm_ext_cmds.h"
140 set C_SRC "tmake.c tm_crypto.c tm_target.c tm_update.c tm_core_cmds.c tm_ext_cmds.c"
142 rule tm_ext_cmds.c {tm_ext_cmds.tcl} {
144 tclgen $MAKE_C_EXT $INPUTS $TARGET
147 rule tmk {config.h jim sqlite3.o $C_SRC $H_SRC} {
150 set OPSYS [tcl::exec uname -s]
151 set ARCH [tcl::exec uname -m]
153 cc {*}$CFLAGS -o $TARGET -Ijimtcl -Ijimtcl/sqlite3 \
154 -DTM_OPSYS="$OPSYS" -DTM_MACHINE_ARCH="$ARCH" \
155 {*}$C_SRC jimtcl/libjim.a sqlite3.o -lm
161 global PREFIX DESTDIR
162 param BINDIR "$PREFIX/bin"
163 #param LIBDIR "$PREFIX/lib"
164 param MANDIR "$PREFIX/share/man"
166 file mkdir "$DESTDIR/$BINDIR"
167 #file mkdir "$DESTDIR/$LIBDIR"
168 file mkdir "$DESTDIR/$MANDIR/man1"
170 exec install -m 755 tmk "$DESTDIR/$BINDIR"
171 exec install -m 644 doc/tmk.1 "$DESTDIR/$MANDIR/man1"
175 # ----------------------------------------------------------------------------
176 set DOCS {jimtcl/Tcl_shipped.html doc/refman.md}
178 rule doc-html {$DOCS doc/template.html} {
179 file copy -force jimtcl/Tcl_shipped.html doc/Jim_Tcl.html
180 exec pandoc -S -s --toc --template=./doc/template.html \
181 -f markdown_github -t html -o doc/refman.html doc/refman.md
185 exec pandoc -f html -t latex -o doc/Jim_Tcl.pdf jimtcl/Tcl_shipped.html
186 exec pandoc -S -s --toc \
187 -f markdown_github -t latex -o doc/refman.pdf doc/refman.md
190 rule doc-all {doc-html doc-pdf}
192 rule install-doc {doc-all} {
193 global PREFIX DESTDIR
194 param DOCDIR "$PREFIX/share/doc/tmk"
196 file mkdir "$DESTDIR/$DOCDIR"
198 exec install -m 644 doc/*.html "$DESTDIR/$DOCDIR"
199 exec install -m 644 doc/*.pdf "$DESTDIR/$DOCDIR"
202 #-----------------------------------------------------------------------------