The gdb and valgrind launchers previously passed every argument straight to
magic, leaving no way to give the tool its own options. Add a "--" split
(shared magic_split_args helper): arguments before "--" go to gdb/valgrind,
arguments after go to magic; with no "--", all arguments go to magic (the
common case). Examples:
./run_magic_gdb.sh -tui -ex run -- -dnull foo.mag
./run_magic_valgrind.sh --tool=callgrind -- foo.mag
Also make the tool binary and its default options overridable from the
environment: GDB/GDB_OPTS and VALGRIND/VALGRIND_OPTS (valgrind defaults to
--leak-check=full --error-exitcode=0), and warn if the tool is not on PATH.
Smoke-tested against a live X display: gdb runs magic to a clean exit and
valgrind produces a Memcheck report; option routing verified (a bogus flag
after "--" is rejected by magic, not gdb), both headless (-dnull) and GUI.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Expand each run_magic*.sh header to state its purpose, usage, and the full set
of environment overrides. Initialize every knob with ${VAR:-default} so a value
inherited from the environment always wins:
- CAD_ROOT is now overridable (was hardwired to $builddir/CAD_DIR); point it at
a shared/installed tree to skip staging.
- WISH/TCLSH default to the wish/tclsh configure detected for this build's
Tcl/Tk (@WISH_EXE@/@TCLSH_EXE@, matching --with-tk/--with-tcl), so a build
against a non-standard Tcl/Tk automatically uses the correct absolute paths.
MAGIC_WISH (what tkcon.tcl uses for the Tk console) defaults from WISH.
Add magic_check_env(): on source, sanity-check each value (directory / regular
file / executable, as appropriate) and print a non-fatal stderr warning naming
the offending variable and whether it came from the environment or the baked
default -- to make a bad override easy to diagnose. Empty optional values
(e.g. no tclsh configured) and a not-yet-created CAD_ROOT are not flagged.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Four configure-generated launch scripts let you run magic straight from the
build directory without `make install`:
* run_magic.sh -- GUI magic (Cairo/X11)
* run_magicnull.sh -- batch / no-GUI (-dnull)
* run_magic_gdb.sh -- magic under gdb
* run_magic_valgrind.sh -- magic under valgrind
magic resolves its runtime files through a single $CAD_ROOT root
($CAD_ROOT/magic/{sys,tcl}), but in the build tree they are scattered across
build/ (generated tech, .magicrc, magic.tcl, tclmagic, execs) and source/
(colormaps, dstyles, glyphs, fonts, tcl scripts). On first run each launcher
self-stages ${builddir}/CAD_DIR as a symlink tree in that layout (no copies,
always current) via the shared scripts/magic_run_common.sh, exports
CAD_ROOT=${builddir}/CAD_DIR, and execs the right binary. This pairs with the
preceding commit that made the C launchers honor CAD_ROOT.
magic_stage() is idempotent and re-runs on every launch. Most staged entries
are files, but the bitmaps entry links a *directory*, so it uses `ln -sfn`
(--no-dereference; also accepted by BSD ln): a plain `ln -sf` would, on a second
run, dereference the existing symlink-to-directory and drop the new link *inside*
the target -- a magic/bitmaps/bitmaps self-loop in the source tree that trips up
find/tar/cp -r.
Verified: ./run_magicnull.sh self-stages (30 sys + 24 tcl symlinks) and runs --
`tech load scmos` reports 13 planes -- straight from the build dir. gitignore
covers the generated scripts and the CAD_DIR tree.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>