summaryrefslogtreecommitdiffhomepage
path: root/sofort/tools
diff options
context:
space:
mode:
authormidipix <writeonce@midipix.org>2018-12-31 20:57:15 -0500
committermidipix <writeonce@midipix.org>2018-12-31 21:36:46 -0500
commit3cdb2f52a3517a7a5ef5943faccb47399d4b8ff2 (patch)
tree7590da1325abecdac1b172c99afadd48f2ac4a2e /sofort/tools
parentc8e23f70be15c603f652d79fbd43d695c644847c (diff)
downloadslibtool-3cdb2f52a3517a7a5ef5943faccb47399d4b8ff2.tar.bz2
slibtool-3cdb2f52a3517a7a5ef5943faccb47399d4b8ff2.tar.xz
build system: sofort: refactored, rearranged using distinct sub-folders.
Diffstat (limited to 'sofort/tools')
-rwxr-xr-xsofort/tools/pkgconf.sh107
-rwxr-xr-xsofort/tools/version.sh72
2 files changed, 179 insertions, 0 deletions
diff --git a/sofort/tools/pkgconf.sh b/sofort/tools/pkgconf.sh
new file mode 100755
index 0000000..a37e368
--- /dev/null
+++ b/sofort/tools/pkgconf.sh
@@ -0,0 +1,107 @@
+#!/bin/sh
+
+# prefix, exec_prefix
+if [ "$PKGCONF_PREFIX" = "$PKGCONF_EXEC_PREFIX" ]; then
+ pkgconf_prefix="${PKGCONF_PREFIX}"
+ pkgconf_exec_prefix='${prefix}'
+else
+ pkgconf_prefix="${PKGCONF_PREFIX}"
+ pkgconf_exec_prefix="${PKGCONF_EXEC_PREFIX}"
+fi
+
+
+# (relative) includedir
+if [ -z "$PKGCONF_INCLUDEDIR" ]; then
+ pkgconf_includedir=
+ pkgconf_cflags=
+else
+ prefix=$(dirname "$PKGCONF_INCLUDEDIR")
+ base=$(basename "$PKGCONF_INCLUDEDIR")
+
+ if [ "$prefix/$base" = "$PKGCONF_PREFIX/$base" ]; then
+ pkgconf_includedir='${prefix}/'"${base}"
+ pkgconf_cflags='-I${includedir}'
+ else
+ pkgconf_includedir="${PKGCONF_INCLUDEDIR}"
+ pkgconf_cflags='-I${includedir}'
+ fi
+fi
+
+
+# (relative) libdir (blank unless needed)
+if [ -z "$PKGCONF_LIBDIR" ]; then
+ pkgconf_libdir=
+else
+ prefix=$(dirname "$PKGCONF_LIBDIR")
+ base=$(basename "$PKGCONF_LIBDIR")
+
+ if [ "$prefix/$base" = "$PKGCONF_EXEC_PREFIX/$base" ]; then
+ pkgconf_libdir='${exec_prefix}/'"${base}"
+ else
+ pkgconf_libdir='${prefix}/'"${PKGCONF_LIBDIR}"
+ fi
+fi
+
+
+# ldflags (--libs)
+if [ -n "$pkgconf_libdir" ] && [ -n "${PKGCONF_NAME}" ]; then
+ pkgconf_ldflags="$pkgconf_libdir -l${PKGCONF_NAME}"
+elif [ -n "${PKGCONF_NAME}" ]; then
+ pkgconf_ldflags="-l${PKGCONF_NAME}"
+else
+ pkgconf_ldflags="$pkgconf_libdir"
+fi
+
+
+# cflags
+if [ -n "$pkgconf_cflags" ] || [ -n "${PKGCONF_DEFS}" ]; then
+ pkgconf_cflags="$pkgconf_cflags ${PKGCONF_DEFS}"
+ pkgconf_cflags=$(printf '%s' "$pkgconf_cflags" | sed -e 's/^[ \t]*//g')
+fi
+
+
+# repo (optional)
+if [ -z "${PKGCONF_REPO}" ]; then
+ pkgconf_repo='#'
+else
+ pkgconf_repo="Repo: ${PKGCONF_REPO}"
+fi
+
+# patches (optional)
+if [ -z "${PKGCONF_PSRC}" ]; then
+ pkgconf_psrc='#'
+else
+ pkgconf_psrc="Patches: ${PKGCONF_PSRC}"
+fi
+
+# distro (optional)
+if [ -z "${PKGCONF_DURL}" ]; then
+ pkgconf_durl='#'
+else
+ pkgconf_durl="Distro: ${PKGCONF_DURL}"
+fi
+
+
+# output (without trailing spaces)
+cat << _EOF | grep -v '^#' | sed 's/[ \t]*$//'
+###
+prefix=$pkgconf_prefix
+exec_prefix=$pkgconf_exec_prefix
+includedir=$pkgconf_includedir
+libdir=$pkgconf_libdir
+
+Name: ${PKGCONF_NAME}
+Description: ${PKGCONF_DESC}
+URL: ${PKGCONF_USRC}
+Version: ${PKGCONF_VERSION}
+$pkgconf_repo
+$pkgconf_psrc
+$pkgconf_durl
+
+Cflags: $pkgconf_cflags
+Libs: $pkgconf_ldflags
+###
+_EOF
+
+# all done
+exit 0
diff --git a/sofort/tools/version.sh b/sofort/tools/version.sh
new file mode 100755
index 0000000..f510a32
--- /dev/null
+++ b/sofort/tools/version.sh
@@ -0,0 +1,72 @@
+#!/bin/sh
+
+set -eu
+
+usage()
+{
+cat << EOF >&2
+
+Usage:
+ -h show this HELP message
+ -s SRCDIR set source directory
+ -o OUTPUT set output header
+ -p PREFIX set macro prefix
+
+EOF
+exit 1
+}
+
+
+# one
+workdir=$(pwd)
+srcdir=
+output=
+prefix=
+
+
+while getopts "hs:o:p:" opt; do
+ case $opt in
+ h)
+ usage
+ ;;
+ s)
+ srcdir="$OPTARG"
+ ;;
+ o)
+ output="$OPTARG"
+ ;;
+ p)
+ prefix="$OPTARG"
+ ;;
+ \?)
+ printf "Invalid option: -%s" "$OPTARG" >&2
+ usage
+ ;;
+ esac
+done
+
+
+# two
+if [ -z "$srcdir" ] || [ -z "$output" ] || [ -z "$prefix" ]; then
+ usage
+fi
+
+cd "$srcdir"
+
+gitver=$(git rev-parse --verify HEAD 2>/dev/null) || gitver="unknown"
+cvdate=$(git show -s --format=%ci $gitver 2>/dev/null) || cvdate=$(date)
+
+vmacro=$(printf '%s' "$prefix"'_GIT_VERSION' | tr '[:lower:]' '[:upper:]')
+dmacro=$(printf '%s' "$prefix"'_GIT_DATE ' | tr '[:lower:]' '[:upper:]')
+
+cd "$workdir"
+
+
+# three
+printf '#define %s "%s"\n#define %s "%s"\n' \
+ "$vmacro" "$gitver" \
+ "$dmacro" "$cvdate" \
+ > "$output"
+
+# all done
+exit 0