6 # Note
: modules which support options
*must
* be included before
'options'
7 use cc cc
-shared cc
-db cc
-lib pkg
-config util
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
, but enabled by
--full
:
50 tree
- OO tree structure
, similar to tcllib
::struct
::tree
51 binary
- Tcl
-compatible
'binary' command
52 tclprefix
- Support for the tcl
::prefix command
53 ensemble
- Support for the ensemble command
54 zlib
- Interface to zlib
56 These are disabled unless explicitly enabled
:
58 readline
- Interface to libreadline
59 rlprompt
- Tcl wrapper around the readline extension
60 mk
- Interface to Metakit
61 sqlite3
- Interface to sqlite3
62 win32
- Interface to win32
64 with
-out
-jim
-ext
: {without
-ext
:"default|ext1,ext2,..."} => {
65 Specify jim extensions to exclude.
66 If
'default' is given
, the default extensions will not be added.
68 with
-jim
-extmod
: {with
-mod
:"ext1,ext2,..."} => {
69 Specify jim extensions to build as separate
modules (either C or Tcl
).
70 Note that not all extensions can be built as loadable modules.
72 # To help out openocd with automake
76 # Save the user
-specified LIBS
77 # We add detected libs to LDLIBS explicitly
78 set LIBS
[get
-define LIBS
]
80 # In case
-Werror is passed in CFLAGS
, set
-Wno
-error when doing checks
81 # to prevent warnings from becoming errors
82 if
{"-Werror" in
[get
-define CFLAGS
] && [cctest
-cflags
-Wno
-error
]} {
83 cc
-with
{-cflags
-Wno
-error
}
86 cc
-check
-types
"long long"
90 if
{[cctest
-cflags
-fno
-unwind
-tables
]} {
91 define
-append CCOPTS
-fno
-unwind
-tables
93 if
{[cctest
-cflags
-fno
-asynchronous
-unwind
-tables
]} {
94 define
-append CCOPTS
-fno
-asynchronous
-unwind
-tables
97 cc
-check
-includes sys
/time.h sys
/socket.h netinet
/in.h arpa
/inet.h netdb.h
98 cc
-check
-includes sys
/un.h dlfcn.h unistd.h dirent.h crt_externs.h
102 # Haiku needs
-lnetwork
, Solaris needs
-lnsl
103 if
{[cc
-check
-function
-in
-lib inet_ntop
{nsl network
}]} {
104 # This does nothing if no libs are needed
105 cc
-with
[list
-libs
[get
-define lib_inet_ntop
]]
106 define
-append LDLIBS
[get
-define lib_inet_ntop
]
108 # Solaris needs
-lsocket
, Windows needs
-lwsock32
109 if
{[cc
-check
-function
-in
-lib socket socket
]} {
110 define
-append LDLIBS
[get
-define lib_socket
]
113 cc
-check
-functions ualarm lstat fork vfork system select execvpe
114 cc
-check
-functions geteuid mkstemp realpath isatty
115 cc
-check
-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
116 cc
-check
-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
117 cc
-check
-functions shutdown socketpair isinf isnan link symlink fsync dup umask
118 cc
-check
-functions localtime gmtime strptime timegm
120 if
{[cc
-check
-function
-in
-lib backtrace execinfo
]} {
121 define
-append LDLIBS
[get
-define lib_backtrace
]
124 if
{[cc
-check
-functions sysinfo
]} {
125 cc
-with
{-includes sys
/sysinfo.h
} {
126 cc
-check
-members
"struct sysinfo.uptime"
130 cc
-with
{-includes fcntl.h
} {
131 cc
-check
-types
"struct flock"
135 cc
-check
-functions fseeko ftello
137 define TCL_LIBRARY
[get
-define prefix
]/lib
/jim
139 lassign
[split
[get
-define host
] -] host_cpu host_vendor host_os
140 # Scrub revision from the host_os
141 regsub
-all
{[0-9.
]} $host_os
{} host_os
143 switch
-glob
-- $host_os
{
145 # We provide our own implementation of dlopen for mingw32
146 define
-feature dlopen
-compat
147 define
-feature winconsole
148 define TCL_PLATFORM_OS $host_os
149 define TCL_PLATFORM_PLATFORM windows
150 define TCL_PLATFORM_PATH_SEPARATOR
{;}
153 # Note that cygwin is considered a unix platform
154 define TCL_PLATFORM_OS $host_os
155 define TCL_PLATFORM_PLATFORM unix
156 define TCL_PLATFORM_PATH_SEPARATOR
:
161 cc
-check
-tools ar ranlib strip
162 define tclsh
[info nameofexecutable
]
164 if
{[opt
-bool docs
]} {
165 if
{[cc
-check
-progs asciidoc sed
]} {
166 define INSTALL_DOCS docs
169 define INSTALL_DOCS shipped
172 define INSTALL_DOCS nodocs
175 if
{![cc
-check
-functions _NSGetEnviron
]} {
176 msg
-checking
"Checking environ declared in unistd.h..."
177 if
{[cctest
-cflags
{-D_GNU_SOURCE
-D_POSIX_SOURCE
} -includes unistd.h
-code
{char
**ep
= environ
;}]} {
178 define NO_ENVIRON_EXTERN
185 # Windows has a mkdir with no permission arg
186 cc
-check
-includes sys
/types.h sys
/stat.h
187 msg
-checking
"Checking for mkdir with one arg..."
188 if
{[cctest
-includes
{sys
/types.h sys
/stat.h
} -code
{mkdir("/dummy");}]} {
189 define HAVE_MKDIR_ONE_ARG
195 cc
-with
{-includes sys
/stat.h
} {
196 foreach i
{S_IXUSR S_IRWXG S_IRWXO
} {
197 if
{![cc
-check
-decls $i
]} {
206 # Returns
1 if either the given option is enabled
, or
207 #
--full is enabled and the option isn
't explicitly disabled
209 proc opt-bool-or-full {opt} {
210 if {[opt-bool $opt]} {
213 if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
219 if {[opt-bool-or-full utf8]} {
220 msg-result "Enabling UTF-8"
222 define-append CCOPTS -DUSE_UTF8
223 define PARSE_UNIDATA_FLAGS ""
228 if {[opt-bool maintainer]} {
229 msg-result "Enabling maintainer settings"
230 define JIM_MAINTAINER
232 # If --math or --full and not --disable-math
233 if {[opt-bool-or-full math]} {
234 msg-result "Enabling math functions"
235 define JIM_MATH_FUNCTIONS
236 cc-check-function-in-lib sin m
237 define-append LDLIBS [get-define lib_sin]
239 if {[opt-bool-or-full ipv6]} {
240 msg-result "Enabling IPv6"
243 define-append PKG_CONFIG_REQUIRES ""
244 if {[opt-bool-or-full ssl]} {
245 if {[pkg-config-init 0]} {
246 foreach pkg {openssl libssl} {
247 if {[pkg-config $pkg]} {
249 define-append LDLIBS [pkg-config-get $pkg LIBS]
250 define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
251 define-append CCOPTS [pkg-config-get $pkg CFLAGS]
252 msg-result "Enabling SSL ($pkg)"
253 define-append PKG_CONFIG_REQUIRES $pkg
258 if {![is-defined JIM_SSL]} {
259 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]} {
260 msg-result "Enabling SSL"
262 define-append LDLIBS [get-define lib_ERR_error_string] [get-define lib_TLSv1_2_method]
263 } elseif {[opt-bool ssl]} {
264 user-error "SSL support requires OpenSSL"
268 if {[opt-bool-or-full lineedit]} {
269 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
270 msg-result "Enabling line editing"
272 define-append PARSE_UNIDATA_FLAGS -width
273 lappend extra_objs linenoise.o
276 if {[opt-bool references]} {
277 msg-result "Enabling references"
278 define JIM_REFERENCES
280 if {[opt-bool shared with-jim-shared]} {
281 msg-result "Building shared library"
283 msg-result "Building static library"
286 define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]
287 define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]]
288 define JIM_INSTALL [opt-bool install-jim]
289 define JIM_DOCS [opt-bool docs]
290 define JIM_RANDOMISE_HASH [opt-bool random-hash]
291 if {[opt-val docdir] ne ""} {
292 define docdir [lindex [opt-val docdir] end]
294 define docdir {${prefix}/docs/jim}
297 # Attributes of the extensions
298 # tcl=Pure Tcl extension
299 # static=Can't be built as a module
300 # off
=Off unless explicitly enabled
301 # optional
=Off by default
, but selected by
--full
302 # cpp
=Is a C
++ extension
304 dict set extdb attrs
{
307 binary
{ tcl optional
}
318 nshelper
{ tcl optional
}
331 stdlib
{ tcl static
}
333 tclcompat
{ tcl static
}
334 tclprefix
{ optional
}
339 # Additional information about certain extensions
340 # dep
=list of extensions which are required for this extension
341 # check
=[expr
] expression to evaluate to determine if the extension can be used
342 # libdep
=list of
'define' symbols for dependent libraries
343 dict set extdb info
{
345 exec
{ check
{([have
-feature vfork
] && [have
-feature waitpid
]) ||
[have
-feature system
]} }
347 load
{ check
{[have
-feature dlopen
-compat
] ||
[cc
-check
-function
-in
-lib dlopen dl
]} libdep lib_dlopen
}
348 mk
{ check
{[check
-metakit
]} libdep lib_mk
}
349 namespace
{ dep nshelper
}
350 posix
{ check
{[have
-feature waitpid
]} }
351 readdir
{ check
{[have
-feature opendir
]} }
352 readline
{ pkg
-config readline check
{[cc
-check
-function
-in
-lib readline readline
]} libdep lib_readline
}
353 rlprompt
{ dep readline
}
355 sdl
{ pkg
-config SDL_gfx check
{[cc
-check
-function
-in
-lib SDL_SetVideoMode SDL
] && [cc
-check
-function
-in
-lib rectangleRGBA SDL_gfx
]}
356 libdep
{lib_SDL_SetVideoMode lib_rectangleRGBA
}
358 signal
{ check
{[have
-feature sigaction
] && [have
-feature vfork
]} }
359 sqlite3
{ pkg
-config sqlite3 check
{[cc
-check
-function
-in
-lib sqlite3_prepare_v2 sqlite3
]} libdep lib_sqlite3_prepare_v2
}
360 zlib
{ pkg
-config zlib check
{[cc
-check
-function
-in
-lib deflate z
]} libdep lib_deflate
}
361 syslog
{ check
{[have
-feature syslog
]} }
363 win32
{ check
{[have
-feature windows
]} }
366 # autosetup cc
-check
-function
-in
-library can
't handle C++ libraries
367 proc check-metakit {} {
369 msg-checking "Checking for Metakit..."
370 cc-with {-lang c++} {
371 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
376 msg-result "not found"
382 # Takes a list of module names, separated by spaces or commas
383 # and returns them as a single list
384 proc join-ext-names {list} {
386 # Replace comma with space in each list then concatenate the result
388 lappend result {*}[string map {, " "} $l]
393 # Set up the withinfo array based on what the user selected
395 set withinfo(without) [join-ext-names [opt-val {without-ext with-out-jim-ext}]]
396 set withinfo(ext) [join-ext-names [opt-val {with-ext with-jim-ext}]]
397 set withinfo(mod) [join-ext-names [opt-val {with-mod with-jim-extmod}]]
398 set withinfo(nodefault) 0
399 set withinfo(optional) [opt-bool full]
400 if {$withinfo(without) eq "default"} {
401 set withinfo(without) {}
402 set withinfo(nodefault) 1
405 # Now go check everything - see autosetup/local.tcl
406 array set extinfo [check-extensions]
409 if {[have-feature windows]} {
410 lappend extra_objs jim-win32compat.o
412 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
413 user-error "cygwin/mingw require --shared for dynamic modules"
416 if {[have-feature termios.h]} {
417 lappend extra_objs jim-tty.o
420 if {[ext-get-status regexp] in {y m}} {
421 if {![have-feature regcomp]} {
422 # No regcomp means we need to use the built-in version
427 if {$jimregexp || [opt-bool jim-regexp]} {
428 msg-result "Using built-in regexp"
431 # If the built-in regexp overrides the system regcomp, etc.
432 # jim must be built shared so that the correct symbols are found
433 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
434 user-error "Must use --shared with regexp module and built-in regexp"
438 if {[ext-get-status load] eq "n"} {
439 # If we don't have load
, no need to support shared objects
440 define SH_LINKFLAGS
""
443 msg
-result
"Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
444 if
{[llength $
extinfo(module
-tcl
)]} {
445 msg
-result
"Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
447 if
{[llength $
extinfo(module
-c
)]} {
448 msg
-result
"Jim dynamic extensions: [lsort $extinfo(module-c)]"
451 define STATIC_EXTS
[concat $
extinfo(static
-c
) $
extinfo(static
-tcl
)]
452 define C_EXT_OBJS
[prefix jim
- [suffix .o $
extinfo(static
-c
)]]
453 define TCL_EXT_OBJS
[suffix .o $
extinfo(static
-tcl
)]
454 define C_EXT_SHOBJS
[suffix .so $
extinfo(module
-c
)]
455 define TCL_EXTS
[suffix .tcl $
extinfo(module
-tcl
)]
456 define EXTRA_OBJS $extra_objs
458 # Restore the user
-specified LIBS
461 make
-config
-header jim
-config.h
-auto
{HAVE_LONG_LONG
* JIM_UTF8
} -bare JIM_VERSION
-none
*
462 make
-config
-header jimautoconf.h
-auto
{jim_ext_
* TCL_PLATFORM_
* TCL_LIBRARY USE_
* JIM_
* _FILE_OFFSET
*} -bare
{S_I
*}
463 make
-template Makefile.in
464 make
-template build
-jim
-ext.in
465 make
-template jimtcl.pc.in
467 catch
{exec chmod
+x build
-jim
-ext
}