1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376
|
# vim:se syn=tcl:
#
# Note: modules which support options *must* be included before 'options'
use cc cc-shared
options {
utf8 => "include support for utf8-encoded strings"
lineedit=1 => "disable line editing"
references=1 => "disable support for references"
math => "include support for math functions"
ipv6 => "include ipv6 support in the aio extension"
maintainer => {enable the [debug] command and JimPanic}
full => "Enable some optional features: ipv6, math, utf8, binary, oo, tree"
with-jim-shared shared => "build a shared library instead of a static library"
jim-regexp => "use the built-in (Tcl-compatible) regexp, even if POSIX regex is available"
with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
Specify additional jim extensions to include.
These are enabled by default:
aio - ANSI I/O, including open and socket
eventloop - after, vwait, update
array - Tcl-compatible array command
clock - Tcl-compatible clock command
exec - Tcl-compatible exec command
file - Tcl-compatible file command
glob - Tcl-compatible glob command
readdir - Required for glob
package - Package management with the package command
load - Load binary extensions at runtime with load or package
posix - Posix APIs including os.fork, os.wait, pid
regexp - Tcl-compatible regexp, regsub commands
signal - Signal handling
stdlib - Built-in commands including lassign, lambda, alias
syslog - System logging with syslog
tclcompat - Tcl compatible read, gets, puts, parray, case, ...
These are disabled by default:
nvp - Name-value pairs C-only API
oo - Jim OO extension
tree - OO tree structure, similar to tcllib ::struct::tree
binary - Tcl-compatible 'binary' command
readline - Interface to libreadline
rlprompt - Tcl wrapper around the readline extension
sqlite - Interface to sqlite
sqlite3 - Interface to sqlite3
win32 - Interface to win32
}
with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
Specify jim extensions to exclude.
If 'default' is given, the default extensions will not be added.
}
with-jim-extmod: {with-mod:"ext1 ext2 ..."} => {
Specify jim extensions to build as separate modules (either C or Tcl).
Note that not all extensions can be built as loadable modules.
}
# To help out openocd with automake
install-jim=1
}
cc-check-types "long long"
cc-check-includes sys/socket.h netinet/in.h arpa/inet.h netdb.h
cc-check-includes sys/un.h dlfcn.h unistd.h crt_externs.h
cc-check-functions ualarm sysinfo lstat fork vfork system select
cc-check-functions backtrace geteuid mkstemp realpath strptime gettimeofday
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist
cc-check-functions syslog opendir readlink sleep usleep pipe inet_ntop getaddrinfo
define TCL_LIBRARY [get-define prefix]/lib/jim
lassign [split [get-define host] -] host_cpu host_vendor host_os
# Scrub revision from the host_os
regsub -all {[0-9.]} $host_os {} host_os
switch -glob -- $host_os {
mingw* {
# We provide our own implementation of dlopen for mingw32
define-feature dlopen-compat
define TCL_PLATFORM_OS $host_os
define TCL_PLATFORM_PLATFORM windows
define TCL_PLATFORM_PATH_SEPARATOR {;}
}
default {
# Note that cygwin is considered a unix platform
define TCL_PLATFORM_OS $host_os
define TCL_PLATFORM_PLATFORM unix
define TCL_PLATFORM_PATH_SEPARATOR :
}
}
# Find some tools
cc-check-tools ar ranlib strip
define tclsh [info nameofexecutable]
if {![cc-check-functions _NSGetEnviron]} {
msg-checking "Checking environ declared in unistd.h..."
if {[cctest -cflags -D_GNU_SOURCE -includes unistd.h -code {char **ep = environ;}]} {
define NO_ENVIRON_EXTERN
msg-result "yes"
} else {
msg-result "no"
}
}
# Windows has a mkdir with no permission arg
cc-check-includes sys/types.h sys/stat.h
msg-checking "Checking for mkdir with one arg..."
if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
define HAVE_MKDIR_ONE_ARG
msg-result yes
} else {
msg-result no
}
set extra_objs {}
set jimregexp 0
if {[opt-bool utf8 full]} {
msg-result "Enabling UTF-8"
define JIM_UTF8
incr jimregexp
} else {
define JIM_UTF8 0
}
if {[opt-bool maintainer]} {
msg-result "Enabling maintainer settings"
define JIM_MAINTAINER
}
if {[opt-bool math full]} {
msg-result "Enabling math functions"
define JIM_MATH_FUNCTIONS
define-append LIBS -lm
}
if {[opt-bool ipv6 full]} {
msg-result "Enabling IPv6"
define JIM_IPV6
}
if {[opt-bool lineedit full] && [cc-check-includes termios.h] && [cc-check-functions isatty]} {
msg-result "Enabling line editing"
define USE_LINENOISE
lappend extra_objs linenoise.o
cc-check-functions isatty
}
if {[opt-bool references]} {
msg-result "Enabling references"
define JIM_REFERENCES
}
if {[opt-bool shared with-jim-shared]} {
msg-result "Building shared library"
define JIM_LIBTYPE shared
} else {
msg-result "Building static library"
define JIM_LIBTYPE static
}
if {[opt-bool install-jim]} {
define install_jim 1
} else {
define install_jim ""
}
# Note: Extension handling is mapped directly from the configure.ac
# implementation
set without [join [opt-val {without-ext with-out-jim-ext}]]
set withext [join [opt-val {with-ext with-jim-ext}]]
set withmod [join [opt-val {with-mod with-jim-extmod}]]
# Tcl extensions
set ext_tcl "stdlib glob tclcompat tree rlprompt oo binary"
# C extensions
set ext_c "load package readdir array clock exec file posix regexp signal aio eventloop pack syslog nvp readline sqlite sqlite3 win32"
# Tcl extensions which can be modules
set ext_tcl_mod "glob tree rlprompt oo binary"
# C extensions which can be modules
set ext_c_mod "readdir array clock file posix regexp syslog readline pack sqlite sqlite3 win32"
# All extensions
set ext_all [concat $ext_c $ext_tcl]
# Default static extensions
set ext_default "stdlib load package readdir glob array clock exec file posix regexp signal tclcompat aio eventloop syslog"
if {[opt-bool full]} {
lappend ext_default tree binary
}
if {$without eq "default"} {
set ext_default stdlib
set without {}
}
# Check valid extension names
foreach i [concat $withext $without $withmod] {
if {$i ni $ext_all} {
user-error "Unknown extension: $i"
}
}
# needs_xxx="expression" means that the expr must eval to 1 to select the extension
# dep_xxx="yyy zzz" means that if xxx is selected, so is yyy and zzz
set dep(glob) readdir
set dep(rlprompt) readline
set dep(tree) oo
set dep(binary) pack
set needs(aio) {expr {[cc-check-function-in-lib socket socket] || 1}}
set needs(exec) {expr {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]}}
set needs(load) {expr {[cc-check-function-in-lib dlopen dl] || [have-feature dlopen-compat]}}
set needs(posix) {have-feature waitpid}
set needs(readdir) {have-feature opendir}
set needs(readline) {cc-check-function-in-lib readline readline}
set needs(signal) {expr {[have-feature sigaction] && [have-feature vfork]}}
set needs(sqlite) {cc-check-function-in-lib sqlite_open sqlite}
set needs(sqlite3) {cc-check-function-in-lib sqlite3_open sqlite3}
set needs(syslog) {have-feature syslog}
set needs(eventloop) {expr {[have-feature select] || [have-feature usleep]}}
set needs(win32) {have-feature windows}
# First handle dependencies. If an extension is enabled, also enable its dependency
foreach i [concat $ext_default $withext] {
if {$i in $without} {
continue
}
if {[info exists dep($i)]} {
lappend withext {*}$dep($i)
}
}
foreach i $withmod {
if {[info exists dep($i)]} {
# Theoretically, a mod could depend upon something which must be static
# If already configured static, don't make it a module
foreach d $dep($i) {
if {$d ni $withext} {
lappend withmod $d
}
}
}
}
# Now that we know what the platform supports:
# For all known extensions:
# - If it is disabled, remove it
# - Otherwise, check to see if it's pre-requisites are met
# - If yes, add it if it is enabled or is a default
# - If no, error if it is enabled, or do nothing otherwise
# - Modules may be either C or Tcl
set extmodtcl {}
set extmod {}
set ext {}
foreach i [lsort $ext_all] {
# First discard the extension if disabled or not enabled
if {$i in $without} {
msg-result "Extension $i...disabled"
continue
}
if {$i ni [concat $withext $withmod $ext_default]} {
msg-result "Extension $i...not enabled"
continue
}
# Check dependencies
set met 1
if {[info exists needs($i)]} {
set met [eval $needs($i)]
}
msg-checking "Extension $i..."
# Selected as a module?
if {$i in $withmod} {
if {$i in $ext_tcl_mod} {
# Easy, a Tcl module
msg-result "tcl"
lappend extmodtcl $i
continue
}
if {$i ni $ext_c_mod} {
user-error "not a module"
}
if {!$met} {
user-error "dependencies not met"
}
msg-result "module"
lappend extmod $i
continue
}
# Selected as a static extension?
if {$i in $withext} {
if {!$met} {
user-error "dependencies not met"
}
msg-result "enabled"
lappend ext $i
continue
}
# Enabled by default?
if {$i in $ext_default} {
if {!$met} {
msg-result "disabled (dependencies)"
continue
}
msg-result "enabled (default)"
lappend ext $i
continue
}
}
if {[have-feature windows]} {
lappend extra_objs jim-win32compat.o
if {$extmod ne "" && [get-define JIM_LIBTYPE] eq "static"} {
user-error "cygwin/mingw require --shared for dynamic modules"
}
}
if {"regexp" in "$ext $extmod"} {
# No regcomp means we need to use the built-in version
if {![have-feature regcomp]} {
incr jimregexp
}
}
if {$jimregexp || [opt-bool jim-regexp]} {
msg-result "Using built-in regexp"
define JIM_REGEXP
# If the built-in regexp overrides the system regcomp, etc.
# jim must be built shared so that the correct symbols are found
if {"regexp" in $extmod && [get-define JIM_LIBTYPE] eq "static" && [have-feature regcomp]} {
user-error "Must use --shared with regexp module and built-in regexp"
}
}
if {"load" ni $ext} {
# If we don't have load, no need to support shared objects
define SH_LINKFLAGS ""
}
msg-result "Jim static extensions: [lsort $ext]"
if {$extmodtcl ne ""} {
msg-result "Jim Tcl extensions: [lsort $extmodtcl]"
}
if {$extmod ne ""} {
msg-result "Jim dynamic extensions: [lsort $extmod]"
}
# Separate out the static extensions into C and Tcl
set ext_static_c {}
set ext_static_tcl {}
foreach e $ext {
define jim_ext_$e
if {$e in $ext_tcl} {
lappend ext_static_tcl $e
} else {
lappend ext_static_c $e
}
}
define JIM_STATIC_C_EXTS $ext_static_c
define JIM_STATIC_TCL_EXTS $ext_static_tcl
define JIM_TCL_EXTENSIONS $extmodtcl
define JIM_MOD_EXTENSIONS $extmod
define EXTRA_OBJS $extra_objs
make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -none *
make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_*}
make-template Makefile.in
|