export PERL_HASH_SEED=1
-PLANAR_GRAPH=planar-graph
+# PLAG_DEBUG ?= $(PLAG) # effectively
+# PLAG_RELEASE ?= $(PLAG) # ie caller may set these
+PLAG_DIR ?= ../planar-graph
+
+USE_PLAG_DEBUG := $(shell ./find-plag \
+ debug:release "$(PLAG_DIR)" "$(PLAG_DEBUG)" "$(PLAG_RELEASE)" "$(PLAG)")
+USE_PLAG_RELEASE := $(shell ./find-plag \
+ release:debug "$(PLAG_DIR)" "$(PLAG_RELEASE)" "$(PLAG_DEBUG)" "$(PLAG)")
# with planar-graph 74bbc2b1da372d3456c00bcb07f3358c739e5721
./$< input-graph $o
# create opt.plag.reuse to shortcut this
-opt.plag: maybe-rerun-optim map.plag $(PLANAR_GRAPH) Makefile
+opt.plag: maybe-rerun-optim map.plag $(USE_PLAG_RELEASE) Makefile
./$(filter-out Makefile, $^) $@ .opt.plag.sums \
R \
DUAL \
D 0 NLOPT \
W $@.tmp
-faces.plag: opt.plag $(PLANAR_GRAPH) Makefile
- $(PLANAR_GRAPH) RF $< W-FACES $@.tmp && $i
+faces.plag: opt.plag $(USE_PLAG_DEBUG) Makefile
+ $(USE_PLAG_DEBUG) RF $< W-FACES $@.tmp && $i
whole.ps: generate-board faces.plag input-graph misc-data.pl Parse.pm
./generate-board -XS faces.plag input-graph $o
--- /dev/null
+#!/bin/bash
+set -e
+
+cmd=planar-graph
+
+want="$1"; shift
+dir="$1"; shift
+
+printf >&2 "selecting %s (%s)..." "$cmd" "${want%%:*}"
+
+for val in "$@"; do
+ if [ "$val" ]; then
+ printf >&2 ' %s\n' "$val"
+ printf '%s\n' "$def"
+ exit 0
+ fi
+done
+
+if type -p $cmd 2>/dev/null; then
+ printf >&2 ' PATH\n'
+ exit 0
+fi
+
+for which in ${want//\:/ }; do
+ r="$dir/target/$which/$cmd"
+ if test -e "$r"; then
+ printf >&2 ' %s\n' "$r"
+ printf '%s\n' "$r"
+ exit 0
+ fi
+done
+
+printf >&2 ' no!\n'
+echo missing-planar-graph-utility
+exit 16