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 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
{sys
/types.h sys
/stat.h
}} {
134 cc
-check
-members
"struct stat.st_mtimespec"
135 cc
-check
-members
"struct stat.st_mtim"
138 cc
-with
{-includes fcntl.h
} {
139 cc
-check
-types
"struct flock"
143 cc
-check
-functions fseeko ftello
145 define TCL_LIBRARY
[get
-define prefix
]/lib
/jim
147 lassign
[split
[get
-define host
] -] host_cpu host_vendor host_os
148 # Scrub revision from the host_os
149 regsub
-all
{[0-9.
]} $host_os
{} host_os
151 switch
-glob
-- $host_os
{
153 # We provide our own implementation of dlopen for mingw32
154 define
-feature dlopen
-compat
155 define
-feature winconsole
156 define TCL_PLATFORM_OS $host_os
157 define TCL_PLATFORM_PLATFORM windows
158 define TCL_PLATFORM_PATH_SEPARATOR
{;}
161 # Note that cygwin is considered a unix platform
162 define TCL_PLATFORM_OS $host_os
163 define TCL_PLATFORM_PLATFORM unix
164 define TCL_PLATFORM_PATH_SEPARATOR
:
169 cc
-check
-tools ar ranlib strip
170 define tclsh
[info nameofexecutable
]
172 # We only support silent
-rules for GNU Make
173 define NO_SILENT_RULES
174 if
{[get
-define AM_SILENT_RULES
0]} {
175 if
{[cc
-check
-progs
[get
-define MAKE make
]]} {
176 # Are we using GNU make?
177 catch
{exec
[get
-define MAKE
] --version
} makeversion
178 if
{[string match
"GNU Make*" $makeversion
]} {
179 define NO_SILENT_RULES
0
184 if
{[opt
-bool docs
]} {
185 if
{[cc
-check
-progs asciidoc sed
]} {
186 define INSTALL_DOCS docs
189 define INSTALL_DOCS shipped
192 define INSTALL_DOCS nodocs
195 if
{![cc
-check
-functions _NSGetEnviron
]} {
196 msg
-checking
"Checking environ declared in unistd.h..."
197 if
{[cctest
-cflags
{-D_GNU_SOURCE
-D_POSIX_SOURCE
} -includes unistd.h
-code
{char
**ep
= environ
;}]} {
198 define NO_ENVIRON_EXTERN
205 # Windows has a mkdir with no permission arg
206 cc
-check
-includes sys
/types.h sys
/stat.h
207 msg
-checking
"Checking for mkdir with one arg..."
208 if
{[cctest
-includes
{sys
/types.h sys
/stat.h
} -code
{mkdir("/dummy");}]} {
209 define HAVE_MKDIR_ONE_ARG
215 cc
-with
{-includes sys
/stat.h
} {
216 foreach i
{S_IXUSR S_IRWXG S_IRWXO
} {
217 if
{![cc
-check
-decls $i
]} {
226 # Returns
1 if either the given option is enabled
, or
227 #
--full is enabled and the option isn
't explicitly disabled
229 proc opt-bool-or-full {opt} {
230 if {[opt-bool $opt]} {
233 if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
239 if {[opt-bool-or-full utf8]} {
240 msg-result "Enabling UTF-8"
242 define-append CCOPTS -DUSE_UTF8
243 define PARSE_UNIDATA_FLAGS ""
248 if {[opt-bool maintainer]} {
249 msg-result "Enabling maintainer settings"
250 define JIM_MAINTAINER
252 # If --math or --full and not --disable-math
253 if {[opt-bool-or-full math]} {
254 msg-result "Enabling math functions"
255 define JIM_MATH_FUNCTIONS
256 cc-check-function-in-lib sin m
257 define-append LDLIBS [get-define lib_sin]
259 if {[opt-bool-or-full ipv6]} {
260 msg-result "Enabling IPv6"
263 define-append PKG_CONFIG_REQUIRES ""
264 if {[opt-bool-or-full ssl]} {
265 if {[pkg-config-init 0]} {
266 foreach pkg {openssl libssl} {
267 if {[pkg-config $pkg]} {
269 define-append LDLIBS [pkg-config-get $pkg LIBS]
270 define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
271 define-append CCOPTS [pkg-config-get $pkg CFLAGS]
272 msg-result "Enabling SSL ($pkg)"
273 define-append PKG_CONFIG_REQUIRES $pkg
278 if {![is-defined JIM_SSL]} {
279 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]} {
280 msg-result "Enabling SSL"
282 define-append LDLIBS [get-define lib_ERR_error_string] [get-define lib_TLSv1_2_method]
283 } elseif {[opt-bool ssl]} {
284 user-error "SSL support requires OpenSSL"
287 # Later versions deprecate TLSv1_2_method, but older versions don't have TLS_method
288 if
{![cc
-check
-function
-in
-lib TLS_method ssl
]} {
289 define
-append CCOPTS
-DUSE_TLSv1_2_method
292 if
{[opt
-bool
-or
-full lineedit
]} {
293 if
{([cc
-check
-includes termios.h
] && [have
-feature isatty
]) ||
[have
-feature winconsole
]} {
294 msg
-result
"Enabling line editing"
296 define
-append PARSE_UNIDATA_FLAGS
-width
297 lappend extra_objs linenoise.o
300 if
{[opt
-bool references
]} {
301 msg
-result
"Enabling references"
302 define JIM_REFERENCES
304 if
{[opt
-bool shared with
-jim
-shared
]} {
305 msg
-result
"Building shared library"
307 msg
-result
"Building static library"
310 define VERSION
[format
%.2f
[expr
{[get
-define JIM_VERSION
] / 100.0}]]
311 define LIBSOEXT
[format
[get
-define SH_SOEXTVER
] [get
-define VERSION
]]
312 if
{[get
-define libdir
] ni
{/lib
/usr
/lib
}} {
313 define SH_LINKRPATH_FLAGS
[format
[get
-define SH_LINKRPATH
] [get
-define libdir
]]
315 define SH_LINKRPATH_FLAGS
""
317 define JIM_INSTALL
[opt
-bool install
-jim
]
318 define JIM_DOCS
[opt
-bool docs
]
319 define JIM_RANDOMISE_HASH
[opt
-bool random
-hash
]
320 define docdir
[opt
-str docdir o
{$
{prefix
}/docs
/jim
}]
322 # Attributes of the extensions
323 # tcl
=Pure Tcl extension
324 # static
=Can
't be built as a module
325 # off=Off unless explicitly enabled
326 # optional=Off by default, but selected by --full
327 # cpp=Is a C++ extension
329 dict set extdb attrs {
332 binary { tcl optional }
343 nshelper { tcl optional }
356 stdlib { tcl static }
358 tclcompat { tcl static }
359 tclprefix { optional }
364 # Additional information about certain extensions
365 # dep=list of extensions which are required for this extension
366 # check=[expr] expression to evaluate to determine if the extension can be used
367 # libdep=list of 'define
' symbols for dependent libraries
368 dict set extdb info {
370 exec { check {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]} }
372 load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen }
373 mk { check {[check-metakit]} libdep lib_mk }
374 namespace { dep nshelper }
375 posix { check {[have-feature waitpid]} }
376 readdir { check {[have-feature opendir]} }
377 readline { pkg-config readline check {[cc-check-function-in-lib readline readline]} libdep lib_readline}
378 rlprompt { dep readline }
380 sdl { pkg-config SDL_gfx check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}
381 libdep {lib_SDL_SetVideoMode lib_rectangleRGBA}
383 signal { check {[have-feature sigaction]} }
384 sqlite3 { pkg-config sqlite3 check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 }
385 zlib { pkg-config zlib check {[cc-check-function-in-lib deflate z]} libdep lib_deflate }
386 syslog { check {[have-feature syslog]} }
388 win32 { check {[have-feature windows]} }
391 # autosetup cc-check-function-in-library can't handle C
++ libraries
392 proc check
-metakit
{} {
394 msg
-checking
"Checking for Metakit..."
395 cc
-with
{-lang c
++} {
396 if
{[cctest
-includes mk4.h
-libs
-lmk4
-code
{c4_Storage
dummy();}]} {
401 msg
-result
"not found"
407 # Takes a list of module names
, separated by spaces or commas
408 # and returns them as a single list
409 proc join
-ext
-names
{list
} {
411 # Replace comma with space in each list then concatenate the result
413 lappend result
{*}[string map
{, " "} $l
]
418 # Set up the withinfo array based on what the user selected
420 set
withinfo(without
) [join
-ext
-names
[opt
-val
{without
-ext with
-out
-jim
-ext
}]]
421 set
withinfo(ext
) [join
-ext
-names
[opt
-val
{with
-ext with
-jim
-ext
}]]
422 set
withinfo(mod
) [join
-ext
-names
[opt
-val
{with
-mod with
-jim
-extmod
}]]
423 set
withinfo(nodefault
) 0
424 set
withinfo(optional
) [opt
-bool full
]
425 if
{$
withinfo(without
) eq
"default"} {
426 set
withinfo(without
) {}
427 set
withinfo(nodefault
) 1
430 # Now go check everything
- see autosetup
/local.tcl
431 array set extinfo
[check
-extensions
]
434 if
{[have
-feature windows
]} {
435 lappend extra_objs jim
-win32compat.o
437 if
{[llength $
extinfo(module
-c
)] && [get
-define JIM_STATICLIB
]} {
438 user
-error
"cygwin/mingw require --shared for dynamic modules"
441 if
{[have
-feature termios.h
]} {
442 lappend extra_objs jim
-tty.o
445 if
{[ext
-get
-status regexp
] in
{y m
}} {
446 if
{![have
-feature regcomp
]} {
447 # No regcomp means we need to use the built
-in version
452 if
{$jimregexp ||
[opt
-bool jim
-regexp
]} {
453 msg
-result
"Using built-in regexp"
456 # If the built
-in regexp overrides the system regcomp
, etc.
457 # jim must be built shared so that the correct symbols are found
458 if
{[ext
-get
-status regexp
] eq
"m" && [get
-define JIM_STATICLIB
] && [have
-feature regcomp
]} {
459 user
-error
"Must use --shared with regexp module and built-in regexp"
464 if {"signal" ni $extinfo(static-c)} {
465 lappend extra_objs jim-nosignal.o
468 if {[ext-get-status load] eq "n"} {
469 # If we don't have load
, no need to support shared objects
470 define SH_LINKFLAGS
""
473 # Are we cross compiling?
474 if
{[get
-define host
] ne
[get
-define build
]} {
475 define cross_compiling
1
477 define cross_compiling
0
480 msg
-result
"Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
481 if
{[llength $
extinfo(module
-tcl
)]} {
482 msg
-result
"Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
484 if
{[llength $
extinfo(module
-c
)]} {
485 msg
-result
"Jim dynamic extensions: [lsort $extinfo(module-c)]"
488 define STATIC_EXTS
[concat $
extinfo(static
-c
) $
extinfo(static
-tcl
)]
489 define C_EXT_OBJS
[prefix jim
- [suffix .o $
extinfo(static
-c
)]]
490 define TCL_EXT_OBJS
[suffix .o $
extinfo(static
-tcl
)]
491 define C_EXT_SHOBJS
[suffix .so $
extinfo(module
-c
)]
492 define TCL_EXTS
[suffix .tcl $
extinfo(module
-tcl
)]
493 define EXTRA_OBJS $extra_objs
495 # Restore the user
-specified LIBS
498 make
-config
-header jim
-config.h
-auto
{HAVE_LONG_LONG
* JIM_UTF8
} -bare JIM_VERSION
-none
*
499 make
-config
-header jimautoconf.h
-auto
{jim_ext_
* TCL_PLATFORM_
* TCL_LIBRARY USE_
* JIM_
* _FILE_OFFSET
*} -bare
{S_I
*}
500 make
-template Makefile.in
501 make
-template tests
/Makefile.in
502 make
-template build
-jim
-ext.in
503 make
-template jimtcl.pc.in
505 catch
{exec chmod
+x build
-jim
-ext
}