Update ssl cert to use a 4096 bit key
[jimtcl.git] / autosetup / local.tcl
blobba2bb3d99972998e4fadb95cd78d787d206c8bbb
1 global withinfo
2 global extdb
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]
16 } else {
17 return $default
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
24 return $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]
32 return ?
35 proc check-extension-status {ext required {asmodule 0}} {
36 global withinfo
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}} {
47 return $status
50 # required is "required" if this extension *must* be enabled
51 # required is "wanted" if it is not fatal for this extension
52 # not to be enabled
54 array set depinfo {m 0 y 0 n 0}
56 # Stash the current value of LIBS
57 set LIBS [get-define LIBS]
59 set use_pkgconfig 0
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
68 set use_pkgconfig 1
72 if {!$use_pkgconfig} {
73 # Check direct dependencies
74 if [ext-get $ext check 1] {
75 # "check" conditions are met
76 } else {
77 # not met
78 incr depinfo(n)
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)} {
85 set asmodule 1
88 if {$asmodule} {
89 # This is a module, so ignore LIBS
90 # LDLIBS_$ext will contain the appropriate libs for this module
91 define LIBS $LIBS
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"
99 incr depinfo($status)
100 if {$depinfo(n)} {
101 break
106 #parray depinfo
108 if {$depinfo(n)} {
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?
118 if {$asmodule} {
119 if {[ext-has $ext tcl]} {
120 # Easy, a Tcl module
121 msg-result "Extension $ext...tcl"
122 } elseif {[ext-has $ext static]} {
123 user-error "Extension $ext can't be a module"
124 } else {
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
131 } else {
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)"
147 } else {
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
156 } else {
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
194 } else {
195 foreach i $extlist {
196 if {[ext-has $i off]} {
197 continue
199 if {[ext-has $i optional] && !$withinfo(optional)} {
200 continue
202 lappend withinfo(maybe) $i
206 foreach i $extlist {
207 define LDLIBS_$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 {}}
219 foreach i $extlist {
220 set status [ext-get-status $i]
221 set tcl [ext-has $i tcl]
222 switch $status,$tcl {
223 y,1 {
224 define jim_ext_$i
225 lappend extinfo(static-tcl) $i
227 y,0 {
228 define jim_ext_$i
229 lappend extinfo(static-c) $i
230 # If there are any static C++ extensions, jimsh must be linked using
231 # the C++ compiler
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]