swissChili | 9b46c90 | 2022-07-10 15:48:46 -0700 | [diff] [blame] | 1 | # -*- tcl -*- |
| 2 | |
| 3 | variable isas |
| 4 | variable devices |
| 5 | |
| 6 | variable isa_features |
| 7 | |
| 8 | proc isa {name} { |
| 9 | lappend ::isas $name |
| 10 | } |
| 11 | |
| 12 | proc device {name isa} { |
| 13 | lappend ::devices($isa) $name |
| 14 | } |
| 15 | |
| 16 | proc target_feature {feature} { |
| 17 | lappend ::isa_features $feature |
| 18 | } |
| 19 | |
| 20 | proc target_features {args} { |
| 21 | lappend ::isa_features {*}$args |
| 22 | } |
| 23 | |
| 24 | proc feature_supported {feature} { |
| 25 | return [expr {[lsearch -exact $::isa_features $feature] != -1}] |
| 26 | } |
| 27 | |
| 28 | option ISA x86_32 |
swissChili | 56cf817 | 2022-07-30 18:47:48 -0700 | [diff] [blame] | 29 | option DEVICE generic |
swissChili | 9b46c90 | 2022-07-10 15:48:46 -0700 | [diff] [blame] | 30 | |
| 31 | proc source_if_exists {path} { |
| 32 | if {[file exists $path]} { |
| 33 | uplevel 1 jmk_source $path |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | proc enable_multiplat {} { |
| 38 | uplevel 1 source_if_exists "$::root/etc/platforms/platforms.jmk" |
| 39 | |
| 40 | if {[lsearch -exact $::isas $::options(ISA)] == -1} { |
| 41 | jmk_error "Specified ISA $::options(ISA) is invalid, choose one of $::isas" |
| 42 | } |
| 43 | |
| 44 | if {[lsearch -exact $::devices($::options(ISA)) $::options(DEVICE)] == -1} { |
| 45 | jmk_error "Specified DEVICE $::options(DEVICE) is invalid, choose one of $::devices($::options(ISA))" |
| 46 | } |
| 47 | |
| 48 | uplevel 1 source_if_exists "$::root/etc/platforms/$::options(ISA)/$::options(DEVICE).jmk" |
| 49 | uplevel 1 source_if_exists "$::root/etc/platforms/$::options(ISA)/$::options(ISA).jmk" |
| 50 | |
| 51 | uplevel 1 source_if_exists "$::options(ISA)/$::options(DEVICE).jmk" |
| 52 | uplevel 1 source_if_exists "$::options(ISA)/$::options(ISA).jmk" |
| 53 | } |