diff options
author | midipix <writeonce@midipix.org> | 2021-04-10 20:24:58 +0000 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2021-04-10 20:54:44 +0000 |
commit | 28d4adeff6b9f7962596523a662196c31a97a39a (patch) | |
tree | 0e02127d3d904d9132ecf9a6f8320c3e1a6c2b6f /sofort/tools | |
parent | 602ea14c30f0b5f0281d11273100d4bed06351f3 (diff) | |
download | ntapi-28d4adeff6b9f7962596523a662196c31a97a39a.tar.bz2 ntapi-28d4adeff6b9f7962596523a662196c31a97a39a.tar.xz |
build system: posix make support: handle out-of-tree builds in posix make mode.
Diffstat (limited to 'sofort/tools')
-rwxr-xr-x | sofort/tools/srctree.sh | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/sofort/tools/srctree.sh b/sofort/tools/srctree.sh new file mode 100755 index 0000000..90a1d89 --- /dev/null +++ b/sofort/tools/srctree.sh @@ -0,0 +1,83 @@ +#!/bin/sh + +# srctree.sh: support for out-of-tree builds in posix make mode. +# this file is covered by COPYING.SOFORT. + +set -eu + +usage() +{ +cat << EOF >&2 + +Usage: + --help show this HELP message + --srctree=SRCTREE set source directory + +EOF +exit 1 +} + + +# one +workdir=$(pwd -P) +srctree= +argloop= + + +for arg ; do + case "$arg" in + --help) + usage + ;; + + --srctree=*) + srctree=${arg#*=} + ;; + + --) + argloop='done' + ;; + + *) + if [ -z "$argloop" ]; then + printf 'Invalid option: %s\n' "$arg" >&2 + usage + fi + ;; + esac +done + + +# two +if [ -z "$srctree" ] ; then + usage +fi + +cd -- "$srctree" +srctree=$(pwd -P) +cd -- "$workdir" + +if [ "$srctree" = "$workdir" ]; then + exit 0 +fi + + +# three +for arg ; do + case "$arg" in + --srctree=*) + ;; + + --) + ;; + + *) + stat "$arg" > /dev/null 2>&1 \ + || ln -s -- "$srctree/$arg" "$arg" + ;; + esac +done + + +# all done +exit 0 |