blob: d9f06bd25e478b32c9b7343dc1612fa1ae5887b4 [file] [log] [blame]
Paul Bakker34558732012-11-26 17:18:12 +01001#!/bin/bash
2
3VERSION=""
4SOVERSION=""
5
6# Parse arguments
7#
8until [ -z "$1" ]
9do
10 case "$1" in
11 --version)
12 # Version to use
13 shift
14 VERSION=$1
15 ;;
16 --soversion)
17 shift
18 SOVERSION=$1
19 ;;
20 -v|--verbose)
21 # Be verbose
22 VERBOSE="1"
23 ;;
24 -h|--help)
25 # print help
26 echo "Usage: $0"
27 echo -e " -h|--help\t\t\tPrint this help."
28 echo -e " --version <version>\tVersion to bump to."
29 echo -e " -v|--verbose\t\tVerbose."
30 exit 1
31 ;;
32 *)
33 # print error
34 echo "Unknown argument: '$1'"
35 exit 1
36 ;;
37 esac
38 shift
39done
40
41if [ "X" = "X$VERSION" ];
42then
43 echo "No version specified. Unable to continue."
44 exit 1
45fi
46
47[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020048sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010049mv tmp library/CMakeLists.txt
50
51if [ "X" != "X$SOVERSION" ];
52then
53 [ $VERBOSE ] && echo "Bumping SOVERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020054 sed -e "s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SOVERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010055 mv tmp library/CMakeLists.txt
Paul Bakkercf78ba22013-11-05 11:28:32 +010056
57 [ $VERBOSE ] && echo "Bumping SOVERSION in library/Makefile"
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020058 sed -e "s/SONAME=libpolarssl.so.[0-9]\{1,\}/SONAME=libpolarssl.so.$SOVERSION/g" -e "s/DLEXT=so.[0-9]\{1,\}/DLEXT=so.$SOVERSION/g" < library/Makefile > tmp
Paul Bakkercf78ba22013-11-05 11:28:32 +010059 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +010060fi
61
62[ $VERBOSE ] && echo "Bumping VERSION in include/polarssl/version.h"
63read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
64VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
65cat include/polarssl/version.h | \
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020066 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
67 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
68 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
69 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
70 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
71 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"PolarSSL $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +010072 > tmp
73mv tmp include/polarssl/version.h
74
75[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020076sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +010077mv tmp tests/suites/test_suite_version.data
78
79[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/polarssl.doxyfile and doxygen/input/doc_mainpage.h"
80for i in doxygen/polarssl.doxyfile doxygen/input/doc_mainpage.h;
81do
Manuel Pégourié-Gonnard5b76bb82015-09-17 11:54:19 +020082 sed -e "s/PolarSSL v[0-9\.]\{1,\}/PolarSSL v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +010083 mv tmp $i
84done
85