diff options
author | Steve Bennett <steveb@workware.net.au> | 2011-12-03 23:56:20 +1000 |
---|---|---|
committer | Steve Bennett <steveb@workware.net.au> | 2011-12-08 12:48:34 +1000 |
commit | 325ecc8c0f2847f0669941cbbe2cf99c0674d5f7 (patch) | |
tree | a43e1148405741295f143a2edd580fd9cee04224 /auto.def | |
parent | 92f3f1b45b917bb14e61fad225fcd8642dcd5725 (diff) | |
download | jimtcl-325ecc8c0f2847f0669941cbbe2cf99c0674d5f7.zip jimtcl-325ecc8c0f2847f0669941cbbe2cf99c0674d5f7.tar.gz jimtcl-325ecc8c0f2847f0669941cbbe2cf99c0674d5f7.tar.bz2 |
Better extension selection in auto.def
The old implementation was cumbersome for adding new extensions
The new implementation is still too complex :-(
Signed-off-by: Steve Bennett <steveb@workware.net.au>
Diffstat (limited to 'auto.def')
-rw-r--r-- | auto.def | 310 |
1 files changed, 97 insertions, 213 deletions
@@ -3,6 +3,7 @@ # Note: modules which support options *must* be included before 'options' use cc cc-shared cc-db +use local options { utf8 => "include support for utf8-encoded strings" @@ -134,22 +135,6 @@ if {[cctest -includes {sys/types.h sys/stat.h} -code {mkdir("/dummy");}]} { msg-result no } -# autosetup can't handle C++ libraries -proc check-metakit {} { - set found 0 - cc-with {-lang c++} { - msg-checking "Checking for Metakit..." - if {[cctest -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} { - msg-result ok - define lib_mk -lmk4 - incr found - } else { - msg-result "not found" - } - } - return $found -} - set extra_objs {} set jimregexp 0 @@ -193,189 +178,107 @@ if {[opt-bool shared with-jim-shared]} { } define JIM_INSTALL [opt-bool 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" -# Native extensions -set ext_c "load package readdir array clock exec file posix regexp signal aio eventloop pack syslog readline mk sqlite sqlite3 win32 sdl" - -# C++ extensions -set ext_cxx "mk" - -# Tcl extensions which can be modules -set ext_tcl_mod "glob tree rlprompt oo binary" -# Native extensions which can be modules -set ext_c_mod "readdir array clock file posix regexp syslog readline pack mk sqlite sqlite3 win32 sdl" - -# 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 {} +# Attributes of the extensions +# tcl=Pure Tcl extension +# static=Can't be built as a module +# optional=Not selected by default +# full=Select if the --full option is set +# cpp=Is a C++ extension +global extdb +dict set extdb attrs { + aio { static } + array {} + binary { tcl optional full } + clock {} + eventloop { static } + exec { static } + file {} + glob { tcl } + load { static } + mk { cpp optional } + oo { tcl optional full } + pack { optional full } + package { static } + posix {} + readdir {} + readline { optional } + regexp {} + rlprompt { tcl optional } + sdl { optional } + signal { static } + sqlite3 { optional } + stdlib { tcl static } + syslog { optional } + tclcompat { tcl static } + tree { tcl optional full } + win32 { optional } } -# Check valid extension names -foreach i [concat $withext $without $withmod] { - if {$i ni $ext_all} { - user-error "Unknown extension: $i" - } +# Additional information about certain extensions +# dep=list of extensions which are required for this extension +# check=[expr] expression to evaluate to determine if the extension can be used +# libdep=list of 'define' symbols for dependent libraries +dict set extdb info { + binary { dep pack } + exec { check {([have-feature vfork] && [have-feature waitpid]) || [have-feature system]} } + glob { dep readdir } + load { check {[have-feature dlopen-compat] || [cc-check-function-in-lib dlopen dl]} libdep lib_dlopen } + mk { check {[check-metakit]} libdep lib_mk } + posix { check {[have-feature waitpid]} } + readdir { check {[have-feature opendir]} } + readline { check {[cc-check-function-in-lib readline readline]} } + rlprompt { dep readline } + sdl { 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]} } + sqlite3 { check {[cc-check-function-in-lib sqlite3_open sqlite3]} libdep lib_sqlite3_open } + syslog { check {[have-feature syslog]} } + tree { dep oo } + win32 { check {[have-feature windows]} } } -# 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(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 libdep(load) lib_dlopen -set needs(posix) {have-feature waitpid} -set needs(readdir) {have-feature opendir} -set needs(readline) {cc-check-function-in-lib readline readline} -set libdep(readline) lib_readline -set needs(signal) {expr {[have-feature sigaction] && [have-feature vfork]}} -set needs(mk) {check-metakit} -set libdep(mk) lib_mk -set needs(sqlite) {cc-check-function-in-lib sqlite_open sqlite} -set libdep(sqlite) lib_sqlite_open -set needs(sqlite3) {cc-check-function-in-lib sqlite3_open sqlite3} -set libdep(sqlite3) lib_sqlite3_open -set needs(syslog) {have-feature syslog} -set needs(win32) {have-feature windows} -set needs(sdl) {expr {[cc-check-function-in-lib SDL_SetVideoMode SDL] && [cc-check-function-in-lib rectangleRGBA SDL_gfx]}} -set libdep(sdl) {lib_SDL_SetVideoMode lib_rectangleRGBA} - -# 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) +# autosetup cc-check-function-in-library can't handle C++ libraries +proc check-metakit {} { + set found 0 + msg-checking "Checking for Metakit..." + if {[cctest -lang c++ -includes mk4.h -libs -lmk4 -code {c4_Storage dummy();}]} { + msg-result ok + define lib_mk -lmk4 + incr found + } else { + msg-result "not found" } + return $found } -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 - } - } - } +# 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(full) [opt-bool full] +set withinfo(nodefault) 0 +if {$withinfo(without) eq "default"} { + set withinfo(without) {} + set withinfo(nodefault) 1 } -# 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)] - } - - define LDLIBS_$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 - if {[info exists libdep($i)]} { - foreach j $libdep($i) { - define-append LDLIBS_$i [get-define $j ""] - } - } - continue - } - - # Selected as a static extension? - if {$i in $withext} { - if {!$met} { - user-error "dependencies not met" - } - msg-result "enabled" - } elseif {$i in $ext_default} { - if {!$met} { - msg-result "disabled (dependencies)" - continue - } - msg-result "enabled (default)" - } else { - continue - } - - lappend ext $i - if {[info exists libdep($i)]} { - foreach j $libdep($i) { - define-append LDLIBS [get-define $j ""] - } - } -} +# Now go check everything - see autosetup/local.tcl +array set extinfo [check-extensions] +# Now special checks if {[have-feature windows]} { lappend extra_objs jim-win32compat.o - if {$extmod ne "" && [get-define JIM_LIBTYPE] eq "static"} { + if {[llength $extinfo(module-c)] && [get-define JIM_STATICLIB]} { 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 {[ext-get-status regexp] in {y m}} { if {![have-feature regcomp]} { + # No regcomp means we need to use the built-in version incr jimregexp } } @@ -386,48 +289,29 @@ if {$jimregexp || [opt-bool 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]} { + if {[ext-get-status regexp] eq "m" && [get-define JIM_STATICLIB] && [have-feature regcomp]} { user-error "Must use --shared with regexp module and built-in regexp" } } -if {"load" ni $ext} { + +if {[ext-get-status load] eq "n"} { # 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]" +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)]" } - -# 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 - } -} - -# If there are any static C++ extensions, jimsh must be linked using -# the C++ compiler -foreach e $ext_static_c { - if {$e in $ext_cxx} { - define HAVE_CXX_EXTENSIONS - } +if {[llength $extinfo(module-c)]} { + msg-result "Jim dynamic extensions: [lsort $extinfo(module-c)]" } -define STATIC_EXTS [concat $ext_static_c $ext_static_tcl] -define C_EXT_OBJS [prefix jim- [suffix .o $ext_static_c]] -define TCL_EXT_OBJS [suffix .o $ext_static_tcl] -define C_EXT_SHOBJS [suffix .so $extmod] -define TCL_EXTS [suffix .tcl $extmodtcl] +define STATIC_EXTS [concat $extinfo(static-c) $extinfo(static-tcl)] +define C_EXT_OBJS [prefix jim- [suffix .o $extinfo(static-c)]] +define TCL_EXT_OBJS [suffix .o $extinfo(static-tcl)] +define C_EXT_SHOBJS [suffix .so $extinfo(module-c)] +define TCL_EXTS [suffix .tcl $extinfo(module-tcl)] define EXTRA_OBJS $extra_objs make-config-header jim-config.h -auto {HAVE_LONG_LONG* JIM_UTF8} -none * |