1275970Scy#! /bin/sh 2275970Scy 3275970Scy# possible usage: $0 [-f] [version.m4] [version.def] 4275970Scy# 5275970Scy# -f would be 'force the update' 6275970Scy 7275970Scyforce=0 8275970Scyoutputs= 9275970Scyfor i in $* 10275970Scydo 11275970Scy case "$i" in 12275970Scy -f) 13275970Scy force=1 14275970Scy ;; 15275970Scy *version.m4) 16275970Scy outputs="m4/version.m4 $outputs" 17275970Scy ;; 18275970Scy *version.def) 19275970Scy outputs="include/version.def $outputs" 20275970Scy ;; 21275970Scy *version.texi) 22275970Scy outputs="include/version.texi $outputs" 23275970Scy ;; 24275970Scy *) echo "Unrecognized option: $i" 25275970Scy exit 1 26275970Scy ;; 27275970Scy esac 28275970Scydone 29275970Scy 30275970Scycase "$outputs" in 31275970Scy '') outputs="m4/version.m4 include/version.def include/version.texi" ;; 32275970Scyesac 33275970Scy 34275970Scyset -e 35275970Scy 36275970Scy. ../packageinfo.sh 37275970Scy 38275970Scydversion=`../scripts/build/VersionName -p ../packageinfo.sh` 39275970Scy 40275970Scyset +e 41275970Scy 42275970Scy# Create intermediate files in $TEMPDIR defaulting it to /tmp 43275970Scy# if not set. This avoids races when multiple builds run in 44275970Scy# parallel on shared source. 45275970Scy 46275970ScyTEMPDIR=${TEMPDIR=/tmp} 47275970Scy 48275970Scycase "$outputs" in 49275970Scy *version.m4*) 50275970Scy echo "m4_define([VERSION_NUMBER],[${dversion}])" > "${TEMPDIR}/version.m4+" 51275970Scy cmp -s "${TEMPDIR}/version.m4+" m4/version.m4 52275970Scy rc=$? 53275970Scy case "$force$rc" in 54275970Scy 00) 55275970Scy rm -f "${TEMPDIR}/version.m4+" 56275970Scy ;; 57275970Scy *) 58275970Scy mv "${TEMPDIR}/version.m4+" m4/version.m4 59275970Scy ;; 60275970Scy esac 61275970Scy ;; 62275970Scyesac 63275970Scy 64275970Scycase "$outputs" in 65275970Scy *version.def*) 66275970Scy echo "version = '${dversion}';" > "${TEMPDIR}/version.def+" 67275970Scy cmp -s "${TEMPDIR}/version.def+" include/version.def 68275970Scy rc=$? 69275970Scy case "$force$rc" in 70275970Scy 00) 71275970Scy rm -f "${TEMPDIR}/version.def+" 72275970Scy ;; 73275970Scy *) 74275970Scy mv "${TEMPDIR}/version.def+" include/version.def 75275970Scy ;; 76275970Scy esac 77275970Scy ;; 78275970Scyesac 79275970Scy 80275970Scycase "$outputs" in 81275970Scy *version.texi*) 82275970Scy echo "@set UPDATED `date +'%d %B %Y'`" > "${TEMPDIR}/version.texi+" 83275970Scy echo "@set EDITION $dversion" >> "${TEMPDIR}/version.texi+" 84275970Scy echo "@set VERSION $dversion" >> "${TEMPDIR}/version.texi+" 85275970Scy cmp -s "${TEMPDIR}/version.texi+" include/version.texi 86275970Scy rc=$? 87275970Scy case "$force$rc" in 88275970Scy 00) 89275970Scy rm -f "${TEMPDIR}/version.texi+" 90275970Scy ;; 91275970Scy *) 92275970Scy mv "${TEMPDIR}/version.texi+" include/version.texi 93275970Scy ;; 94275970Scy esac 95275970Scy ;; 96275970Scyesac 97