summaryrefslogtreecommitdiff
path: root/auto.def
diff options
context:
space:
mode:
Diffstat (limited to 'auto.def')
-rw-r--r--auto.def224
1 files changed, 187 insertions, 37 deletions
diff --git a/auto.def b/auto.def
index fc32b68..fe6e4a2 100644
--- a/auto.def
+++ b/auto.def
@@ -1,10 +1,14 @@
# vim:se syn=tcl:
#
-define JIM_VERSION 77
+define JIM_VERSION 79
+
+options-defaults {
+ silent-rules 1
+}
# Note: modules which support options *must* be included before 'options'
-use cc cc-shared cc-db cc-lib pkg-config
+use cc cc-shared cc-db cc-lib pkg-config util
use local
options {
@@ -21,7 +25,7 @@ options {
docs=1 => "don't build or install the documentation"
docdir:path => "path to install docs (if built)"
random-hash => "randomise hash tables. more secure but hash table results are not predicable"
- with-jim-ext: {with-ext:"ext1 ext2 ..."} => {
+ with-jim-ext: {with-ext:"ext1,ext2,..."} => {
Specify additional jim extensions to include.
These are enabled by default:
@@ -36,7 +40,7 @@ options {
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
+ posix - Posix APIs including os.fork, os.uptime
regexp - Tcl-compatible regexp, regsub commands
signal - Signal handling
stdlib - Built-in commands including lassign, lambda, alias
@@ -44,24 +48,28 @@ options {
tclcompat - Tcl compatible read, gets, puts, parray, case, ...
namespace - Tcl compatible namespace support
- These are disabled by default:
+ These are disabled by default, but enabled by --full:
oo - Jim OO extension
tree - OO tree structure, similar to tcllib ::struct::tree
binary - Tcl-compatible 'binary' command
+ tclprefix - Support for the tcl::prefix command
+ zlib - Interface to zlib
+ json - JSON encode/decode
+
+ These are disabled unless explicitly enabled:
+
readline - Interface to libreadline
rlprompt - Tcl wrapper around the readline extension
mk - Interface to Metakit
- tclprefix - Support for the tcl::prefix command
sqlite3 - Interface to sqlite3
- zlib - Interface to zlib
win32 - Interface to win32
}
- with-out-jim-ext: {without-ext:"default|ext1 ext2 ..."} => {
+ 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 ..."} => {
+ 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.
}
@@ -73,7 +81,14 @@ options {
# We add detected libs to LDLIBS explicitly
set LIBS [get-define LIBS]
+# In case -Werror is passed in CFLAGS, set -Wno-error when doing checks
+# to prevent warnings from becoming errors
+if {"-Werror" in [get-define CFLAGS] && [cctest -cflags -Wno-error]} {
+ cc-with {-cflags -Wno-error}
+}
+
cc-check-types "long long"
+cc-check-sizeof int
define CCOPTS ""
define CXXOPTS ""
@@ -101,10 +116,15 @@ if {[cc-check-function-in-lib socket socket]} {
}
cc-check-functions ualarm lstat fork vfork system select execvpe
-cc-check-functions backtrace geteuid mkstemp realpath strptime isatty
+cc-check-functions geteuid mkstemp realpath isatty
cc-check-functions regcomp waitpid sigaction sys_signame sys_siglist isascii
cc-check-functions syslog opendir readlink sleep usleep pipe getaddrinfo utimes
-cc-check-functions shutdown socketpair isinf isnan link symlink fsync dup
+cc-check-functions shutdown socketpair isinf isnan link symlink fsync dup umask
+cc-check-functions localtime gmtime strptime clock_gettime
+
+if {[cc-check-function-in-lib backtrace execinfo]} {
+ define-append LDLIBS [get-define lib_backtrace]
+}
if {[cc-check-functions sysinfo]} {
cc-with {-includes sys/sysinfo.h} {
@@ -112,6 +132,11 @@ if {[cc-check-functions sysinfo]} {
}
}
+cc-with {-includes {sys/types.h sys/stat.h}} {
+ cc-check-members "struct stat.st_mtimespec"
+ cc-check-members "struct stat.st_mtim"
+}
+
cc-with {-includes fcntl.h} {
cc-check-types "struct flock"
}
@@ -146,6 +171,29 @@ switch -glob -- $host_os {
cc-check-tools ar ranlib strip
define tclsh [info nameofexecutable]
+# We only support silent-rules for GNU Make
+define NO_SILENT_RULES
+if {[get-define AM_SILENT_RULES 0]} {
+ if {[cc-check-progs [get-define MAKE make]]} {
+ # Are we using GNU make?
+ catch {exec [get-define MAKE] --version} makeversion
+ if {[string match "GNU Make*" $makeversion]} {
+ define NO_SILENT_RULES 0
+ }
+ }
+}
+
+if {[opt-bool docs]} {
+ if {[cc-check-progs asciidoc sed]} {
+ define INSTALL_DOCS docs
+ define HAVE_ASCIIDOC
+ } else {
+ define INSTALL_DOCS shipped
+ }
+} else {
+ define INSTALL_DOCS nodocs
+}
+
if {![cc-check-functions _NSGetEnviron]} {
msg-checking "Checking environ declared in unistd.h..."
if {[cctest -cflags {-D_GNU_SOURCE -D_POSIX_SOURCE} -includes unistd.h -code {char **ep = environ;}]} {
@@ -166,12 +214,35 @@ if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} {
msg-result no
}
+cc-with {-includes sys/stat.h} {
+ foreach i {S_IXUSR S_IRWXG S_IRWXO} {
+ if {![cc-check-decls $i]} {
+ define $i 0
+ }
+ }
+}
+
set extra_objs {}
set jimregexp 0
-if {[opt-bool utf8 full]} {
+# Returns 1 if either the given option is enabled, or
+# --full is enabled and the option isn't explicitly disabled
+#
+proc opt-bool-or-full {opt} {
+ if {[opt-bool $opt]} {
+ return 1
+ }
+ if {[opt-bool full] && [opt-bool -nodefault $opt] != 0} {
+ return 1
+ }
+ return 0
+}
+
+if {[opt-bool-or-full utf8]} {
msg-result "Enabling UTF-8"
define JIM_UTF8
+ define-append CCOPTS -DUSE_UTF8
+ define PARSE_UNIDATA_FLAGS ""
incr jimregexp
} else {
define JIM_UTF8 0
@@ -180,17 +251,19 @@ if {[opt-bool maintainer]} {
msg-result "Enabling maintainer settings"
define JIM_MAINTAINER
}
-if {[opt-bool math full]} {
+# If --math or --full and not --disable-math
+if {[opt-bool-or-full math]} {
msg-result "Enabling math functions"
define JIM_MATH_FUNCTIONS
cc-check-function-in-lib sin m
define-append LDLIBS [get-define lib_sin]
}
-if {[opt-bool ipv6 full]} {
+if {[opt-bool-or-full ipv6]} {
msg-result "Enabling IPv6"
define JIM_IPV6
}
-if {[opt-bool ssl full]} {
+define-append PKG_CONFIG_REQUIRES ""
+if {[opt-bool-or-full ssl]} {
if {[pkg-config-init 0]} {
foreach pkg {openssl libssl} {
if {[pkg-config $pkg]} {
@@ -199,6 +272,7 @@ if {[opt-bool ssl full]} {
define-append LDFLAGS [pkg-config-get $pkg LDFLAGS]
define-append CCOPTS [pkg-config-get $pkg CFLAGS]
msg-result "Enabling SSL ($pkg)"
+ define-append PKG_CONFIG_REQUIRES $pkg
break
}
}
@@ -212,12 +286,20 @@ if {[opt-bool ssl full]} {
user-error "SSL support requires OpenSSL"
}
}
+ # Later versions deprecate TLSv1_2_method, but older versions don't have TLS_method
+ if {![cc-check-function-in-lib TLS_method ssl]} {
+ define-append CCOPTS -DUSE_TLSv1_2_method
+ }
}
-if {[opt-bool lineedit full]} {
+if {[opt-bool-or-full lineedit]} {
if {([cc-check-includes termios.h] && [have-feature isatty]) || [have-feature winconsole]} {
msg-result "Enabling line editing"
define USE_LINENOISE
+ define-append PARSE_UNIDATA_FLAGS -width
lappend extra_objs linenoise.o
+ if {[cc-check-inline] && [is-defined inline]} {
+ define-append CCOPTS -Dinline=[get-define inline]
+ }
}
}
if {[opt-bool references]} {
@@ -230,26 +312,29 @@ if {[opt-bool shared with-jim-shared]} {
msg-result "Building static library"
define JIM_STATICLIB
}
-define LIBSOEXT [format [get-define SH_SOEXTVER] [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]]
+define VERSION [format %.2f [expr {[get-define JIM_VERSION] / 100.0}]]
+define LIBSOEXT [format [get-define SH_SOEXTVER] [get-define VERSION]]
+if {[get-define libdir] ni {/lib /usr/lib}} {
+ define SH_LINKRPATH_FLAGS [format [get-define SH_LINKRPATH] [get-define libdir]]
+} else {
+ define SH_LINKRPATH_FLAGS ""
+}
define JIM_INSTALL [opt-bool install-jim]
define JIM_DOCS [opt-bool docs]
define JIM_RANDOMISE_HASH [opt-bool random-hash]
-if {[opt-val docdir] ne ""} {
- define docdir [opt-val docdir]
-} else {
- define docdir {${prefix}/docs/jim}
-}
+define docdir [opt-str docdir o {${prefix}/docs/jim}]
# Attributes of the extensions
# tcl=Pure Tcl extension
# static=Can't be built as a module
-# optional=Not selected by default
+# off=Off unless explicitly enabled
+# optional=Off by default, but selected by --full
# cpp=Is a C++ extension
global extdb
dict set extdb attrs {
aio { static }
array {}
- binary { tcl }
+ binary { tcl optional }
clock {}
eventloop { static }
exec { static }
@@ -257,8 +342,10 @@ dict set extdb attrs {
glob { tcl }
history {}
interp { }
+ json { optional }
+ jsonencode { tcl optional }
load { static }
- mk { cpp optional }
+ mk { cpp off }
namespace { static }
nshelper { tcl optional }
oo { tcl }
@@ -266,19 +353,19 @@ dict set extdb attrs {
package { static }
posix {}
readdir {}
- readline { optional }
+ readline { off }
regexp {}
- rlprompt { tcl optional }
- sdl { optional }
+ rlprompt { tcl off }
+ sdl { off }
signal { static }
- sqlite3 { optional }
+ sqlite3 { off }
zlib { optional }
stdlib { tcl static }
syslog {}
tclcompat { tcl static }
- tclprefix {}
+ tclprefix { optional }
tree { tcl }
- win32 { optional }
+ win32 { off }
}
# Additional information about certain extensions
@@ -292,6 +379,7 @@ dict set extdb info {
load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen }
mk { check {[check-metakit]} libdep lib_mk }
namespace { dep nshelper }
+ json { dep jsonencode extrasrcs jsmn/jsmn.c }
posix { check {[have-feature waitpid]} }
readdir { check {[have-feature opendir]} }
readline { pkg-config readline check {[cc-check-function-in-lib readline readline]} libdep lib_readline}
@@ -300,7 +388,7 @@ dict set extdb info {
sdl { pkg-config SDL_gfx check {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}
libdep {lib_SDL_SetVideoMode lib_rectangleRGBA}
}
- signal { check {[have-feature sigaction] && [have-feature vfork]} }
+ signal { check {[have-feature sigaction]} }
sqlite3 { pkg-config sqlite3 check {[cc-check-function-in-lib sqlite3_prepare_v2 sqlite3]} libdep lib_sqlite3_prepare_v2 }
zlib { pkg-config zlib check {[cc-check-function-in-lib deflate z]} libdep lib_deflate }
syslog { check {[have-feature syslog]} }
@@ -324,12 +412,24 @@ proc check-metakit {} {
return $found
}
+# Takes a list of module names, separated by spaces or commas
+# and returns them as a single list
+proc join-ext-names {list} {
+ set result {}
+ # Replace comma with space in each list then concatenate the result
+ foreach l $list {
+ lappend result {*}[string map {, " "} $l]
+ }
+ return $result
+}
+
# Set up the withinfo array based on what the user selected
global withinfo
-set withinfo(without) [join [opt-val {without-ext with-out-jim-ext}]]
-set withinfo(ext) [join [opt-val {with-ext with-jim-ext}]]
-set withinfo(mod) [join [opt-val {with-mod with-jim-extmod}]]
+set withinfo(without) [join-ext-names [opt-val {without-ext with-out-jim-ext}]]
+set withinfo(ext) [join-ext-names [opt-val {with-ext with-jim-ext}]]
+set withinfo(mod) [join-ext-names [opt-val {with-mod with-jim-extmod}]]
set withinfo(nodefault) 0
+set withinfo(optional) [opt-bool full]
if {$withinfo(without) eq "default"} {
set withinfo(without) {}
set withinfo(nodefault) 1
@@ -346,6 +446,9 @@ if {[have-feature windows]} {
user-error "cygwin/mingw require --shared for dynamic modules"
}
}
+if {[have-feature termios.h]} {
+ lappend extra_objs jim-tty.o
+}
if {[ext-get-status regexp] in {y m}} {
if {![have-feature regcomp]} {
@@ -365,11 +468,33 @@ if {$jimregexp || [opt-bool jim-regexp]} {
}
}
+foreach mod $extinfo(static-c) {
+ if {[dict exists $extdb info $mod extrasrcs]} {
+ foreach src [dict get $extdb info $mod extrasrcs] {
+ # In case we are building out-of-tree and $src is in a subdir
+ file mkdir [file dirname $src]
+ lappend extra_objs {*}[file rootname $src].o
+ }
+ }
+}
+
+# poor-man's signals
+if {"signal" ni $extinfo(static-c)} {
+ lappend extra_objs jim-nosignal.o
+}
+
if {[ext-get-status load] eq "n"} {
# If we don't have load, no need to support shared objects
define SH_LINKFLAGS ""
}
+# Are we cross compiling?
+if {[get-define host] ne [get-define build]} {
+ define cross_compiling 1
+} else {
+ define cross_compiling 0
+}
+
msg-result "Jim static extensions: [lsort [concat $extinfo(static-tcl) $extinfo(static-c)]]"
if {[llength $extinfo(module-tcl)]} {
msg-result "Jim Tcl extensions: [lsort $extinfo(module-tcl)]"
@@ -388,9 +513,34 @@ define EXTRA_OBJS $extra_objs
# Restore the user-specified LIBS
define LIBS $LIBS
-make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -bare JIM_VERSION -none *
-make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*}
+# Now generate the Makefile rules to build the external C shared objects
+# It is easier to do this here rather than listing them out explicitly in Makefile.in
+set lines {}
+foreach mod $extinfo(module-c) {
+ set objs {}
+ set libs [get-define LDLIBS_$mod]
+ set srcs jim-$mod.c
+ if {[dict exists $extdb info $mod extrasrcs]} {
+ lappend srcs {*}[dict get $extdb info $mod extrasrcs]
+ }
+ lappend lines "$mod.so: $srcs"
+ foreach src $srcs {
+ set obj [file rootname $src].o
+ lappend objs $obj
+ lappend lines "\t\$(ECHO)\t\"\tCC\t$obj\""
+ lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(SHOBJ_CFLAGS) -c -o $obj $src"
+ }
+ lappend lines "\t\$(ECHO)\t\"\tLDSO\t\$@\""
+ lappend lines "\t\$(Q)\$(CC) \$(CFLAGS) \$(LDFLAGS) \$(SHOBJ_LDFLAGS) -o \$@ $objs \$(SH_LIBJIM) $libs"
+ lappend lines ""
+}
+define BUILD_SHOBJS [join $lines \n]
+
+make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8 SIZEOF_INT} -bare JIM_VERSION -none *
+make-config-header jimautoconf.h -auto {jim_ext_* TCL_PLATFORM_* TCL_LIBRARY USE_* JIM_* _FILE_OFFSET*} -bare {S_I*}
make-template Makefile.in
+make-template tests/Makefile.in
make-template build-jim-ext.in
+make-template jimtcl.pc.in
catch {exec chmod +x build-jim-ext}