From: Ian Jackson Date: Sun, 3 Mar 2019 11:22:20 +0000 (+0000) Subject: find-plag X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ian/git?a=commitdiff_plain;h=944817c7eccd0c1c5ebaae9165ce8638179bd3c0;p=pandemic-rising-tide.git find-plag --- diff --git a/Makefile b/Makefile index bc72f22..ee8052a 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,14 @@ o= >$@.tmp && $i 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 @@ -18,7 +25,7 @@ map.plag: generate-plag input-graph Parse.pm ./$< 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 \ @@ -28,8 +35,8 @@ opt.plag: maybe-rerun-optim map.plag $(PLANAR_GRAPH) Makefile 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 diff --git a/find-plag b/find-plag new file mode 100755 index 0000000..45b9773 --- /dev/null +++ b/find-plag @@ -0,0 +1,35 @@ +#!/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