Skip to content

Instantly share code, notes, and snippets.

@msteveb
Created December 13, 2017 23:32
Show Gist options
  • Save msteveb/da1ace0c304878c7914eea4a5db5903c to your computer and use it in GitHub Desktop.
Save msteveb/da1ace0c304878c7914eea4a5db5903c to your computer and use it in GitHub Desktop.
Suggestion for os8 option handling for PiDP-8/I
Index: auto.def
==================================================================
--- auto.def
+++ auto.def
@@ -49,40 +49,41 @@
# Some of the --*-os8-* options are defined only for the configure
# script because they are either meta-options, affecting the definition
# of some of those we do define here, or they aren't passed as-is to the
# mkos8 script, but instead must be translated. (e.g. --disable-os8-src
# suppresses the call to "mkos8 src" from the Makefile.)
-set mkos8_opts ""
-set os "# GENERATED BY auto.def; DO NOT MODIFY.\n\nopts = {\n"
-set os8desc {}
-set os8def {}
-foreach {opt def desc} {
- advent 1 "leave Adventure off the built OS/8 RK05 image"
- ba 1 "leave *.BA BASIC games and demos off the built OS/8 RK05 image"
- cc8 1 "leave the native OS/8 CC8 compiler off the built OS/8 RK05 image"
- chess 1 "leave the CHECKMO-II game of chess off the built OS/8 RK05 image"
- crt 1 "suppress CRT-style rubout processing in the built OS/8 RK05 image"
- dcp 1 "leave the DCP disassembler off the built OS/8 RK05 image"
- focal69 0 "add FOCAL 69 to the built OS/8 RK05 image"
- fortran-ii 1 "leave FORTRAN II off the built OS/8 RK05 image"
- fortran-iv 1 "leave FORTRAN IV off the built OS/8 RK05 image"
- init 1 "do not show the OS/8 INIT message in the built OS/8 RK05 image"
- k12 1 "leave 12-bit Kermit off the built OS/8 RK05 image"
- macrel 1 "leave MACREL assembler off the built OS/8 RK05 image"
- music 0 "add *.MU files to the built OS/8 RK05 image"
- uwfocal 1 "leave U/W FOCAL (only) off the built OS/8 RK05 image"
- vtedit 0 "add the TECO VTEDIT setup to built OS/8 RK05 image"
-} {
- options-add [list os8-$opt=$def => $desc]
- append os "\t\"" $opt "\": \[ $def, \"" $desc "\" \],\n"
- dict set os8desc $opt $desc
- dict set os8def $opt $def
-}
-append os "}\n" ; # saved later!
+set os8opts {
+ advent 1 "Adventure"
+ ba 1 "*.BA BASIC games and demos"
+ cc8 1 "the native OS/8 CC8 compiler"
+ chess 1 "the CHECKMO-II game of chess"
+ crt 1 "CRT-style rubout processing"
+ dcp 1 "the DCP disassembler"
+ focal69 0 "FOCAL 69"
+ fortran-ii 1 "FORTRAN II"
+ fortran-iv 1 "FORTRAN IV"
+ init 1 "the OS/8 INIT message"
+ k12 1 "12-bit Kermit"
+ macrel 1 "MACREL assembler"
+ music 0 "*.MU files"
+ uwfocal 1 "U/W FOCAL (only)"
+ vtedit 0 "the TECO VTEDIT setup"
+}
+
+set alloptions {}
+
+foreach {opt def desc} $os8opts {
+ if {$def} {
+ set prefix "disable"
+ } else {
+ set prefix "enable"
+ }
+ append alloptions [list os8-$opt=$def => "$prefix $desc in the built OS/8 RK05 image"]
+}
# Now define those command line options that belong only to us.
-options {
+append alloptions {
alt-serial-mod => "use GPIO drive scheme suitable for James L-W's serial mod method"
cc8-cross=1 => "do not build the cc8 cross-compiler on the host"
debug-mode => "create a debug build (default is release)"
lowercase: => "select how lowercase input is to be handled"
no-lamp-simulator => "use simple LED driver instead of incandescent lamp simulator"
@@ -92,64 +93,70 @@
os8-src=1 => "do not build os8v3d-src.rk05 from OS/8 source tapes"
serial-mod => "use GPIO drive scheme suitable for Oscar Vermeulen's serial mod method"
throttle: => "override the throttle values in the boot scripts"
}
-# Handle meta-options first.
+options $alloptions
+
+# Make our own array of os8 options so we can apply the meta options
+foreach {opt def desc} $os8opts {
+ set os8bool($opt) [opt-bool os8-$opt]
+}
+set os8bool(patches) [opt-bool os8-patches]
+set os8bool(src) [opt-bool os8-src]
+
+# Handle meta-options
if {![opt-bool os8-focal]} {
- if {[opt-bool os8-focal69]} {
- dict set $::autosetup(optset) "os8-focal69" 0
- }
- if {[opt-bool os8-uwfocal]} {
- dict set $::autosetup(optset) "os8-uwfocal" 0
+ set os8bool(focal69) 0
+ set os8bool(uwfocal) 0
+}
+if {![opt-bool os8-minimal]} {
+ set os8bool(patches) 0
+}
+# And dependencies
+if {$os8bool(cc8) && $os8bool(fortran-ii)} {
+ set $os8bool(fortran-ii) 0
+ msg-result "Disabling --disable-os8-fortran-ii because CC8 is enabled."
+}
+
+# -- do not use opt-bool os8-* below this point
+# -- use the os8bool() array
+
+# Now build the options to mkos8
+set mkos8_opts ""
+# For simplicity, just pass all options to mkos8 even if they are the default
+foreach {opt def desc} $os8opts {
+ if {$os8bool($opt)} {
+ msg-result "Will enable $desc in the built OS/8 RK05 image"
+ append mkos8_opts " --enable-$opt"
+ } else {
+ append mkos8_opts " --disable-$opt"
+ msg-result "Will not enable $desc in the built OS/8 RK05 image"
}
}
-set os8min [opt-bool os8-minimal]
-set os8src [opt-bool os8-src]
-# Decide which of the --*-os8-* options to pass on to mkos8
-foreach opt [lsort [dict keys $::autosetup(optdefault)]] {
- # Skip meta-options handled above and non --*-os8-* options.
- if {$opt in {os8-focal os8-minimal os8-patches os8-src}} { continue }
- if {[string first "os8-" $opt] != 0} { continue }
-
- # Collect working data
- set obn [string replace $opt 0 3]
- set od [dict get $os8def $obn]
- set oh [dict get $os8desc $obn]
- set ov [opt-bool $opt]
-
- # Fix grammar for upcoming msg-result calls
- if {[string first "do not " $oh] == 0} {
- set oh [string replace $oh 0 6]
- } elseif {[string first "do " $oh] == 0} {
- set oh [string replace $oh 0 2]
- }
-
- # Choose option to pass to mkos8 corresponding to this configure
- # script option. Also tell user what we're going to do; grammar
- # is inverted because the option help text says what happens when
- # you give the opposite of the option's default argument.
- if {$ov == $od} {
- # Don't append a mkos8 option; the default is correct.
- msg-result "Will not $oh."
- } elseif {!$os8min && $ov} {
- append mkos8_opts " --enable-" $obn
+# And generate mkos8/opts.py
+set os "# GENERATED BY auto.def; DO NOT MODIFY.\n\nopts = {\n"
+foreach {opt def desc} $os8opts {
+ if {$def} {
+ set fulldesc "disable $desc in the built OS/8 RK05 image"
} else {
- append mkos8_opts " --disable-" $obn
+ set fulldesc "enable $desc in the built OS/8 RK05 image"
}
+ append os "\t\"" $opt "\": \[ $def, \"" $fulldesc "\" \],\n"
}
+append os "}\n" ; # saved later!
# Handle the OS/8 options not passed to mkos8 generically by above.
-if {$os8src} {
+if {$os8bool(src)} {
msg-result "Building os8v3d-src.rk05 from OS/8 source tapes."
define OS8_SRC_RK05 bin/os8v3d-src.rk05
} else {
msg-result "Will not build os8v3d-src.rk05 from OS/8 source tapes."
define OS8_SRC_RK05 {}
}
-if {$os8min || ![opt-bool os8-patches]} {
+if {!$os8bool(patches)} {
msg-result "Will not patch OS/8 on the RK05 bin disk."
define OS8_BOOT_DISK "os8v3d-bin.rk05"
define MKOS8_BIN_PATCHES {}
} else {
msg-result "Will apply OS/8 V3D patches to the RK05 bin disk."
@@ -197,15 +204,10 @@
} else {
user-error "Legal values for --lowercase are {auto,pass,upper}."
}
msg-result "Lowercase handling set to '$lv' mode."
-if {[opt-bool os8-cc8] && ![opt-bool os8-fortran-ii]} {
- msg-result "Must clear --disable-os8-fortran-ii when CC8 is enabled."
- regsub -- {--disable-os8-fortran-ii } $mkos8_opts {}
-}
-
# We've purposely held off exporting the mkos8 option set until now
# because some of the configuration options can affect the option set.
define MKOS8_OPTS $mkos8_opts
if {![file exists "lib/mkos8"]} { file mkdir "lib/mkos8" }
write-if-changed "lib/mkos8/opts.py" $os
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment