Add template for HTML docs.
[tmk.git] / TMakefile
blobc3ea79f9a8468cd21c8e75558860df75ccbcdaf4
1 param CC gcc
2 param CFLAGS "-g -O2 -ansi -Wall -Wextra"
4 param JIM_CFLAGS [options { -D_GNU_SOURCE
5                             -Wall
6                             -I.
7                             -g
8                             -O2
9                             -fno-unwind-tables
10                             -fno-asynchronous-unwind-tables
11                           }]
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 \
16                       ]
18 param SQLITE_CFLAGS [options { -DSQLITE_OMIT_LOAD_EXTENSION=1
19                                -DSQLITE_THREADSAFE=0
20                                -DSQLITE_DEFAULT_FILE_FORMAT=4
21                                -DSQLITE_ENABLE_STAT3
22                                -DSQLITE_ENABLE_LOCKING_STYLE=0
23                                -DSQLITE_OMIT_INCRBLOB
24                              }]
26 param TCL "jimsh0"
27 param MAKE_C_EXT "make-c-ext.tcl"
28 param MAKE_LOAD_STATIC_EXTS "make-load-static-exts.tcl"
30 proc cc args {
31         global CC
33         exec $CC {*}$args
36 proc tclgen {script tclfile cfile} {
37         global TCL
39         set tcl ""
40         if {![file exists $TCL]} {
41                 set tcl "jimtcl/$TCL"
42         } else {
43                 set tcl "./$TCL"
44         }
46         set cmd $script
47         if {![file exists $script]} {
48                 set cmd "jimtcl/$script"
49         }
51         exec -flags @ echo "#define JIM_EMBEDDED" > $cfile
52         exec $tcl $cmd {*}$tclfile >> $cfile
55 rule all {tmk}
57 set JIM_CSRC {_load-static-exts.c jim-subcmd.c jim-interactive.c jim-format.c
58               jim.c utf8.c jimregexp.c jim-aio.c jim-array.c jim-clock.c
59               jim-exec.c jim-file.c jim-namespace.c jim-pack.c jim-package.c
60               jim-posix.c jim-readdir.c jim-regexp.c jim-signal.c
61               jim-tclprefix.c _binary.c _glob.c _nshelper.c _oo.c _stdlib.c
62               _tclcompat.c _tree.c}
64 set JIM_TCLSRC {binary.tcl glob.tcl nshelper.tcl oo.tcl stdlib.tcl
65                 tclcompat.tcl tree.tcl initjimsh.tcl}
67 set JIMSH_SRC {jimsh.c _initjimsh.c}
69 if {[defined NO_BUILD_JIMTCL]} {
70         rule jim {}
71 } else {
72         rule jim_bootstrap {[in-dir jimtcl/autosetup jimsh0.c]} {
73                 global JIM_CFLAGS
74                 cc -o jimtcl/jimsh0 $INPUTS 2>/dev/null
75         }
77         rule jim_exts {jim_bootstrap [in-dir jimtcl $JIM_TCLSRC]} {
78                 global JIM_TCLSRC MAKE_C_EXT
80                 cd jimtcl
81                 foreach tclfile $JIM_TCLSRC {
82                         tclgen $MAKE_C_EXT $tclfile _[replace-ext $tclfile .tcl .c]
83                 }
84                 cd ..
85         }
87         rule _load-static-exts.c {jim_exts} {
88                 global MAKE_LOAD_STATIC_EXTS JIM_STATIC_EXTS
89                 
90                 cd jimtcl
91                 tclgen $MAKE_LOAD_STATIC_EXTS $JIM_STATIC_EXTS _load-static-exts.c
92                 cd ..
93         }
95         rule jim_lib {jim_exts _load-static-exts.c [in-dir jimtcl $JIM_CSRC]} {
96                 global JIM_CSRC JIM_CFLAGS
98                 cd jimtcl
99                 foreach cfile $JIM_CSRC {
100                         cc {*}$JIM_CFLAGS -o [replace-ext $cfile .c .o] -c $cfile
101                 }
103                 exec ar cr libjim.a {*}[replace-ext $JIM_CSRC .c .o]
104                 exec ranlib libjim.a
106                 cd ..
107         }
109         rule jimsh {jim_lib [in-dir jimtcl $JIMSH_SRC]} {
110                 global JIMSH_SRC JIM_CFLAGS
112                 cd jimtcl
113                 cc {*}$JIM_CFLAGS -o $TARGET {*}$JIMSH_SRC libjim.a -lm
114                 cd ..
115         }
117         rule jim {jimsh}
120 rule sqlite3.o {[in-dir jimtcl/sqlite3 sqlite3.c]} {
121         global CC SQLITE_CFLAGS
122         cc -o $TARGET -c $INPUTS {*}$SQLITE_CFLAGS
126 set H_SRC "tmake.h tm_crypto.h tm_target.h tm_update.h tm_core_cmds.h tm_ext_cmds.h"
127 set C_SRC "tmake.c tm_crypto.c tm_target.c tm_update.c tm_core_cmds.c tm_ext_cmds.c"
129 rule tm_ext_cmds.c {tm_ext_cmds.tcl} {
130         global MAKE_C_EXT
131         tclgen $MAKE_C_EXT $INPUTS $TARGET
134 rule tmk {jim sqlite3.o $C_SRC $H_SRC} {
135         global C_SRC CFLAGS
137         set OPSYS [tcl::exec uname -s]
138         set ARCH  [tcl::exec uname -m]
140         cc {*}$CFLAGS -o $TARGET -Ijimtcl -Ijimtcl/sqlite3 \
141            -DTM_OPSYS="$OPSYS" -DTM_MACHINE_ARCH="$ARCH" \
142            {*}$C_SRC jimtcl/libjim.a sqlite3.o -lm
147 # ----------------------------------------------------------------------------
148 set DOCS {jimtcl/Tcl_shipped.html doc/refman.md}
150 rule doc-html {$DOCS template.html} {
151         file copy -force jimtcl/Tcl_shipped.html doc/Jim_Tcl.html
152         exec pandoc -S -s --toc --template=./doc/template.html \
153                -f markdown_github -t html -o doc/refman.html doc/refman.md
156 rule doc-pdf $DOCS {
157         exec pandoc -f html -t latex -o doc/Jim_Tcl.pdf jimtcl/Tcl_shipped.html
158         exec pandoc -S -s --toc \
159                 -f markdown_github -t latex -o doc/refman.pdf doc/refman.md
162 rule doc-all {doc-html doc-pdf}
164 #-----------------------------------------------------------------------------