aboutsummaryrefslogtreecommitdiff
path: root/config.rc
diff options
context:
space:
mode:
authormerakor <cem@ckyln.com>2020-12-21 10:02:45 +0000
committermerakor <cem@ckyln.com>2020-12-21 10:02:45 +0000
commitc1c68a205b8cbf0a8ee55f099c27d0a0c7f8afe2 (patch)
tree0e28e76b2391ba290180df87acdab6577d1dfe3f /config.rc
parent08af0013de1d77cf0ee46245e50007a9fbf79035 (diff)
parent1535d115d8d0c58ca4a90acbf16b263cf85bb0a1 (diff)
downloadcpt-c1c68a205b8cbf0a8ee55f099c27d0a0c7f8afe2.tar.gz
Merge branch 'redo'
FossilOrigin-Name: 046e1a0012624ed9a8934a8a4099710264281bcb6814c1fc0fbe3157c1121d2f
Diffstat (limited to 'config.rc')
-rw-r--r--config.rc84
1 files changed, 84 insertions, 0 deletions
diff --git a/config.rc b/config.rc
new file mode 100644
index 0000000..2f0733b
--- /dev/null
+++ b/config.rc
@@ -0,0 +1,84 @@
+# -*- mode: redo -*-
+# See LICENSE for copyright information
+
+setv() {
+ # Set variables if unset. Works similar to the Makefile syntax.
+ [ "$3" ] || {
+ printf '%s\n' "Faulty variable syntax" >&2
+ exit 1
+ }
+ var=$1; sym=$2; shift 2
+ case "$sym" in
+ \?=|=) eval "[ \"\$$var\" ]" || export "$var=$*" ;;
+ +=) eval "export \"$var=\$$var $*\""
+ esac
+}
+
+setv VERSION = 5.1.1
+
+# Paths
+setv PREFIX = /usr/local
+setv BINDIR = "${PREFIX}/bin"
+setv SHAREDIR = "${PREFIX}/share"
+setv DOCDIR = "${SHAREDIR}/doc"
+setv CPTDOC = "${DOCDIR}/cpt"
+setv MANPREFIX = "${SHAREDIR}/man"
+setv MAN1 = "${MANPREFIX}/man1"
+
+# Flags
+setv CFLAGS = -std=c99 -Wpedantic -Wall -Os
+setv CFLAGS += -D_XOPEN_SOURCE=700
+setv LDFLAGS = -s -static
+setv LIBS = -lc
+
+setv CC = cc
+setv LD = "${CC}"
+
+# Documentation tools
+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 ] && {
+ while read -r file; do
+ [ -d "$file" ] || rm -f "$file"
+ done < .do_built
+ }
+ find . -type f \( -name '*.tmp' -o -name '*.did' -o -name '.dep*' -o -name '.target*' \) \
+ -exec rm -f -- {} +
+ [ "$DO_BUILT" ] || find . -name '.do_built*' -exec rm -rf -- {} +
+ [ "$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() {
+ # 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() {
+ # Function to get all executables
+ find src contrib bin -name 'cpt-*' ! -name '*.in' ! -name '*.[coh]'
+}
+
+
+# Phony targets
+PHONY all dist clean install uninstall test