#!/bin/sh # License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. # # mcde-host.sh -- MCDE for the desktop of this (Linux) build host, in /usr/mdt # # usage: tools/mcde-host.sh [install] # (make mcde-host [MCDE_DIRS=install]) # # The desktop the developer works in runs MCDE from /usr/mdt (configuration # /etc/mdt), built from this tree. This builds it the way the pkgsrc recipe # does (ext/src/mcde/pkgsrc/Makefile, pre-configure): every "/usr/dt", # "/etc/dt" and "/usr/bin/X11" in the sources becomes the prefix, the # configuration directory and the X binaries -- CDE has them written into # its programs (dtsearchpath: libCliSrv/Environ.C), and without the step a # session finds no data types and dtwm no front panel. Then configure (when # configure.ac or a Makefile.am changed), make, and with "install" make # install into build/mcde-host-stage and its second-level directories # (usr/mdt, etc/cde, ...) copied below / with sudo, owned by root (rsync: # every file renamed into place, so running programs keep theirs). # # The working tree of ext/src/mcde (with uncommitted edits, without pkgsrc/) # is copied to build/mcde-host; a substituted file is written only when its # text changes, so a second run recompiles only what changed. Not how # Makronix gets MCDE -- that is pkgsrc -- and nothing here goes into a set. # # The last line of the output is "mcde-host exit=N". set -u TOP=$(cd "$(dirname "$0")/.." && pwd) # This tool writes build/obj or releasedir: only inside the build lock. if [ -z "${BUILD_LOCK_HELD:-}" ] || [ ! -d "$BUILD_LOCK_HELD" ]; then echo "${0##*/}: run this through make or tools/build-lock.sh" >&2 exit 1 fi SRC=$TOP/ext/src/mcde B=$TOP/build/mcde-host STAGE=$TOP/build/mcde-host-stage PREFIX=/usr/mdt SYSCONF=/etc/mdt X11BIN=/usr/bin JOBS=${JOBS:-16} finish() { echo "mcde-host exit=$1"; exit "$1"; } case ${1:-} in ''|install) ;; *) echo "usage: ${0##*/} [install]" >&2; finish 2 ;; esac mkdir -p "$B" || finish 1 LIST=$B/.mcde-host-subst # the files with a CDE path, relative to the tree (rsync leaves them out) (cd "$SRC" && grep -rlI -e /usr/dt -e /etc/dt -e /usr/bin/X11 \ --exclude-dir=pkgsrc . | sed 's,^\./,,') > "$LIST.new" || finish 1 sed 's,^,/,' "$LIST.new" > "$LIST.exclude" rsync -a --exclude=/pkgsrc --exclude=/.mcde-host-subst* \ --exclude-from="$LIST.exclude" "$SRC/" "$B/" || finish 1 while IFS= read -r f; do mkdir -p "$B/$(dirname "$f")" || finish 1 # cp -p first: the redirection keeps the mode (a script stays one) cp -p "$SRC/$f" "$B/$f.subst" && sed -e "s:/usr/bin/X11:$X11BIN:g" -e "s:/usr/dt:$PREFIX:g" \ -e "s:/etc/dt:$SYSCONF:g" "$SRC/$f" > "$B/$f.subst" || finish 1 if cmp -s "$B/$f.subst" "$B/$f"; then rm -f "$B/$f.subst" else mv "$B/$f.subst" "$B/$f" || finish 1 case $f in *Makefile.am) : > "$B/.mcde-host-regen" ;; esac fi # the time of the source: a configure.ac must not look newer than # the configure made from it (motif/ would run its aclocal-1.15) # Only the build system's inputs: a source with a changed path must # look newer than its object, or make keeps the object that still has # "/etc/dt" in it (dtsearchpath did, 2026-11-13: no front panel). case $f in *configure.ac|*Makefile.am|*.m4) touch -r "$SRC/$f" "$B/$f" || finish 1 ;; esac done < "$LIST.new" mv "$LIST.new" "$LIST" cd "$B" || finish 1 # .mcde-host-regen: a Makefile.am was substituted; it goes only when # configure has run, so a failed run regenerates again if [ -f .mcde-host-regen ] || [ ! -f config.status ] || [ -n "$(find . -name configure.ac -newer config.status -o \ -name Makefile.am -newer config.status | head -1)" ]; then ./autogen.sh || finish 1 ./configure --prefix="$PREFIX" --sysconfdir=/etc --localstatedir=/var \ --with-config-dir="$SYSCONF" --with-logfiles-dir=/var/mdt \ --with-pamdir=/etc/pam.d --with-calendar-dir=/var/spool/calendar || finish 1 rm -f .mcde-host-regen fi nice -n 19 make -j"$JOBS" || finish $? if [ "${1:-}" = install ]; then rm -rf "$STAGE" || finish 1 make install DESTDIR="$STAGE" || finish $? # below the top directories only (usr/mdt, etc/cde, etc/pam.d, ...): # "rsync STAGE/ /" gave /, /etc, /usr and /var the owner and the mode # of the stage -- the user, 775 (2026-11-13, put back by hand). Owner # root, nothing writable by group or others: dtlogin runs as root. (cd "$STAGE" && sudo rsync -rlptR --no-implied-dirs \ --chown=root:root --chmod=go-w ./*/* /) || finish $? echo "installed from $(git -C "$TOP" rev-parse --short HEAD)" \ "$(git -C "$TOP" status --porcelain -- ext/src/mcde | grep -q . && echo '(with uncommitted changes)')" fi finish 0