blob: 36c65a9a626bf294cca79b8c3a3fa90129f8101c [file] [log] [blame]
swissChili0fc3f262021-08-09 22:05:17 -07001# Rewrite of JMK in TCL
2
3variable jmk_name {}
4variable jmk_target {}
5variable cflags {}
6variable asmflags {}
7
8variable asm as
9variable cc cc
10
11variable options
12
13proc 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
25proc preset {p} {
26 ::preset::$p
27}
28
29proc presets {args} {
30 foreach arg $args {
31 preset $arg
32 }
33}
34
35proc cflag {arg} {
36 global cflags
37 set cflags "$cflags $arg"
38}
39
40proc cflags {args} {
41 foreach arg $args {
42 cflag $arg
43 }
44}
45
46proc asmflag {arg} {
47 global asmflags
48 set asmflags "$asmflags $arg"
49}
50
51proc asmflags {args} {
52 foreach arg $args {
53 asmflag $arg
54 }
55}
56
57proc option {name val} {
58 global options
59 if {![info exists options($name)]} {
60 set options($name) $val
61 }
62}
63
64namespace 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
85if {[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}