diff options
author | EuAndreh <eu@euandre.org> | 2022-05-02 22:07:14 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-05-02 22:07:14 -0300 |
commit | 801a2ff5964a9c2794fcfad9660ea1216f5f845c (patch) | |
tree | 8c792d1eb132064655d9753d746bcd2a703fe1e5 /src/development | |
parent | _config.yml: Exclude src/ for now (diff) | |
download | euandre.org-801a2ff5964a9c2794fcfad9660ea1216f5f845c.tar.gz euandre.org-801a2ff5964a9c2794fcfad9660ea1216f5f845c.tar.xz |
src/development/dynmake.sh: Base tool to do dynamic Makefiles without proprietary $(wildcard ...) add-ons
Diffstat (limited to '')
-rwxr-xr-x | src/development/dynmake.sh | 72 |
1 files changed, 72 insertions, 0 deletions
diff --git a/src/development/dynmake.sh b/src/development/dynmake.sh new file mode 100755 index 0000000..3f173da --- /dev/null +++ b/src/development/dynmake.sh @@ -0,0 +1,72 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + dynmake.sh -n VARNAME -d DIR + dynmake.sh -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -h, --help show this message + EOF +} + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +while getopts 'd:n:h' flag; do + case "$flag" in + d) + DIR="$OPTARG" + ;; + n) + NAME="$OPTARG" + ;; + h) + usage + help + exit + ;; + *) + usage >&2 + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) + +assert_arg() { + if [ -z "$1" ]; then + printf 'Missing %s.' "$2" >&2 + exit 2 + fi +} + +assert_arg "${DIR:-}" '-d DIR' +assert_arg "${NAME:-}" '-n NAME' + + + +printf '%s = \\\n' "$NAME" +find "$DIR" -type f | + sed -e 's/^/ /' \ + -e 's/$/ \\/' +printf '\n' |