swissChili | 0fc3f26 | 2021-08-09 22:05:17 -0700 | [diff] [blame] | 1 | # Rewrite of JMK in TCL |
| 2 | |
| 3 | variable jmk_name {} |
| 4 | variable jmk_target {} |
| 5 | variable cflags {} |
| 6 | variable asmflags {} |
| 7 | |
| 8 | variable asm as |
| 9 | variable cc cc |
| 10 | |
| 11 | variable options |
| 12 | |
| 13 | proc init {name {target {DEFAULT_TARGET}}} { |
| 14 | if {$target eq {DEFAULT_TARGET}} { |
| 15 | set target $name |
| 16 | } |
| 17 | |
| 18 | global jmk_name |
| 19 | global jmk_target |
| 20 | |
| 21 | set jmk_name $name |
| 22 | set jmk_target $target |
| 23 | } |
| 24 | |
| 25 | proc preset {p} { |
| 26 | ::preset::$p |
| 27 | } |
| 28 | |
| 29 | proc presets {args} { |
| 30 | foreach arg $args { |
| 31 | preset $arg |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | proc cflag {arg} { |
| 36 | global cflags |
| 37 | set cflags "$cflags $arg" |
| 38 | } |
| 39 | |
| 40 | proc cflags {args} { |
| 41 | foreach arg $args { |
| 42 | cflag $arg |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | proc asmflag {arg} { |
| 47 | global asmflags |
| 48 | set asmflags "$asmflags $arg" |
| 49 | } |
| 50 | |
| 51 | proc asmflags {args} { |
| 52 | foreach arg $args { |
| 53 | asmflag $arg |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | proc option {name val} { |
| 58 | global options |
| 59 | if {![info exists options($name)]} { |
| 60 | set options($name) $val |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | namespace eval preset { |
| 65 | proc 32 {} { |
| 66 | cflag -m32 |
| 67 | asmflag -felf32 |
| 68 | } |
| 69 | |
| 70 | proc debug {} { |
| 71 | cflag -g |
| 72 | asmflag -Fdwarf |
| 73 | } |
| 74 | |
| 75 | proc warn {} { |
| 76 | cflag "-Wall -Wextra -Werror" |
| 77 | } |
| 78 | |
| 79 | proc nasm {} { |
| 80 | global asm |
| 81 | set asm nasm |
| 82 | } |
| 83 | } |
| 84 | |
| 85 | if {[catch {array set options $argv} msg]} { |
| 86 | puts "Sorry, you must pass an even number of arguments to this script" |
| 87 | puts "in the form <key> <value>" |
| 88 | exit 1 |
| 89 | } |