10 # Note
: modules which support options
*must
* be included before
'options'
11 use cc cc
-shared cc
-db cc
-lib pkg
-config util
15 utf8
=> "include support for utf8-encoded strings"
16 lineedit
=1 => "disable line editing"
17 references
=1 => "disable support for references"
18 math
=> "include support for math functions"
19 ssl
=> "include ssl/tls support in the aio extension"
20 ipv6
=> "include ipv6 support in the aio extension"
21 maintainer
=> {enable the
[debug
] command and JimPanic
}
22 full
=> "Enable some optional features: ipv6, ssl, math, utf8, binary, oo, tree"
23 with
-jim
-shared shared
=> "build a shared library instead of a static library"
24 jim
-regexp
=1 => "prefer POSIX regex if over the the built-in (Tcl-compatible) regex"
25 docs
=1 => "don't build or install the documentation"
26 docdir
:path
=> "path to install docs (if built)"
27 random
-hash
=> "randomise hash tables. more secure but hash table results are not predicable"
28 with
-jim
-ext
: {with
-ext
:"ext1,ext2,..."} => {
29 Specify additional jim extensions to include.
30 These are enabled by default
:
32 aio
- ANSI I
/O
, including open and socket
33 eventloop
- after
, vwait
, update
34 array
- Tcl
-compatible array command
35 clock
- Tcl
-compatible clock command
36 exec
- Tcl
-compatible exec command
37 file
- Tcl
-compatible file command
38 glob
- Tcl
-compatible glob command
39 history
- Tcl access to interactive history
40 readdir
- Required for glob
41 package
- Package management with the package command
42 load
- Load binary extensions at runtime with load or package
43 posix
- Posix APIs including os.fork
, os.uptime
44 regexp
- Tcl
-compatible regexp
, regsub commands
45 signal
- Signal handling
46 stdlib
- Built
-in commands including lassign
, lambda
, alias
47 syslog
- System logging with syslog
48 tclcompat
- Tcl compatible read
, gets
, puts
, parray
, case
, ...
49 namespace
- Tcl compatible namespace support
51 These are disabled by default
, but enabled by
--full
:
54 tree
- OO tree structure
, similar to tcllib
::struct
::tree
55 binary
- Tcl
-compatible
'binary' command
56 tclprefix
- Support for the tcl
::prefix command
57 zlib
- Interface to zlib
59 These are disabled unless explicitly enabled
:
61 readline
- Interface to libreadline
62 rlprompt
- Tcl wrapper around the readline extension
63 mk
- Interface to Metakit
64 sqlite3
- Interface to sqlite3
65 win32
- Interface to win32
67 with
-out
-jim
-ext
: {without
-ext
:"default|ext1,ext2,..."} => {
68 Specify jim extensions to exclude.
69 If
'default' is given
, the default extensions will not be added.
71 with
-jim
-extmod
: {with
-mod
:"ext1,ext2,..."} => {
72 Specify jim extensions to build as separate
modules (either C or Tcl
).
73 Note that not all extensions can be built as loadable modules.
75 # To help out openocd with automake
79 # Save the user
-specified LIBS
80 # We add detected libs to LDLIBS explicitly
81 set LIBS
[get
-define LIBS
]
83 # In case
-Werror is passed in CFLAGS
, set
-Wno
-error when doing checks
84 # to prevent warnings from becoming errors
85 if
{"-Werror" in
[get
-define CFLAGS
] && [cctest
-cflags
-Wno
-error
]} {
86 cc
-with
{-cflags
-Wno
-error
}
89 cc
-check
-types
"long long"
93 if
{[cctest
-cflags
-fno
-unwind
-tables
]} {
94 define
-append CCOPTS
-fno
-unwind
-tables
96 if
{[cctest
-cflags
-fno
-asynchronous
-unwind
-tables
]} {
97 define
-append CCOPTS
-fno
-asynchronous
-unwind
-tables
100 cc
-check
-includes sys
/time.h sys
/socket.h netinet
/in.h arpa
/inet.h netdb.h
101 cc
-check
-includes sys
/un.h dlfcn.h unistd.h dirent.h crt_externs.h
105 # Haiku needs
-lnetwork
, Solaris needs
-lnsl
106 if
{[cc
-check
-function
-in
-lib inet_ntop
{nsl network
}]} {
107 # This does nothing if no libs are needed
108 cc
-with
[list
-libs
[get
-define lib_inet_ntop
]]
109 define
-append LDLIBS
[get
-define lib_inet_ntop
]
111 # Solaris needs
-lsocket
, Windows needs
-lwsock32
112 if
{[cc
-check
-function
-in
-lib socket socket
]} {
113 define
-append LDLIBS
[get
-define lib_socket
]
116 cc
-check
-functions ualarm lstat fork vfork system select execvpe
117 cc
-check
-functions geteuid mkstemp realpath isatty
118 cc
-check
-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
119 cc
-check
-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
120 cc
-check
-functions shutdown socketpair isinf isnan link symlink fsync dup umask
121 cc
-check
-functions localtime gmtime strptime timegm clock_gettime
123 if
{[cc
-check
-function
-in
-lib backtrace execinfo
]} {
124 define
-append LDLIBS
[get
-define lib_backtrace
]
127 if
{[cc
-check
-functions sysinfo
]} {
128 cc
-with
{-includes sys
/sysinfo.h
} {
129 cc
-check
-members
"struct sysinfo.uptime"
133 cc
-with
{-includes fcntl.h
} {
134 cc
-check
-types
"struct flock"
138 cc
-check
-functions fseeko ftello
140 define TCL_LIBRARY
[get
-define prefix
]/lib
/jim
142 lassign
[split
[get
-define host
] -] host_cpu host_vendor host_os
143 # Scrub revision from the host_os
144 regsub
-all
{[0-9.
]} $host_os
{} host_os
146 switch
-glob
-- $host_os
{
148 # We provide our own implementation of dlopen for mingw32
149 define
-feature dlopen
-compat
150 define
-feature winconsole
151 define TCL_PLATFORM_OS $host_os
152 define TCL_PLATFORM_PLATFORM windows
153 define TCL_PLATFORM_PATH_SEPARATOR
{;}
156 # Note that cygwin is considered a unix platform
157 define TCL_PLATFORM_OS $host_os
158 define TCL_PLATFORM_PLATFORM unix
159 define TCL_PLATFORM_PATH_SEPARATOR
:
164 cc
-check
-tools ar ranlib strip
165 define tclsh
[info nameofexecutable
]
167 # We only support silent
-rules for GNU Make
168 define NO_SILENT_RULES
169 if
{[get
-define AM_SILENT_RULES
0]} {
170 if
{[cc
-check
-progs
[get
-define MAKE make
]]} {
171 # Are we using GNU make?
172 catch
{exec
[get
-define MAKE
] --version
} makeversion
173 if
{[string match
"GNU Make*" $makeversion
]} {
174 define NO_SILENT_RULES
0
179 if
{[opt
-bool docs
]} {
180 if
{[cc
-check
-progs asciidoc sed
]} {
181 define INSTALL_DOCS docs
184 define INSTALL_DOCS shipped
187 define INSTALL_DOCS nodocs
190 if
{![cc
-check
-functions _NSGetEnviron
]} {
191 msg
-checking
"Checking environ declared in unistd.h..."
192 if
{[cctest
-cflags
{-D_GNU_SOURCE
-D_POSIX_SOURCE
} -includes unistd.h
-code
{char
**ep
= environ
;}]} {
193 define NO_ENVIRON_EXTERN
200 # Windows has a mkdir with no permission arg
201 cc
-check
-includes sys
/types.h sys
/stat.h
202 msg
-checking
"Checking for mkdir with one arg..."
203 if
{[cctest
-includes
{sys
/types.h sys
/stat.h
} -code
{mkdir("/dummy");}]} {
204 define HAVE_MKDIR_ONE_ARG
210 cc
-with
{-includes sys
/stat.h
} {
211 foreach i
{S_IXUSR S_IRWXG S_IRWXO
} {
212 if
{![cc
-check
-decls $i
]} {
221 # Returns
1 if either the given option is enabled
, or
222 #
--full is enabled and the option isn
't explicitly disabled
224 proc opt-bool-or-full {opt} {
225 if {[opt-bool $opt]} {
228 if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
234 if {[opt-bool-or-full utf8]} {
235 msg-result "Enabling UTF-8"
237 define-append CCOPTS -DUSE_UTF8
238 define PARSE_UNIDATA_FLAGS ""
243 if {[opt-bool maintainer]} {
244 msg-result "Enabling maintainer settings"
245 define JIM_MAINTAINER
247 # If --math or --full and not --disable-math
248 if {[opt-bool-or-full math]} {
249 msg-result "Enabling math functions"
250 define JIM_MATH_FUNCTIONS
251 cc-check-function-in-lib sin m
252 define-append LDLIBS [get-define lib_sin]
254 if {[opt-bool-or-full ipv6]} {
255 msg-result "Enabling IPv6"
258 define-append PKG_CONFIG_REQUIRES ""
259 if {[opt-bool-or-full ssl]} {
260 if {[pkg-config-init 0]} {
261 foreach pkg {openssl libssl} {
262 if {[pkg-config $pkg]} {
264 define-append LDLIBS [pkg-config-get $pkg LIBS]
265 define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
266 define-append CCOPTS [pkg-config-get $pkg CFLAGS]
267 msg-result "Enabling SSL ($pkg)"
268 define-append PKG_CONFIG_REQUIRES $pkg
273 if {![is-defined JIM_SSL]} {
274 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]} {
275 msg-result "Enabling SSL"
277 define-append LDLIBS [get-define lib_ERR_error_string] [get-define lib_TLSv1_2_method]
278 } elseif {[opt-bool ssl]} {
279 user-error "SSL support requires OpenSSL"
283 if {[opt-bool-or-full lineedit]} {
284 if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
285 msg-result "Enabling line editing"
287 define-append PARSE_UNIDATA_FLAGS -width
288 lappend extra_objs linenoise.o
291 if {[opt-bool references]} {
292 msg-result "Enabling references"
293 define JIM_REFERENCES
295 if {[opt-bool shared with-jim-shared]} {
296 msg-result "Building shared library"
298 msg-result "Building static library"
301 define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]
302 define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]]
303 define JIM_INSTALL [opt-bool install-jim]
304 define JIM_DOCS [opt-bool docs]
305 define JIM_RANDOMISE_HASH [opt-bool random-hash]
306 define docdir [opt-str docdir o {${prefix}/docs/jim}]
308 # Attributes of the extensions
309 # tcl=Pure Tcl extension
310 # static=Can't be built as a module
311 # off
=Off unless explicitly enabled
312 # optional
=Off by default
, but selected by
--full
313 # cpp
=Is a C
++ extension
315 dict set extdb attrs
{
318 binary
{ tcl optional
}
329 nshelper
{ tcl optional
}
342 stdlib
{ tcl static
}
344 tclcompat
{ tcl static
}
345 tclprefix
{ optional
}
350 # Additional information about certain extensions
351 # dep
=list of extensions which are required for this extension
352 # check
=[expr
] expression to evaluate to determine if the extension can be used
353 # libdep
=list of
'define' symbols for dependent libraries
354 dict set extdb info
{
356 exec
{ check
{([have
-feature vfork
] && [have
-feature waitpid
]) ||
[have
-feature system
]} }
358 load
{ check
{[have
-feature dlopen
-compat
] ||
[cc
-check
-function
-in
-lib dlopen dl
]} libdep lib_dlopen
}
359 mk
{ check
{[check
-metakit
]} libdep lib_mk
}
360 namespace
{ dep nshelper
}
361 posix
{ check
{[have
-feature waitpid
]} }
362 readdir
{ check
{[have
-feature opendir
]} }
363 readline
{ pkg
-config readline check
{[cc
-check
-function
-in
-lib readline readline
]} libdep lib_readline
}
364 rlprompt
{ dep readline
}
366 sdl
{ pkg
-config SDL_gfx check
{[cc
-check
-function
-in
-lib SDL_SetVideoMode SDL
] && [cc
-check
-function
-in
-lib rectangleRGBA SDL_gfx
]}
367 libdep
{lib_SDL_SetVideoMode lib_rectangleRGBA
}
369 signal
{ check
{[have
-feature sigaction
]} }
370 sqlite3
{ pkg
-config sqlite3 check
{[cc
-check
-function
-in
-lib sqlite3_prepare_v2 sqlite3
]} libdep lib_sqlite3_prepare_v2
}
371 zlib
{ pkg
-config zlib check
{[cc
-check
-function
-in
-lib deflate z
]} libdep lib_deflate
}
372 syslog
{ check
{[have
-feature syslog
]} }
374 win32
{ check
{[have
-feature windows
]} }
377 # autosetup cc
-check
-function
-in
-library can
't handle C++ libraries
378 proc check-metakit {} {
380 msg-checking "Checking for Metakit..."
381 cc-with {-lang c++} {
382 if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} {
387 msg-result "not found"
393 # Takes a list of module names, separated by spaces or commas
394 # and returns them as a single list
395 proc join-ext-names {list} {
397 # Replace comma with space in each list then concatenate the result
399 lappend result {*}[string map {, " "} $l]
404 # Set up the withinfo array based on what the user selected
406 set withinfo(without) [join-ext-names [opt-val {without-ext with-out-jim-ext}]]
407 set withinfo(ext) [join-ext-names [opt-val {with-ext with-jim-ext}]]
408 set withinfo(mod) [join-ext-names [opt-val {with-mod with-jim-extmod}]]
409 set withinfo(nodefault) 0
410 set withinfo(optional) [opt-bool full]
411 if {$withinfo(without) eq "default"} {
412 set withinfo(without) {}
413 set withinfo(nodefault) 1
416 # Now go check everything - see autosetup/local.tcl
417 array set extinfo [check-extensions]
420 if {[have-feature windows]} {
421 lappend extra_objs jim-win32compat.o
423 if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} {
424 user-error "cygwin/mingw require --shared for dynamic modules"
427 if {[have-feature termios.h]} {
428 lappend extra_objs jim-tty.o
431 if {[ext-get-status regexp] in {y m}} {
432 if {![have-feature regcomp]} {
433 # No regcomp means we need to use the built-in version
438 if {$jimregexp || [opt-bool jim-regexp]} {
439 msg-result "Using built-in regexp"
442 # If the built-in regexp overrides the system regcomp, etc.
443 # jim must be built shared so that the correct symbols are found
444 if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} {
445 user-error "Must use --shared with regexp module and built-in regexp"
450 if
{"signal" ni $
extinfo(static
-c
)} {
451 lappend extra_objs jim
-nosignal.o
454 if
{[ext
-get
-status load
] eq
"n"} {
455 # If we don
't have load, no need to support shared objects
456 define SH_LINKFLAGS ""
459 msg-result "Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
460 if {[llength $extinfo(module-tcl)]} {
461 msg-result "Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
463 if {[llength $extinfo(module-c)]} {
464 msg-result "Jim dynamic extensions: [lsort $extinfo(module-c)]"
467 define STATIC_EXTS [concat $extinfo(static-c) $extinfo(static-tcl)]
468 define C_EXT_OBJS [prefix jim- [suffix .o $extinfo(static-c)]]
469 define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)]
470 define C_EXT_SHOBJS [suffix .so $extinfo(module-c)]
471 define TCL_EXTS [suffix .tcl $extinfo(module-tcl)]
472 define EXTRA_OBJS $extra_objs
474 # Restore the user-specified LIBS
477 make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
478 make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
479 make-template Makefile.in
480 make-template build-jim-ext.in
481 make-template jimtcl.pc.in
483 catch {exec chmod +x build-jim-ext}