1 # The complex extension checking is done here.
6 # Final determination of module status
7 dict
set extdb status
{}
9 # Returns 1 if the extension has the attribute
10 proc ext-has
{ext attr
} {
11 expr {$attr in
[dict get
$::extdb attrs
$ext]}
14 # Returns an entry from the extension 'info' table, or $default otherwise
15 proc ext-get
{ext key
{default {}}} {
16 if {[dict exists
$::extdb info $ext $key]} {
17 return [dict get
$::extdb info $ext $key]
23 # Set the status of the extension to the given value, and returns the value
24 proc ext-set-status
{ext value
} {
25 dict
set ::extdb status
$ext $value
29 # Returns the status of the extension, or ? if unknown
30 proc ext-get-status
{ext
} {
31 if {[dict exists
$::extdb status
$ext]} {
32 return [dict get
$::extdb status
$ext]
37 proc check-extension-status
{ext required
} {
40 set status
[ext-get-status
$ext]
42 if {$ext in
$withinfo(without
)} {
43 # Disabled without further ado
44 msg-result
"Extension $ext...disabled"
45 return [ext-set-status
$ext n
]
48 if {$status in
{m y n
}} {
52 # required is "required" if this extension *must* be enabled
53 # required is "wanted" if it is not fatal for this extension
56 array set depinfo
{m
0 y
0 n
0}
58 # Stash the current value of LIBS
59 set LIBS
[get-define LIBS
]
61 # Check direct dependencies
62 if [ext-get
$ext check
1] {
63 # "check" conditions are met
69 if {$ext in
$withinfo(mod
)} {
70 # This is a module, so ignore LIBS
71 # LDLIBS_$ext will contain the appropriate libs for this module
75 if {$depinfo(n
) == 0} {
76 # Now extension dependencies
77 foreach i
[ext-get
$ext dep
] {
78 set status
[check-extension-status
$i $required]
79 #puts "$ext: dep $i $required => $status"
90 msg-checking
"Extension $ext..."
91 if {$required eq
"required"} {
92 user-error
"dependencies not met"
94 msg-result
"disabled (dependencies)"
95 return [ext-set-status
$ext n
]
98 # Selected as a module?
99 if {$ext in
$withinfo(mod
)} {
100 if {[ext-has
$ext tcl
]} {
102 msg-result
"Extension $ext...tcl"
103 } elseif
{[ext-has
$ext static
]} {
104 user-error
"Extension $ext can't be a module"
106 msg-result
"Extension $ext...module"
107 foreach i
[ext-get
$ext libdep
] {
108 define-append LDLIBS_
$ext [get-define
$i ""]
111 return [ext-set-status
$ext m
]
114 # Selected as a static extension?
115 if {[ext-has
$ext shared
]} {
116 user-error
"Extension $ext can only be selected as a module"
117 } elseif
{$ext in
$withinfo(ext
) ||
$required eq
"$required"} {
118 msg-result
"Extension $ext...enabled"
119 } elseif
{$ext in
$withinfo(maybe
)} {
120 msg-result
"Extension $ext...enabled (default)"
122 # Could be selected, but isn't (yet)
123 return [ext-set-status
$ext x
]
125 foreach i
[ext-get
$ext libdep
] {
126 define-append LDLIBS
[get-define
$i ""]
128 return [ext-set-status
$ext y
]
131 # Examines the user options (the $withinfo array)
132 # and the extension database ($extdb) to determine
133 # what is selected, and in what way.
135 # The results are available via ext-get-status
136 # And a dictionary is returned containing four keys:
137 # static-c extensions which are static C
138 # static-tcl extensions which are static Tcl
139 # module-c extensions which are C modules
140 # module-tcl extensions which are Tcl modules
141 proc check-extensions
{} {
142 global extdb withinfo
144 # Check valid extension names
145 foreach i
[concat $withinfo(ext
) $withinfo(mod
)] {
146 if {![dict exists
$extdb attrs
$i]} {
147 user-error
"Unknown extension: $i"
151 set extlist
[lsort [dict keys
[dict get
$extdb attrs
]]]
153 set withinfo
(maybe
) {}
155 # Now work out the default status. We have.
156 # normal case, include !optional if possible
157 # --without=default, don't include optional
158 if {$withinfo(nodefault
)} {
159 lappend withinfo
(maybe
) stdlib
162 if {![ext-has
$i optional
]} {
163 lappend withinfo
(maybe
) $i
172 foreach i
[concat $withinfo(ext
) $withinfo(mod
)] {
173 check-extension-status
$i required
175 foreach i
$withinfo(maybe
) {
176 check-extension-status
$i wanted
179 array set extinfo
{static-c
{} static-tcl
{} module-c
{} module-tcl
{}}
182 set status
[ext-get-status
$i]
183 set tcl
[ext-has
$i tcl
]
184 switch $status,$tcl {
187 lappend extinfo
(static-tcl
) $i
191 lappend extinfo
(static-c
) $i
192 # If there are any static C++ extensions, jimsh must be linked using
194 if {[ext-has
$i cpp
]} {
195 define HAVE_CXX_EXTENSIONS
198 m
,1 { lappend extinfo
(module-tcl
) $i }
199 m
,0 { lappend extinfo
(module-c
) $i }
202 return [array get extinfo
]