6 # Note
: modules which support options
*must
* be included before
'options'
7 use cc cc
-shared cc
-db cc
-lib pkg
-config
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 ssl
=> "include ssl/tls support in the aio extension"
16 ipv6
=> "include ipv6 support in the aio extension"
17 maintainer
=> {enable the
[debug
] command and JimPanic
}
18 full
=> "Enable some optional features: ipv6, ssl, math, utf8, binary, oo, tree"
19 with
-jim
-shared shared
=> "build a shared library instead of a static library"
20 jim
-regexp
=1 => "prefer POSIX regex if over the the built-in (Tcl-compatible) regex"
21 docs
=1 => "don't build or install the documentation"
22 docdir
:path
=> "path to install docs (if built)"
23 random
-hash
=> "randomise hash tables. more secure but hash table results are not predicable"
24 with
-jim
-ext
: {with
-ext
:"ext1 ext2 ..."} => {
25 Specify additional jim extensions to include.
26 These are enabled by default
:
28 aio
- ANSI I
/O
, including open and socket
29 eventloop
- after
, vwait
, update
30 array
- Tcl
-compatible array command
31 clock
- Tcl
-compatible clock command
32 exec
- Tcl
-compatible exec command
33 file
- Tcl
-compatible file command
34 glob
- Tcl
-compatible glob command
35 history
- Tcl access to interactive history
36 readdir
- Required for glob
37 package
- Package management with the package command
38 load
- Load binary extensions at runtime with load or package
39 posix
- Posix APIs including os.fork
, os.wait
, pid
40 regexp
- Tcl
-compatible regexp
, regsub commands
41 signal
- Signal handling
42 stdlib
- Built
-in commands including lassign
, lambda
, alias
43 syslog
- System logging with syslog
44 tclcompat
- Tcl compatible read
, gets
, puts
, parray
, case
, ...
45 namespace
- Tcl compatible namespace support
47 These are disabled by default
:
50 tree
- OO tree structure
, similar to tcllib
::struct
::tree
51 binary
- Tcl
-compatible
'binary' command
52 readline
- Interface to libreadline
53 rlprompt
- Tcl wrapper around the readline extension
54 mk
- Interface to Metakit
55 tclprefix
- Support for the tcl
::prefix command
56 sqlite3
- Interface to sqlite3
57 zlib
- Interface to zlib
58 win32
- Interface to win32
60 with
-out
-jim
-ext
: {without
-ext
:"default|ext1 ext2 ..."} => {
61 Specify jim extensions to exclude.
62 If
'default' is given
, the default extensions will not be added.
64 with
-jim
-extmod
: {with
-mod
:"ext1 ext2 ..."} => {
65 Specify jim extensions to build as separate
modules (either C or Tcl
).
66 Note that not all extensions can be built as loadable modules.
68 # To help out openocd with automake
72 # Save the user
-specified LIBS
73 # We add detected libs to LDLIBS explicitly
74 set LIBS
[get
-define LIBS
]
76 # In case
-Werror is passed in CFLAGS
, set
-Wno
-error when doing checks
77 # to prevent warnings from becoming errors
78 if
{"-Werror" in
[get
-define CFLAGS
] && [cctest
-cflags
-Wno
-error
]} {
79 cc
-with
{-cflags
-Wno
-error
}
82 cc
-check
-types
"long long"
86 if
{[cctest
-cflags
-fno
-unwind
-tables
]} {
87 define
-append CCOPTS
-fno
-unwind
-tables
89 if
{[cctest
-cflags
-fno
-asynchronous
-unwind
-tables
]} {
90 define
-append CCOPTS
-fno
-asynchronous
-unwind
-tables
93 cc
-check
-includes sys
/time.h sys
/socket.h netinet
/in.h arpa
/inet.h netdb.h
94 cc
-check
-includes sys
/un.h dlfcn.h unistd.h dirent.h crt_externs.h
98 # Haiku needs
-lnetwork
, Solaris needs
-lnsl
99 if
{[cc
-check
-function
-in
-lib inet_ntop
{nsl network
}]} {
100 # This does nothing if no libs are needed
101 cc
-with
[list
-libs
[get
-define lib_inet_ntop
]]
102 define
-append LDLIBS
[get
-define lib_inet_ntop
]
104 # Solaris needs
-lsocket
, Windows needs
-lwsock32
105 if
{[cc
-check
-function
-in
-lib socket socket
]} {
106 define
-append LDLIBS
[get
-define lib_socket
]
109 cc
-check
-functions ualarm lstat fork vfork system select execvpe
110 cc
-check
-functions backtrace geteuid mkstemp realpath strptime isatty
111 cc
-check
-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
112 cc
-check
-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
113 cc
-check
-functions shutdown socketpair isinf isnan link symlink fsync dup umask
115 if
{[cc
-check
-functions sysinfo
]} {
116 cc
-with
{-includes sys
/sysinfo.h
} {
117 cc
-check
-members
"struct sysinfo.uptime"
121 cc
-with
{-includes fcntl.h
} {
122 cc
-check
-types
"struct flock"
126 cc
-check
-functions fseeko ftello
128 define TCL_LIBRARY
[get
-define prefix
]/lib
/jim
130 lassign
[split
[get
-define host
] -] host_cpu host_vendor host_os
131 # Scrub revision from the host_os
132 regsub
-all
{[0-9.
]} $host_os
{} host_os
134 switch
-glob
-- $host_os
{
136 # We provide our own implementation of dlopen for mingw32
137 define
-feature dlopen
-compat
138 define
-feature winconsole
139 define TCL_PLATFORM_OS $host_os
140 define TCL_PLATFORM_PLATFORM windows
141 define TCL_PLATFORM_PATH_SEPARATOR
{;}
144 # Note that cygwin is considered a unix platform
145 define TCL_PLATFORM_OS $host_os
146 define TCL_PLATFORM_PLATFORM unix
147 define TCL_PLATFORM_PATH_SEPARATOR
:
152 cc
-check
-tools ar ranlib strip
153 define tclsh
[info nameofexecutable
]
155 if
{[opt
-bool docs
]} {
156 if
{[cc
-check
-progs asciidoc
]} {
157 define INSTALL_DOCS docs
160 define INSTALL_DOCS shipped
163 define INSTALL_DOCS nodocs
166 if
{![cc
-check
-functions _NSGetEnviron
]} {
167 msg
-checking
"Checking environ declared in unistd.h..."
168 if
{[cctest
-cflags
{-D_GNU_SOURCE
-D_POSIX_SOURCE
} -includes unistd.h
-code
{char
**ep
= environ
;}]} {
169 define NO_ENVIRON_EXTERN
176 # Windows has a mkdir with no permission arg
177 cc
-check
-includes sys
/types.h sys
/stat.h
178 msg
-checking
"Checking for mkdir with one arg..."
179 if
{[cctest
-includes
{sys
/types.h sys
/stat.h
} -code
{mkdir("/dummy");}]} {
180 define HAVE_MKDIR_ONE_ARG
186 cc
-with
{-includes sys
/stat.h
} {
187 foreach i
{S_IXUSR S_IRWXG S_IRWXO
} {
188 if
{![cc
-check
-decls $i
]} {
197 # Returns
1 if either the given option is enabled
, or
198 #
--full is enabled and the option isn
't explicitly disabled
200 proc opt-bool-or-full {opt} {
201 if {[opt-bool $opt]} {
204 if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
210 if {[opt-bool-or-full utf8]} {
211 msg-result "Enabling UTF-8"
213 define-append CCOPTS -DUSE_UTF8
214 define PARSE_UNIDATA_FLAGS ""
219 if {[opt-bool maintainer]} {
220 msg-result "Enabling maintainer settings"
221 define JIM_MAINTAINER
223 # If --math or --full and not --disable-math
224 if {[opt-bool-or-full math]} {
225 msg-result "Enabling math functions"
226 define JIM_MATH_FUNCTIONS
227 cc-check-function-in-lib sin m
228 define-append LDLIBS [get-define lib_sin]
230 if {[opt-bool-or-full ipv6]} {
231 msg-result "Enabling IPv6"
234 define-append PKG_CONFIG_REQUIRES ""
235 if {[opt-bool-or-full ssl]} {
236 if {[pkg-config-init 0]} {
237 foreach pkg {openssl libssl} {
238 if {[pkg-config $pkg]} {
240 define-append LDLIBS [pkg-config-get $pkg LIBS]
241 define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
242 define-append CCOPTS [pkg-config-get $pkg CFLAGS]
243 msg-result "Enabling SSL ($pkg)"
244 define-append PKG_CONFIG_REQUIRES $pkg
249 if {![is-defined JIM_SSL]} {
250 if {[cc-check-includes openssl/ssl.h] && [cc-check-function-in-lib ERR_error_string crypto] && [cc-check-function-in-lib TLSv1_2_method ssl]} {
251 msg-result "Enabling SSL"
253 define-append LDLIBS [get-define lib_ERR_error_string] [get-define lib_TLSv1_2_method]
254 } elseif {[opt-bool ssl]} {
255 user-error "SSL support requires OpenSSL"
259 if {[opt-bool-or-full lineedit]} {
260 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
261 msg-result "Enabling line editing"
263 define-append PARSE_UNIDATA_FLAGS -width
264 lappend extra_objs linenoise.o
267 if {[opt-bool references]} {
268 msg-result "Enabling references"
269 define JIM_REFERENCES
271 if {[opt-bool shared with-jim-shared]} {
272 msg-result "Building shared library"
274 msg-result "Building static library"
277 define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]
278 define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]]
279 define JIM_INSTALL [opt-bool install-jim]
280 define JIM_DOCS [opt-bool docs]
281 define JIM_RANDOMISE_HASH [opt-bool random-hash]
282 if {[opt-val docdir] ne ""} {
283 define docdir [opt-val docdir]
285 define docdir {${prefix}/docs/jim}
288 # Attributes of the extensions
289 # tcl=Pure Tcl extension
290 # static=Can't be built as a module
291 # optional
=Not selected by default
292 # cpp
=Is a C
++ extension
294 dict set extdb attrs
{
308 nshelper
{ tcl optional
}
314 readline
{ optional
}
316 rlprompt
{ tcl optional
}
321 stdlib
{ tcl static
}
323 tclcompat
{ tcl static
}
329 # Additional information about certain extensions
330 # dep
=list of extensions which are required for this extension
331 # check
=[expr
] expression to evaluate to determine if the extension can be used
332 # libdep
=list of
'define' symbols for dependent libraries
333 dict set extdb info
{
335 exec
{ check
{([have
-feature vfork
] && [have
-feature waitpid
]) ||
[have
-feature system
]} }
337 load
{ check
{[have
-feature dlopen
-compat
] ||
[cc
-check
-function
-in
-lib dlopen dl
]} libdep lib_dlopen
}
338 mk
{ check
{[check
-metakit
]} libdep lib_mk
}
339 namespace
{ dep nshelper
}
340 posix
{ check
{[have
-feature waitpid
]} }
341 readdir
{ check
{[have
-feature opendir
]} }
342 readline
{ pkg
-config readline check
{[cc
-check
-function
-in
-lib readline readline
]} libdep lib_readline
}
343 rlprompt
{ dep readline
}
345 sdl
{ pkg
-config SDL_gfx check
{[cc
-check
-function
-in
-lib SDL_SetVideoMode SDL
] && [cc
-check
-function
-in
-lib rectangleRGBA SDL_gfx
]}
346 libdep
{lib_SDL_SetVideoMode lib_rectangleRGBA
}
348 signal
{ check
{[have
-feature sigaction
] && [have
-feature vfork
]} }
349 sqlite3
{ pkg
-config sqlite3 check
{[cc
-check
-function
-in
-lib sqlite3_prepare_v2 sqlite3
]} libdep lib_sqlite3_prepare_v2
}
350 zlib
{ pkg
-config zlib check
{[cc
-check
-function
-in
-lib deflate z
]} libdep lib_deflate
}
351 syslog
{ check
{[have
-feature syslog
]} }
353 win32
{ check
{[have
-feature windows
]} }
356 # autosetup cc
-check
-function
-in
-library can
't handle C++ libraries
357 proc check-metakit {} {
359 msg-checking "Checking for Metakit..."
360 cc-with {-lang c++} {
361 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
366 msg-result "not found"
372 # Set up the withinfo array based on what the user selected
374 set withinfo(without) [join [opt-val {without-ext with-out-jim-ext}]]
375 set withinfo(ext) [join [opt-val {with-ext with-jim-ext}]]
376 set withinfo(mod) [join [opt-val {with-mod with-jim-extmod}]]
377 set withinfo(nodefault) 0
378 if {$withinfo(without) eq "default"} {
379 set withinfo(without) {}
380 set withinfo(nodefault) 1
383 # Now go check everything - see autosetup/local.tcl
384 array set extinfo [check-extensions]
387 if {[have-feature windows]} {
388 lappend extra_objs jim-win32compat.o
390 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
391 user-error "cygwin/mingw require --shared for dynamic modules"
394 if {[have-feature termios.h]} {
395 lappend extra_objs jim-tty.o
398 if {[ext-get-status regexp] in {y m}} {
399 if {![have-feature regcomp]} {
400 # No regcomp means we need to use the built-in version
405 if {$jimregexp || [opt-bool jim-regexp]} {
406 msg-result "Using built-in regexp"
409 # If the built-in regexp overrides the system regcomp, etc.
410 # jim must be built shared so that the correct symbols are found
411 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
412 user-error "Must use --shared with regexp module and built-in regexp"
416 if {[ext-get-status load] eq "n"} {
417 # If we don't have load
, no need to support shared objects
418 define SH_LINKFLAGS
""
421 msg
-result
"Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
422 if
{[llength $
extinfo(module
-tcl
)]} {
423 msg
-result
"Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
425 if
{[llength $
extinfo(module
-c
)]} {
426 msg
-result
"Jim dynamic extensions: [lsort $extinfo(module-c)]"
429 define STATIC_EXTS
[concat $
extinfo(static
-c
) $
extinfo(static
-tcl
)]
430 define C_EXT_OBJS
[prefix jim
- [suffix .o $
extinfo(static
-c
)]]
431 define TCL_EXT_OBJS
[suffix .o $
extinfo(static
-tcl
)]
432 define C_EXT_SHOBJS
[suffix .so $
extinfo(module
-c
)]
433 define TCL_EXTS
[suffix .tcl $
extinfo(module
-tcl
)]
434 define EXTRA_OBJS $extra_objs
436 # Restore the user
-specified LIBS
439 make
-config
-header jim
-config.h
-auto
{HAVE_LONG_LONG
* JIM_UTF8
} -bare JIM_VERSION
-none
*
440 make
-config
-header jimautoconf.h
-auto
{jim_ext_
* TCL_PLATFORM_
* TCL_LIBRARY USE_
* JIM_
* _FILE_OFFSET
*} -bare
{S_I
*}
441 make
-template Makefile.in
442 make
-template build
-jim
-ext.in
443 make
-template jimtcl.pc.in
445 catch
{exec chmod
+x build
-jim
-ext
}