61 lines
3.1 KiB
Bash
61 lines
3.1 KiB
Bash
|
|
# Shared setup for the run_magic* launchers -- sourced, not run directly.
|
||
|
|
#
|
||
|
|
# Generated by configure from scripts/magic_run_common.sh.in. It stages a
|
||
|
|
# CAD_ROOT directory of *symlinks* into the build (generated) and source trees --
|
||
|
|
# the same layout `make install` copies, but instantly and always reflecting the
|
||
|
|
# latest build -- and exports the environment magic needs to start straight from
|
||
|
|
# the build tree without `make install`.
|
||
|
|
#
|
||
|
|
# See magic's runtime file discovery: MAGIC_SYS_PATH = ". $CAD_ROOT/magic/sys
|
||
|
|
# $CAD_ROOT/magic/sys/current" (utils/paths.h) for tech/glyphs/fonts/styles, the
|
||
|
|
# system .magicrc at $CAD_ROOT/magic/sys/.magicrc, and (since tcltk/tcldir.h)
|
||
|
|
# magic.tcl / tclmagic / auto_path at $CAD_ROOT/magic/tcl.
|
||
|
|
|
||
|
|
MAGIC_BUILDDIR="@abs_top_builddir@"
|
||
|
|
MAGIC_SRCDIR="@abs_top_srcdir@"
|
||
|
|
SHDLIB_EXT="@SHDLIB_EXT@"
|
||
|
|
|
||
|
|
CAD_ROOT="${MAGIC_BUILDDIR}/CAD_DIR"
|
||
|
|
export CAD_ROOT
|
||
|
|
MAGIC_SYS="${CAD_ROOT}/magic/sys"
|
||
|
|
MAGIC_TCL="${CAD_ROOT}/magic/tcl"
|
||
|
|
|
||
|
|
# (Re)build the symlink layout. Idempotent; `ln -sf` relinks so a rebuilt target
|
||
|
|
# is always current. Missing globs (a partial build) are tolerated.
|
||
|
|
magic_stage() {
|
||
|
|
local b="$MAGIC_BUILDDIR" s="$MAGIC_SRCDIR"
|
||
|
|
mkdir -p "$MAGIC_SYS" "$MAGIC_TCL"
|
||
|
|
|
||
|
|
# --- sys/ : generated tech (build) + display files/glyphs/fonts (source) ---
|
||
|
|
ln -sf "$b"/scmos/*.tech "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
ln -sf "$s"/scmos/*.cmap "$s"/scmos/*dstyle "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
ln -sf "$s"/windows/*.glyphs "$s"/windows/vfont.* "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
ln -sf "$s"/graphics/*.glyphs "$s"/graphics/*.pt3 "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
ln -sf "$b"/magic/proto.magicrc "$MAGIC_SYS"/.magicrc 2>/dev/null || :
|
||
|
|
ln -sf "$b"/magic/proto.initrc "$MAGIC_SYS"/.initrc 2>/dev/null || :
|
||
|
|
if [ -f "$b"/magic/magicps.pro ]; then
|
||
|
|
ln -sf "$b"/magic/magicps.pro "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
else
|
||
|
|
ln -sf "$s"/magic/magicps.pro "$MAGIC_SYS"/ 2>/dev/null || :
|
||
|
|
fi
|
||
|
|
|
||
|
|
# --- tcl/ : source scripts + generated magic.tcl + .so + execs + bitmaps ---
|
||
|
|
ln -sf "$s"/tcltk/*.tcl "$MAGIC_TCL"/ 2>/dev/null || :
|
||
|
|
ln -sf "$b"/tcltk/magic.tcl "$MAGIC_TCL"/ 2>/dev/null || :
|
||
|
|
ln -sf "$b"/magic/tclmagic${SHDLIB_EXT} "$MAGIC_TCL"/ 2>/dev/null || :
|
||
|
|
ln -sf "$b"/tcltk/magicexec "$b"/tcltk/magicdnull "$MAGIC_TCL"/ 2>/dev/null || :
|
||
|
|
# bitmaps is a *directory*: use -n so a re-stage replaces the existing
|
||
|
|
# symlink instead of dereferencing it and dropping a self-link *inside* the
|
||
|
|
# source tree (magic/bitmaps/bitmaps -> .../magic/bitmaps).
|
||
|
|
ln -sfn "$s"/magic/bitmaps "$MAGIC_TCL"/bitmaps 2>/dev/null || :
|
||
|
|
}
|
||
|
|
|
||
|
|
# Fail early with a clear message if the build has not produced the binaries yet.
|
||
|
|
magic_require_built() {
|
||
|
|
if [ ! -x "$MAGIC_BUILDDIR/tcltk/magicexec" ] && \
|
||
|
|
[ ! -x "$MAGIC_BUILDDIR/tcltk/magicdnull" ]; then
|
||
|
|
echo "error: magic is not built yet -- run 'make' in ${MAGIC_BUILDDIR} first." >&2
|
||
|
|
exit 1
|
||
|
|
fi
|
||
|
|
}
|