4 # Final determination of module status
5 dict
set extdb status
{}
7 # Returns 1 if the extension has the attribute
8 proc ext-has
{ext attr
} {
9 expr {$attr in
[dict get
$::extdb attrs
$ext]}
12 # Returns an entry from the extension 'info' table, or $default otherwise
13 proc ext-get
{ext key
{default {}}} {
14 if {[dict exists
$::extdb info $ext $key]} {
15 return [dict get
$::extdb info $ext $key]
21 # Set the status of the extension to the given value, and returns the value
22 proc ext-set-status
{ext value
} {
23 dict
set ::extdb status
$ext $value
27 # Returns the status of the extension, or ? if unknown
28 proc ext-get-status
{ext
} {
29 if {[dict exists
$::extdb status
$ext]} {
30 return [dict get
$::extdb status
$ext]
35 proc check-extension-status
{ext required
{asmodule
0}} {
38 set status
[ext-get-status
$ext]
40 if {$ext in
$withinfo(without
)} {
41 # Disabled without further ado
42 msg-result
"Extension $ext...disabled"
43 return [ext-set-status
$ext n
]
46 if {$status in
{m y n
}} {
50 # required is "required" if this extension *must* be enabled
51 # required is "wanted" if it is not fatal for this extension
54 array set depinfo
{m
0 y
0 n
0}
56 # Stash the current value of LIBS
57 set LIBS
[get-define LIBS
]
60 set pkgconfig
[ext-get
$ext pkg-config
]
61 if {$pkgconfig ne
""} {
62 # pkg-config support is optional, so explicitly initialse it here
63 if {[pkg-config-init
0]} {
64 lassign
$pkgconfig pkg args
66 if {[pkg-config
{*}$pkgconfig]} {
67 # Found via pkg-config so ignore check and libdep
72 if {!$use_pkgconfig} {
73 # Check direct dependencies
74 if [ext-get
$ext check
1] {
75 # "check" conditions are met
82 # asmodule=1 means that the parent is a module so
83 # any automatically selected dependencies should also be modules
84 if {$asmodule == 0 && $ext in
$withinfo(mod
)} {
89 # This is a module, so ignore LIBS
90 # LDLIBS_$ext will contain the appropriate libs for this module
94 if {$depinfo(n
) == 0} {
95 # Now extension dependencies
96 foreach i
[ext-get
$ext dep
] {
97 set status
[check-extension-status
$i $required $asmodule]
98 #puts "$ext: dep $i $required => $status"
109 msg-checking
"Extension $ext..."
110 if {$required eq
"required"} {
111 user-error
"dependencies not met"
113 msg-result
"disabled (dependencies)"
114 return [ext-set-status
$ext n
]
117 # Selected as a module directly or because of a parent dependency?
119 if {[ext-has
$ext tcl
]} {
121 msg-result
"Extension $ext...tcl"
122 } elseif
{[ext-has
$ext static
]} {
123 user-error
"Extension $ext can't be a module"
125 msg-result
"Extension $ext...module"
126 if {$use_pkgconfig} {
127 define-append LDLIBS_
$ext [pkg-config-get
$pkg LIBS
]
128 define-append LDFLAGS
[pkg-config-get
$pkg LDFLAGS
]
129 define-append CCOPTS
[pkg-config-get
$pkg CFLAGS
]
130 define-append PKG_CONFIG_REQUIRES
$pkg
132 foreach i
[ext-get
$ext libdep
] {
133 define-append LDLIBS_
$ext [get-define
$i ""]
137 return [ext-set-status
$ext m
]
140 # Selected as a static extension?
141 if {[ext-has
$ext shared
]} {
142 user-error
"Extension $ext can only be selected as a module"
143 } elseif
{$ext in
$withinfo(ext
) ||
$required eq
"$required"} {
144 msg-result
"Extension $ext...enabled"
145 } elseif
{$ext in
$withinfo(maybe
)} {
146 msg-result
"Extension $ext...enabled (default)"
148 # Could be selected, but isn't (yet)
149 return [ext-set-status
$ext x
]
151 if {$use_pkgconfig} {
152 define-append LDLIBS
[pkg-config-get
$pkg LIBS
]
153 define-append LDFLAGS
[pkg-config-get
$pkg LDFLAGS
]
154 define-append CCOPTS
[pkg-config-get
$pkg CFLAGS
]
155 define-append PKG_CONFIG_REQUIRES
$pkg
157 foreach i
[ext-get
$ext libdep
] {
158 define-append LDLIBS
[get-define
$i ""]
161 return [ext-set-status
$ext y
]
164 # Examines the user options (the $withinfo array)
165 # and the extension database ($extdb) to determine
166 # what is selected, and in what way.
168 # The results are available via ext-get-status
169 # And a dictionary is returned containing four keys:
170 # static-c extensions which are static C
171 # static-tcl extensions which are static Tcl
172 # module-c extensions which are C modules
173 # module-tcl extensions which are Tcl modules
174 proc check-extensions
{} {
175 global extdb withinfo
177 # Check valid extension names
178 foreach i
[concat $withinfo(ext
) $withinfo(mod
)] {
179 if {![dict exists
$extdb attrs
$i]} {
180 user-error
"Unknown extension: $i"
184 set extlist
[lsort [dict keys
[dict get
$extdb attrs
]]]
186 set withinfo
(maybe
) {}
188 # Now work out the default status. We have.
189 # normal case, include !off, !optional if possible
190 # --full, include !off if possible
191 # --without=default, don't include optional or off
192 if {$withinfo(nodefault
)} {
193 lappend withinfo
(maybe
) stdlib
196 if {[ext-has
$i off
]} {
199 if {[ext-has
$i optional
] && !$withinfo(optional
)} {
202 lappend withinfo
(maybe
) $i
210 foreach i
[concat $withinfo(ext
) $withinfo(mod
)] {
211 check-extension-status
$i required
213 foreach i
$withinfo(maybe
) {
214 check-extension-status
$i wanted
217 array set extinfo
{static-c
{} static-tcl
{} module-c
{} module-tcl
{}}
220 set status
[ext-get-status
$i]
221 set tcl
[ext-has
$i tcl
]
222 switch $status,$tcl {
225 lappend extinfo
(static-tcl
) $i
229 lappend extinfo
(static-c
) $i
230 # If there are any static C++ extensions, jimsh must be linked using
232 if {[ext-has
$i cpp
]} {
233 define HAVE_CXX_EXTENSIONS
236 m
,1 { lappend extinfo
(module-tcl
) $i }
237 m
,0 { lappend extinfo
(module-c
) $i }
240 return [array get extinfo
]