diff options
-rw-r--r-- | .gitignore | 9 | ||||
-rw-r--r-- | bin/all.do | 2 | ||||
-rw-r--r-- | bin/clean.do | 2 | ||||
-rw-r--r-- | clean.do | 5 | ||||
-rw-r--r-- | config.rc | 66 | ||||
-rw-r--r-- | default.do | 49 | ||||
-rw-r--r-- | docs/default.do | 24 | ||||
-rw-r--r-- | src/cpt-lib.in (renamed from src/cpt-lib) | 2 |
8 files changed, 158 insertions, 1 deletions
@@ -16,5 +16,14 @@ getopt [._]ss[a-gi-z] [._]sw[a-p] +### Redo files +/.redo +/.do_built +/.do_built.dir +*.tmp +*.did +.dep* +.target* + ### Texinfo ### *.info diff --git a/bin/all.do b/bin/all.do new file mode 100644 index 0000000..aceda74 --- /dev/null +++ b/bin/all.do @@ -0,0 +1,2 @@ +. ../config.rc +redo-ifchange cpt-readlink cpt-stat diff --git a/bin/clean.do b/bin/clean.do new file mode 100644 index 0000000..6234248 --- /dev/null +++ b/bin/clean.do @@ -0,0 +1,2 @@ +. ../config.rc +rm -f -- ./*.o cpt-readlink cpt-stat .dep.* diff --git a/clean.do b/clean.do new file mode 100644 index 0000000..b30f907 --- /dev/null +++ b/clean.do @@ -0,0 +1,5 @@ +. ./config.rc +redo bin/clean src/clean +redo_clean +rm -f "cpt-$VERSION.tar.xz" +find docs -name '*.info' -exec rm -f -- {} + diff --git a/config.rc b/config.rc new file mode 100644 index 0000000..b6dc81e --- /dev/null +++ b/config.rc @@ -0,0 +1,66 @@ +# -*- 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 +} + +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 +} + +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 +} + +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 + +# Phony targets +PHONY all dist clean install uninstall test diff --git a/default.do b/default.do new file mode 100644 index 0000000..d8c1cd9 --- /dev/null +++ b/default.do @@ -0,0 +1,49 @@ +. ./config.rc + +# Extensionless name of file +fn="${1%.*}" + +case "$1" in + all) redo-ifchange src/cpt-lib bin/all docs/cpt.info ;; + dist) + redo clean + redo "cpt-$VERSION.tar.xz" + ;; + src/cpt-lib) + redo-ifchange "$1.in" + sed "s|@VERSION@|$VERSION|g" < "$1.in" > "$3" + ;; + bin/cpt-readlink|bin/cpt-stat) + redo-ifchange "$1.o" + "$CC" -o "$3" $LDFLAGS "$1.o" $LIBS + ;; + *.o) + [ -f "${1%.o}.c" ] || exit 99 + redo-ifchange "$fn.c" + "$CC" -c -o "$3" $CFLAGS "$fn.c" + ;; + "cpt-$VERSION.tar.xz") + redo docs/cpt.info + rm -rf -- "cpt-$VERSION" + find . -type f ! -name '.*' ! -path './.*' | + while read -r file; do + mkdir -p "cpt-$VERSION/${file%/*}" + cp "$file" "cpt-$VERSION/$file" + done + tar cf "cpt-$VERSION.tar" "cpt-$VERSION" + xz -z "cpt-$VERSION.tar" + rm -rf -- "cpt-$VERSION" + mv "$1" "$3" + ;; + test) + redo src/test + ;; + src/clean) + rm -f src/cpt-lib + ;; + *) + echo "Unknown target $1" + exit 99 +esac + +PHONY all dist test clean src/clean diff --git a/docs/default.do b/docs/default.do new file mode 100644 index 0000000..2742edb --- /dev/null +++ b/docs/default.do @@ -0,0 +1,24 @@ +. ../config.rc + +# Extensionless name of file +fn="${1%.*}" + +case "$1" in + all) redo-ifchange info ;; + info) redo-ifchange cpt.info ;; + *.info) + redo-ifchange "$fn.texi" + $MAKEINFO "$fn.texi" -o "$3" + ;; + *.texi) + [ -f "$fn.org" ] || exit 99 + redo-ifchange "$fn.org" + $EMACS "$fn.org" --batch -f org-texinfo-export-to-texinfo + mv "$1" "$3" + ;; + *) + echo "Unknown target $1" + exit 99 +esac + +PHONY all info html diff --git a/src/cpt-lib b/src/cpt-lib.in index c75fbcf..6045e22 100644 --- a/src/cpt-lib +++ b/src/cpt-lib.in @@ -8,7 +8,7 @@ # Currently maintained by Cem Keylan. version() { - log "Carbs Packaging Tools" 5.1.1 + log "Carbs Packaging Tools" @VERSION@ exit 0 } |