blob: d419f1c10f3279957295a2825ecb128da162e1ee [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."
Paul Bakkereaed9df2013-09-18 21:19:35 +020029 echo -e " --soversion <version>\tSO version to bump to."
Paul Bakker34558732012-11-26 17:18:12 +010030 echo -e " -v|--verbose\t\tVerbose."
31 exit 1
32 ;;
33 *)
34 # print error
35 echo "Unknown argument: '$1'"
36 exit 1
37 ;;
38 esac
39 shift
40done
41
42if [ "X" = "X$VERSION" ];
43then
44 echo "No version specified. Unable to continue."
45 exit 1
46fi
47
48[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020049sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010050mv tmp library/CMakeLists.txt
51
52if [ "X" != "X$SOVERSION" ];
53then
54 [ $VERBOSE ] && echo "Bumping SOVERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020055 sed -e "s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SOVERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010056 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010057
58 [ $VERBOSE ] && echo "Bumping SOVERSION in library/Makefile"
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020059 sed -e "s/SOEXT=so.[0-9]\{1,\}/SOEXT=so.$SOVERSION/g" < library/Makefile > tmp
Paul Bakker91180722013-11-05 11:28:32 +010060 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +010061fi
62
63[ $VERBOSE ] && echo "Bumping VERSION in include/polarssl/version.h"
64read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
65VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
66cat include/polarssl/version.h | \
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020067 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
68 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
69 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
70 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
71 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
72 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +010073 > tmp
74mv tmp include/polarssl/version.h
75
76[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020077sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +010078mv tmp tests/suites/test_suite_version.data
79
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +000080[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
81for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +010082do
Manuel Pégourié-Gonnardc54931a2015-09-17 11:51:55 +020083 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +010084 mv tmp $i
85done
86
Paul Bakker0f90d7d2014-04-30 11:49:44 +020087[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +020088scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +020089
90[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +020091scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +020092
93[ $VERBOSE ] && echo "Re-generating visualc files"
94scripts/generate_visualc_files.pl