aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-12-20 21:18:47 +0000
committermerakor <cem@ckyln.com>2020-12-20 21:18:47 +0000
commit9aab40bc5d33350c5bfb3a6d86a783b9c243ec68 (patch)
treecc8f03451445b6381a49f732a3be842ab907effe
parent2b62486c4e07a6fd10a4900d125b5c55da5ecd91 (diff)
downloadcpt-9aab40bc5d33350c5bfb3a6d86a783b9c243ec68.tar.gz
config.rc: better helper functions
FossilOrigin-Name: 616fa2758bb01ad6f314baa41abb361b53194e62407bdc7ecd2320be41073334
-rw-r--r--config.rc27
1 files changed, 19 insertions, 8 deletions
diff --git a/config.rc b/config.rc
index f09b44c..2f0733b 100644
--- a/config.rc
+++ b/config.rc
@@ -39,6 +39,8 @@ setv EMACS = emacs
setv MAKEINFO = makeinfo
# Helper functions
+target=$1 basename=$2 dest=$3
+
redo_clean() {
# Clean function for various redo implementations
[ -r .do_built ] && {
@@ -52,15 +54,24 @@ redo_clean() {
[ "$REDO_BASE" ] || rm -rf -- .redo
}
+targcheck() {
+ # Usage: targcheck [target...]
+ #
+ # Check if current target is one of the given arguments of this function.
+ # Returns 0 if target is one of the arguments, returns 1 if not.
+ case " $* " in *" $target "*) return 0; esac; return 1
+}
+
PHONY() {
- # Function that resembles the .PHONY: target on the classic 'make' build
- # system.
- [ "$1" ] || {
- trap 'rm -f $3' EXIT INT
- return 0
- }
- setv PHONY += "$@"
- trap 'case " $PHONY " in *" $1 "*) rm -f $3; esac' EXIT INT
+ # Usage: PHONY [[target...]]
+ #
+ # Function that resembles the .PHONY: target on the classic 'make' system.
+ # You can either use it without an argument on a single target, or specify
+ # multiple targets.
+ if [ -z "$1" ] || targcheck "$@"; then
+ # shellcheck disable=2064
+ trap "rm -f $dest" EXIT INT
+ fi
}
getbin() {