• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash
2
3if ! test -f configure.ac; then
4    >&2 echo "$(basename $0): script must be called from the package's top directory"
5    exit 1
6fi
7
8declare $(sed -ne '/^LIBCOAP_API_VERSION=[0-9]\+/{p; q}' configure.ac)
9NEW_VERSION=${1:-$LIBCOAP_API_VERSION}
10
11if test "x$NEW_VERSION" = "x$LIBCOAP_API_VERSION"; then
12    >&2 echo "no version change requested, exiting (current version is $LIBCOAP_API_VERSION)"
13    exit 1
14fi
15
16echo $(basename $0): increase version $LIBCOAP_API_VERSION to $NEW_VERSION
17
18# command for move operations on version-controlled files and directories
19MV="git mv"
20move() {
21    source=$1
22    dest=$2
23    test -e "$1" && $MV "$1" "$2"
24}
25
26move include/coap$LIBCOAP_API_VERSION include/coap$NEW_VERSION
27move libcoap-$LIBCOAP_API_VERSION.pc.in libcoap-$NEW_VERSION.pc.in
28move libcoap-$LIBCOAP_API_VERSION.map libcoap-$NEW_VERSION.map
29move libcoap-$LIBCOAP_API_VERSION.sym libcoap-$NEW_VERSION.sym
30
31# sed pattern for include path prefix substitution
32pat='\(#\s*include ["<]coap\)'$LIBCOAP_API_VERSION/
33
34find \( -name \*.h -o -name \*.c \) \
35     -exec grep -q "^$pat" {} \; -print | \
36    (while read fn ; do test -f ${fn}.in || sed -i "s,^$pat,\1$NEW_VERSION/,"  $fn ; done )
37
38# examples-code-check.c generates new files with include statements
39sed -i "s,$pat,\1$NEW_VERSION/," man/examples-code-check.c
40
41pathpat='\(include/coap\)'$LIBCOAP_API_VERSION
42
43# autogen.sh
44for fn in autogen.sh .gitignore build-env/Dockerfile.* ; do
45    sed -i "s,$pathpat,\1$NEW_VERSION,g" $fn
46done
47
48# Adjust LIBCOAP_API_VERSION in CMakeLists.txt
49sed -i "s/^\(set(LIBCOAP_API_VERSION \+\)$LIBCOAP_API_VERSION\( *)\)/\1$NEW_VERSION\2/" CMakeLists.txt
50
51# Adjust LibCoAPIncludeDir in win32/libcoap.props
52sed -i "s/\(<LibCoAPIncludeDir>include\\\coap\)$LIBCOAP_API_VERSION/\1$NEW_VERSION/" win32/libcoap.props
53
54# Finally, increase LIBCOAP_API_VERSION in configure.ac and re-run autoconf
55sed -i "s/^\(LIBCOAP_API_VERSION=\)$LIBCOAP_API_VERSION/\1$NEW_VERSION/" configure.ac && autoreconf
56