diff --git a/scripts/config-printflags.sh b/scripts/config-printflags.sh new file mode 100755 index 0000000..5b5906f --- /dev/null +++ b/scripts/config-printflags.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +for pkg in $@ +do + varname="$(echo "${pkg}" | tr a-z A-Z)" + echo '[ -z "${'${varname}'_CFLAGS}" ] && '${varname}'_CFLAGS=$('${pkg}'-config --cflags)"' + echo '[ -z "${'${varname}'_LIBS}" ] && '${varname}'_LIBS=$('${pkg}'-config --cflags)"' +done diff --git a/scripts/version.sh b/scripts/version.sh new file mode 100755 index 0000000..11eb3d6 --- /dev/null +++ b/scripts/version.sh @@ -0,0 +1,126 @@ +#!/bin/sh + +if [ $# -eq 0 ] +then + echo "Usage: $0 COMMANDS" + echo "" + echo " major - bump major version, reset minor and micro" + echo " minor - bump minor version, reset micro" + echo " micro - bump micro version" + echo " libmajor LIB - as major but for soversion" + echo " libminor LIB - as minor but for soversion" + echo " libmicro LIB - as micro but for soversion" + echo " tag - tag version" + echo " push - do a git-push with --tags" + + exit 1 +fi + +edit_versions() { + file="$1" + shift + + SEDCMD="" + while [ $# -ne 0 ] + do + var="$1" + shift + value="$1" + shift + + SEDCMD="${SEDCMD} -e s,^${var}=.*$,${var}=${value}," + done + sed ${SEDCMD} -i "${file}" + git-commit -m "Bump version" "${file}" +} + +bump_major() { + source version + edit_versions "version" "VERMAJOR" "$[${VERMAJOR} + 1]" "VERMINOR" "0" "VERMICRO" "0" +} + +bump_minor() { + source version + edit_versions "version" "VERMINOR" "$[${VERMINOR} + 1]" "VERMICRO" "0" +} + +bump_micro() { + source version + edit_versions "version" "VERMICRO" "$[${VERMICRO} + 1]" +} + +bump_somajor() { + source src/$1/soversion + edit_versions "src/$1/soversion" "SOMAJOR" "$[${SOMAJOR} + 1]" "SOMINOR" "0" "SOMICRO" "0" +} + +bump_sominor() { + source src/$1/soversion + edit_versions "src/$1/soversion" "SOMINOR" "$[${SOMINOR} + 1]" "SOMICRO" "0" +} + +bump_somicro() { + source src/$1/soversion + edit_versions "src/$1/soversion" "SOMICRO" "$[${SOMICRO} + 1]" +} + +do_tag() { + source version + git-tag "${VERMAJOR}.${VERMINOR}.${VERMICRO}" +} + +do_push() { + git-push + git-push --tags +} + +set -ex + +while [ $# -ne 0 ] +do + case $1 in + major) + bump_major + ;; + + minor) + bump_minor + ;; + + micro) + bump_micro + ;; + + libmajor) + bump_somajor $2 + shift + ;; + + libminor) + bump_sominor $2 + shift + ;; + + libmicro) + bump_somicro $2 + shift + ;; + + tag) + do_tag + ;; + + push) + do_push + ;; + + *) + echo "Unrecognised command: $1" + exit 1 + ;; + esac + + shift +done + +true