Improve performance of script validation commit
[jimtcl.git] / auto.def
blob8ffc98d8bd9137bc63201273bf474a867c5e18b9
1 # vim:se syn=tcl:
4 define JIM_VERSION 75
6 # Note: modules which support options *must* be included before 'options'
7 use cc cc-shared cc-db cc-lib
8 use local
10 options {
11 utf8 => "include support for utf8-encoded strings"
12 lineedit=1 => "disable line editing"
13 references=1 => "disable support for references"
14 math => "include support for math functions"
15 ipv6 => "include ipv6 support in the aio extension"
16 maintainer => {enable the [debug] command and JimPanic}
17 full => "Enable some optional features: ipv6, math, utf8, binary, oo, tree"
18 with-jim-shared shared => "build a shared library instead of a static library"
19 jim-regexp=1 => "prefer POSIX regex if over the the built-in (Tcl-compatible) regex"
20 docs=1 => "don't build or install the documentation"
21 random-hash => "randomise hash tables. more secure but hash table results are not predicable"
22 with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
23 Specify additional jim extensions to include.
24 These are enabled by default:
26 aio - ANSI I/O, including open and socket
27 eventloop - after, vwait, update
28 array - Tcl-compatible array command
29 clock - Tcl-compatible clock command
30 exec - Tcl-compatible exec command
31 file - Tcl-compatible file command
32 glob - Tcl-compatible glob command
33 history - Tcl access to interactive history
34 readdir - Required for glob
35 package - Package management with the package command
36 load - Load binary extensions at runtime with load or package
37 posix - Posix APIs including os.fork, os.wait, pid
38 regexp - Tcl-compatible regexp, regsub commands
39 signal - Signal handling
40 stdlib - Built-in commands including lassign, lambda, alias
41 syslog - System logging with syslog
42 tclcompat - Tcl compatible read, gets, puts, parray, case, ...
43 namespace - Tcl compatible namespace support
45 These are disabled by default:
47 oo - Jim OO extension
48 tree - OO tree structure, similar to tcllib ::struct::tree
49 binary - Tcl-compatible 'binary' command
50 readline - Interface to libreadline
51 rlprompt - Tcl wrapper around the readline extension
52 mk - Interface to Metakit
53 tclprefix - Support for the tcl::prefix command
54 sqlite3 - Interface to sqlite3
55 win32 - Interface to win32
57 with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
58 Specify jim extensions to exclude.
59 If 'default' is given, the default extensions will not be added.
61 with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
62 Specify jim extensions to build as separate modules (either C or Tcl).
63 Note that not all extensions can be built as loadable modules.
65 # To help out openocd with automake
66 install-jim=1
69 # Save the user-specified LIBS
70 # We add detected libs to LDLIBS explicitly
71 set LIBS [get-define LIBS]
73 cc-check-types "long long"
75 define CCOPTS ""
76 define CXXOPTS ""
77 if {[cctest -cflags -fno-unwind-tables]} {
78 define-append CCOPTS -fno-unwind-tables
80 if {[cctest -cflags -fno-asynchronous-unwind-tables]} {
81 define-append CCOPTS -fno-asynchronous-unwind-tables
84 cc-check-includes sys/time.h sys/socket.h netinet/in.h arpa/inet.h netdb.h
85 cc-check-includes sys/un.h dlfcn.h unistd.h dirent.h crt_externs.h
87 define LDLIBS ""
89 # Haiku needs -lnetwork, Solaris needs -lnsl
90 if {[cc-check-function-in-lib inet_ntop {nsl network}]} {
91 # This does nothing if no libs are needed
92 cc-with [list -libs [get-define lib_inet_ntop]]
93 define-append LDLIBS [get-define lib_inet_ntop]
95 # Solaris needs -lsocket, Windows needs -lwsock32
96 if {[cc-check-function-in-lib socket socket]} {
97 define-append LDLIBS [get-define lib_socket]
100 cc-check-functions ualarm lstat fork vfork system select execvpe
101 cc-check-functions backtrace geteuid mkstemp realpath strptime isatty
102 cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
103 cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
104 cc-check-functions shutdown socketpair isinf isnan link symlink
106 if {[cc-check-functions sysinfo]} {
107 cc-with {-includes sys/sysinfo.h} {
108 cc-check-members "struct sysinfo.uptime"
112 cc-check-lfs
113 cc-check-functions fseeko ftello
115 define TCL_LIBRARY [get-define prefix]/lib/jim
117 lassign [split [get-define host] -] host_cpu host_vendor host_os
118 # Scrub revision from the host_os
119 regsub -all {[0-9.]} $host_os {} host_os
121 switch -glob -- $host_os {
122 mingw* {
123 # We provide our own implementation of dlopen for mingw32
124 define-feature dlopen-compat
125 define-feature winconsole
126 define TCL_PLATFORM_OS $host_os
127 define TCL_PLATFORM_PLATFORM windows
128 define TCL_PLATFORM_PATH_SEPARATOR {;}
130 default {
131 # Note that cygwin is considered a unix platform
132 define TCL_PLATFORM_OS $host_os
133 define TCL_PLATFORM_PLATFORM unix
134 define TCL_PLATFORM_PATH_SEPARATOR :
138 # Find some tools
139 cc-check-tools ar ranlib strip
140 define tclsh [info nameofexecutable]
142 if {![cc-check-functions _NSGetEnviron]} {
143 msg-checking "Checking environ declared in unistd.h..."
144 if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
145 define NO_ENVIRON_EXTERN
146 msg-result "yes"
147 } else {
148 msg-result "no"
152 # Windows has a mkdir with no permission arg
153 cc-check-includes sys/types.h sys/stat.h
154 msg-checking "Checking for mkdir with one arg..."
155 if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
156 define HAVE_MKDIR_ONE_ARG
157 msg-result yes
158 } else {
159 msg-result no
162 set extra_objs {}
163 set jimregexp 0
165 if {[opt-bool utf8 full]} {
166 msg-result "Enabling UTF-8"
167 define JIM_UTF8
168 incr jimregexp
169 } else {
170 define JIM_UTF8 0
172 if {[opt-bool maintainer]} {
173 msg-result "Enabling maintainer settings"
174 define JIM_MAINTAINER
176 if {[opt-bool math full]} {
177 msg-result "Enabling math functions"
178 define JIM_MATH_FUNCTIONS
179 cc-check-function-in-lib sin m
180 define-append LDLIBS [get-define lib_sin]
182 if {[opt-bool ipv6 full]} {
183 msg-result "Enabling IPv6"
184 define JIM_IPV6
186 if {[opt-bool lineedit full]} {
187 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
188 msg-result "Enabling line editing"
189 define USE_LINENOISE
190 lappend extra_objs linenoise.o
193 if {[opt-bool references]} {
194 msg-result "Enabling references"
195 define JIM_REFERENCES
197 if {[opt-bool shared with-jim-shared]} {
198 msg-result "Building shared library"
199 } else {
200 msg-result "Building static library"
201 define JIM_STATICLIB
203 define LIBSOEXT [format [get-define SH_SOEXTVER] [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]]
204 define JIM_INSTALL [opt-bool install-jim]
205 define JIM_DOCS [opt-bool docs]
206 define JIM_RANDOMISE_HASH [opt-bool random-hash]
208 # Attributes of the extensions
209 # tcl=Pure Tcl extension
210 # static=Can't be built as a module
211 # optional=Not selected by default
212 # cpp=Is a C++ extension
213 global extdb
214 dict set extdb attrs {
215 aio { static }
216 array {}
217 binary { tcl }
218 clock {}
219 eventloop { static }
220 exec { static }
221 file {}
222 glob { tcl }
223 history {}
224 load { static }
225 mk { cpp optional }
226 namespace { static }
227 nshelper { tcl optional }
228 oo { tcl }
229 pack {}
230 package { static }
231 posix {}
232 readdir {}
233 readline { optional }
234 regexp {}
235 rlprompt { tcl optional }
236 sdl { optional }
237 signal { static }
238 sqlite3 { optional }
239 stdlib { tcl static }
240 syslog {}
241 tclcompat { tcl static }
242 tclprefix {}
243 tree { tcl }
244 win32 { optional }
247 # Additional information about certain extensions
248 # dep=list of extensions which are required for this extension
249 # check=[expr] expression to evaluate to determine if the extension can be used
250 # libdep=list of 'define' symbols for dependent libraries
251 dict set extdb info {
252 binary { dep pack }
253 exec { check {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]} }
254 glob { dep readdir }
255 load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen }
256 mk { check {[check-metakit]} libdep lib_mk }
257 namespace { dep nshelper }
258 posix { check {[have-feature waitpid]} }
259 readdir { check {[have-feature opendir]} }
260 readline { check {[cc-check-function-in-lib readline readline]} libdep lib_readline}
261 rlprompt { dep readline }
262 tree { dep oo }
263 sdl { check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}
264 libdep {lib_SDL_SetVideoMode lib_rectangleRGBA}
266 signal { check {[have-feature sigaction] && [have-feature vfork]} }
267 sqlite3 { check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 }
268 syslog { check {[have-feature syslog]} }
269 tree { dep oo }
270 win32 { check {[have-feature windows]} }
273 # autosetup cc-check-function-in-library can't handle C++ libraries
274 proc check-metakit {} {
275 set found 0
276 msg-checking "Checking for Metakit..."
277 cc-with {-lang c++} {
278 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
279 msg-result ok
280 define lib_mk -lmk4
281 incr found
282 } else {
283 msg-result "not found"
286 return $found
289 # Set up the withinfo array based on what the user selected
290 global withinfo
291 set withinfo(without) [join [opt-val {without-ext with-out-jim-ext}]]
292 set withinfo(ext) [join [opt-val {with-ext with-jim-ext}]]
293 set withinfo(mod) [join [opt-val {with-mod with-jim-extmod}]]
294 set withinfo(nodefault) 0
295 if {$withinfo(without) eq "default"} {
296 set withinfo(without) {}
297 set withinfo(nodefault) 1
300 # Now go check everything - see autosetup/local.tcl
301 array set extinfo [check-extensions]
303 # Now special checks
304 if {[have-feature windows]} {
305 lappend extra_objs jim-win32compat.o
307 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
308 user-error "cygwin/mingw require --shared for dynamic modules"
312 if {[ext-get-status regexp] in {y m}} {
313 if {![have-feature regcomp]} {
314 # No regcomp means we need to use the built-in version
315 incr jimregexp
319 if {$jimregexp || [opt-bool jim-regexp]} {
320 msg-result "Using built-in regexp"
321 define JIM_REGEXP
323 # If the built-in regexp overrides the system regcomp, etc.
324 # jim must be built shared so that the correct symbols are found
325 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
326 user-error "Must use --shared with regexp module and built-in regexp"
330 if {[ext-get-status load] eq "n"} {
331 # If we don't have load, no need to support shared objects
332 define SH_LINKFLAGS ""
335 msg-result "Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
336 if {[llength $extinfo(module-tcl)]} {
337 msg-result "Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
339 if {[llength $extinfo(module-c)]} {
340 msg-result "Jim dynamic extensions: [lsort $extinfo(module-c)]"
343 define STATIC_EXTS [concat $extinfo(static-c) $extinfo(static-tcl)]
344 define C_EXT_OBJS [prefix jim- [suffix .o $extinfo(static-c)]]
345 define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
346 define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
347 define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
348 define EXTRA_OBJS $extra_objs
350 # Restore the user-specified LIBS
351 define LIBS $LIBS
353 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
354 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*}
355 make-template Makefile.in
356 make-template build-jim-ext.in
358 catch {exec chmod +x build-jim-ext}