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