diff options
-rw-r--r-- | config.rc | 51 | ||||
-rw-r--r-- | default.do | 6 | ||||
-rw-r--r-- | install.do | 16 | ||||
-rw-r--r-- | src/test.do | 4 | ||||
-rw-r--r-- | uninstall.do | 9 |
5 files changed, 62 insertions, 24 deletions
@@ -14,6 +14,31 @@ setv() { 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 redo_clean() { # Clean function for various redo implementations [ -r .do_built ] && { @@ -38,29 +63,11 @@ 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}" +getbin() { + # Function to get all executables + find src contrib bin -name 'cpt-*' ! -name '*.in' ! -name '*.[coh]' +} -# Documentation tools -setv EMACS = emacs -setv MAKEINFO = makeinfo # Phony targets PHONY all dist clean install uninstall test @@ -25,9 +25,11 @@ case "$1" in "cpt-$VERSION.tar.xz") redo docs/cpt.info rm -rf -- "cpt-$VERSION" - find . -type f ! -name '.*' ! -path './.*' | + mkdir -p "cpt-$VERSION" + { git ls-tree -r HEAD --name-only && echo docs/cpt.info ;} | while read -r file; do - mkdir -p "cpt-$VERSION/${file%/*}" + [ "${file##*/*}" ] || + mkdir -p "cpt-$VERSION/${file%/*}" cp "$file" "cpt-$VERSION/$file" done tar cf "cpt-$VERSION.tar" "cpt-$VERSION" diff --git a/install.do b/install.do new file mode 100644 index 0000000..cc11bd4 --- /dev/null +++ b/install.do @@ -0,0 +1,16 @@ +. ./config.rc +redo all + +# Install executables. +mkdir -p "${DESTDIR}${BINDIR}" +getbin | while read -r file; do + cp "$file" "${DESTDIR}${BINDIR}/${file##*/}" + chmod 755 "${DESTDIR}${BINDIR}/${file##*/}" +done + +# Install manual pages. +mkdir -p "${DESTDIR}${MAN1}" +for man in man/*.1; do + cp "$man" "${DESTDIR}${MAN1}/${man##*/}" + chmod 644 "${DESTDIR}${MAN1}/${man##*/}" +done diff --git a/src/test.do b/src/test.do new file mode 100644 index 0000000..9d32aef --- /dev/null +++ b/src/test.do @@ -0,0 +1,4 @@ +. ../config.rc +redo-ifchange cpt-lib +shellcheck -x -f gcc ./cpt* ../contrib/* +PHONY diff --git a/uninstall.do b/uninstall.do new file mode 100644 index 0000000..d2f4585 --- /dev/null +++ b/uninstall.do @@ -0,0 +1,9 @@ +. ./config.rc + +getbin | while read -r file; do + rm -f "${DESTDIR}${BINDIR}/${file##*/}" +done + +for man in man/*.1; do + rm -f "${DESTDIR}${MAN1}/${man##*/}" +done |