JimPanic() doesn't require interp
[jimtcl.git] / auto.def
blob8da61b8fcb806fdf0187a708f5e743d43195532f
1 # vim:se syn=tcl:
4 # Note: modules which support options *must* be included before 'options'
5 use cc cc-shared
7 options {
8 utf8 => "include support for utf8-encoded strings"
9 lineedit=1 => "disable line editing"
10 references=1 => "disable support for references"
11 math => "include support for math functions"
12 ipv6 => "include ipv6 support in the aio extension"
13 maintainer => {enable the [debug] command and JimPanic}
14 full => "Enable some optional features: ipv6, math, utf8, binary, oo, tree"
15 with-jim-shared shared => "build a shared library instead of a static library"
16 jim-regexp => "use the built-in (Tcl-compatible) regexp, even if POSIX regex is available"
17 with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
18 Specify additional jim extensions to include.
19 These are enabled by default:
21 aio - ANSI I/O, including open and socket
22 eventloop - after, vwait, update
23 array - Tcl-compatible array command
24 clock - Tcl-compatible clock command
25 exec - Tcl-compatible exec command
26 file - Tcl-compatible file command
27 glob - Tcl-compatible glob command
28 readdir - Required for glob
29 package - Package management with the package command
30 load - Load binary extensions at runtime with load or package
31 posix - Posix APIs including os.fork, os.wait, pid
32 regexp - Tcl-compatible regexp, regsub commands
33 signal - Signal handling
34 stdlib - Built-in commands including lassign, lambda, alias
35 syslog - System logging with syslog
36 tclcompat - Tcl compatible read, gets, puts, parray, case, ...
38 These are disabled by default:
40 nvp - Name-value pairs C-only API
41 oo - Jim OO extension
42 tree - OO tree structure, similar to tcllib ::struct::tree
43 binary - Tcl-compatible 'binary' command
44 readline - Interface to libreadline
45 rlprompt - Tcl wrapper around the readline extension
46 sqlite - Interface to sqlite
47 sqlite3 - Interface to sqlite3
48 win32 - Interface to win32
50 with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
51 Specify jim extensions to exclude.
52 If 'default' is given, the default extensions will not be added.
54 with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
55 Specify jim extensions to build as separate modules (either C or Tcl).
56 Note that not all extensions can be built as loadable modules.
58 # To help out openocd with automake
59 install-jim=1
62 cc-check-types "long long"
64 cc-check-includes sys/socket.h netinet/in.h arpa/inet.h netdb.h
65 cc-check-includes sys/un.h dlfcn.h unistd.h crt_externs.h
67 # Haiku needs -lnetwork
68 if {[cc-check-function-in-lib inet_ntop network]} {
69 if {[get-define lib_inet_ntop] ne ""} {
70 cc-with {-libs -lnetwork}
74 cc-check-functions ualarm sysinfo lstat fork vfork system select
75 cc-check-functions backtrace geteuid mkstemp realpath strptime gettimeofday
76 cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist
77 cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo
79 define TCL_LIBRARY [get-define prefix]/lib/jim
81 lassign [split [get-define host] -] host_cpu host_vendor host_os
82 # Scrub revision from the host_os
83 regsub -all {[0-9.]} $host_os {} host_os
85 switch -glob -- $host_os {
86 mingw* {
87 # We provide our own implementation of dlopen for mingw32
88 define-feature dlopen-compat
89 define TCL_PLATFORM_OS $host_os
90 define TCL_PLATFORM_PLATFORM windows
91 define TCL_PLATFORM_PATH_SEPARATOR {;}
93 default {
94 # Note that cygwin is considered a unix platform
95 define TCL_PLATFORM_OS $host_os
96 define TCL_PLATFORM_PLATFORM unix
97 define TCL_PLATFORM_PATH_SEPARATOR :
101 # Find some tools
102 cc-check-tools ar ranlib strip
103 define tclsh [info nameofexecutable]
105 if {![cc-check-functions _NSGetEnviron]} {
106 msg-checking "Checking environ declared in unistd.h..."
107 if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
108 define NO_ENVIRON_EXTERN
109 msg-result "yes"
110 } else {
111 msg-result "no"
115 # Windows has a mkdir with no permission arg
116 cc-check-includes sys/types.h sys/stat.h
117 msg-checking "Checking for mkdir with one arg..."
118 if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
119 define HAVE_MKDIR_ONE_ARG
120 msg-result yes
121 } else {
122 msg-result no
125 set extra_objs {}
126 set jimregexp 0
128 if {[opt-bool utf8 full]} {
129 msg-result "Enabling UTF-8"
130 define JIM_UTF8
131 incr jimregexp
132 } else {
133 define JIM_UTF8 0
135 if {[opt-bool maintainer]} {
136 msg-result "Enabling maintainer settings"
137 define JIM_MAINTAINER
139 if {[opt-bool math full]} {
140 msg-result "Enabling math functions"
141 define JIM_MATH_FUNCTIONS
142 cc-check-function-in-lib sin m
144 if {[opt-bool ipv6 full]} {
145 msg-result "Enabling IPv6"
146 define JIM_IPV6
148 if {[opt-bool lineedit full] && [cc-check-includes termios.h] && [cc-check-functions isatty]} {
149 msg-result "Enabling line editing"
150 define USE_LINENOISE
151 lappend extra_objs linenoise.o
152 cc-check-functions isatty
154 if {[opt-bool references]} {
155 msg-result "Enabling references"
156 define JIM_REFERENCES
158 if {[opt-bool shared with-jim-shared]} {
159 msg-result "Building shared library"
160 define JIM_LIBTYPE shared
161 } else {
162 msg-result "Building static library"
163 define JIM_LIBTYPE static
165 if {[opt-bool install-jim]} {
166 define install_jim 1
167 } else {
168 define install_jim ""
171 # Note: Extension handling is mapped directly from the configure.ac
172 # implementation
174 set without [join [opt-val {without-ext with-out-jim-ext}]]
175 set withext [join [opt-val {with-ext with-jim-ext}]]
176 set withmod [join [opt-val {with-mod with-jim-extmod}]]
178 # Tcl extensions
179 set ext_tcl "stdlib glob tclcompat tree rlprompt oo binary"
180 # C extensions
181 set ext_c "load package readdir array clock exec file posix regexp signal aio eventloop pack syslog nvp readline sqlite sqlite3 win32"
183 # Tcl extensions which can be modules
184 set ext_tcl_mod "glob tree rlprompt oo binary"
185 # C extensions which can be modules
186 set ext_c_mod "readdir array clock file posix regexp syslog readline pack sqlite sqlite3 win32"
188 # All extensions
189 set ext_all [concat $ext_c $ext_tcl]
191 # Default static extensions
192 set ext_default "stdlib load package readdir glob array clock exec file posix regexp signal tclcompat aio eventloop syslog"
194 if {[opt-bool full]} {
195 lappend ext_default tree binary
198 if {$without eq "default"} {
199 set ext_default stdlib
200 set without {}
203 # Check valid extension names
204 foreach i [concat $withext $without $withmod] {
205 if {$i ni $ext_all} {
206 user-error "Unknown extension: $i"
210 # needs_xxx="expression" means that the expr must eval to 1 to select the extension
211 # dep_xxx="yyy zzz" means that if xxx is selected, so is yyy and zzz
212 set dep(glob) readdir
213 set dep(rlprompt) readline
214 set dep(tree) oo
215 set dep(binary) pack
217 set needs(aio) {expr {[cc-check-function-in-lib socket socket] || 1}}
218 set needs(exec) {expr {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]}}
219 set needs(load) {expr {[cc-check-function-in-lib dlopen dl] || [have-feature dlopen-compat]}}
220 set needs(posix) {have-feature waitpid}
221 set needs(readdir) {have-feature opendir}
222 set needs(readline) {cc-check-function-in-lib readline readline}
223 set needs(signal) {expr {[have-feature sigaction] && [have-feature vfork]}}
224 set needs(sqlite) {cc-check-function-in-lib sqlite_open sqlite}
225 set needs(sqlite3) {cc-check-function-in-lib sqlite3_open sqlite3}
226 set needs(syslog) {have-feature syslog}
227 set needs(eventloop) {expr {[have-feature select] || [have-feature usleep]}}
228 set needs(win32) {have-feature windows}
230 # First handle dependencies. If an extension is enabled, also enable its dependency
231 foreach i [concat $ext_default $withext] {
232 if {$i in $without} {
233 continue
235 if {[info exists dep($i)]} {
236 lappend withext {*}$dep($i)
240 foreach i $withmod {
241 if {[info exists dep($i)]} {
242 # Theoretically, a mod could depend upon something which must be static
243 # If already configured static, don't make it a module
244 foreach d $dep($i) {
245 if {$d ni $withext} {
246 lappend withmod $d
252 # Now that we know what the platform supports:
254 # For all known extensions:
255 # - If it is disabled, remove it
256 # - Otherwise, check to see if it's pre-requisites are met
257 # - If yes, add it if it is enabled or is a default
258 # - If no, error if it is enabled, or do nothing otherwise
259 # - Modules may be either C or Tcl
261 set extmodtcl {}
262 set extmod {}
263 set ext {}
265 foreach i [lsort $ext_all] {
266 # First discard the extension if disabled or not enabled
267 if {$i in $without} {
268 msg-result "Extension $i...disabled"
269 continue
271 if {$i ni [concat $withext $withmod $ext_default]} {
272 msg-result "Extension $i...not enabled"
273 continue
276 # Check dependencies
277 set met 1
278 if {[info exists needs($i)]} {
279 set met [eval $needs($i)]
282 msg-checking "Extension $i..."
284 # Selected as a module?
285 if {$i in $withmod} {
286 if {$i in $ext_tcl_mod} {
287 # Easy, a Tcl module
288 msg-result "tcl"
289 lappend extmodtcl $i
290 continue
292 if {$i ni $ext_c_mod} {
293 user-error "not a module"
295 if {!$met} {
296 user-error "dependencies not met"
298 msg-result "module"
299 lappend extmod $i
300 continue
303 # Selected as a static extension?
304 if {$i in $withext} {
305 if {!$met} {
306 user-error "dependencies not met"
308 msg-result "enabled"
309 lappend ext $i
310 continue
313 # Enabled by default?
314 if {$i in $ext_default} {
315 if {!$met} {
316 msg-result "disabled (dependencies)"
317 continue
319 msg-result "enabled (default)"
320 lappend ext $i
321 continue
325 if {[have-feature windows]} {
326 lappend extra_objs jim-win32compat.o
328 if {$extmod ne "" && [get-define JIM_LIBTYPE] eq "static"} {
329 user-error "cygwin/mingw require --shared for dynamic modules"
333 if {"regexp" in "$ext $extmod"} {
334 # No regcomp means we need to use the built-in version
335 if {![have-feature regcomp]} {
336 incr jimregexp
340 if {$jimregexp || [opt-bool jim-regexp]} {
341 msg-result "Using built-in regexp"
342 define JIM_REGEXP
344 # If the built-in regexp overrides the system regcomp, etc.
345 # jim must be built shared so that the correct symbols are found
346 if {"regexp" in $extmod && [get-define JIM_LIBTYPE] eq "static" && [have-feature regcomp]} {
347 user-error "Must use --shared with regexp module and built-in regexp"
350 if {"load" ni $ext} {
351 # If we don't have load, no need to support shared objects
352 define SH_LINKFLAGS ""
355 msg-result "Jim static extensions: [lsort $ext]"
356 if {$extmodtcl ne ""} {
357 msg-result "Jim Tcl extensions: [lsort $extmodtcl]"
359 if {$extmod ne ""} {
360 msg-result "Jim dynamic extensions: [lsort $extmod]"
363 # Separate out the static extensions into C and Tcl
364 set ext_static_c {}
365 set ext_static_tcl {}
366 foreach e $ext {
367 define jim_ext_$e
368 if {$e in $ext_tcl} {
369 lappend ext_static_tcl $e
370 } else {
371 lappend ext_static_c $e
375 define JIM_STATIC_C_EXTS $ext_static_c
376 define JIM_STATIC_TCL_EXTS $ext_static_tcl
377 define JIM_TCL_EXTENSIONS $extmodtcl
378 define JIM_MOD_EXTENSIONS $extmod
379 define EXTRA_OBJS $extra_objs
381 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -none *
382 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_*}
383 make-template Makefile.in