blob: 8e771053302118c070b8724820afe4dcc6d02d82 [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 ;;
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020016 --so-crypto)
Paul Bakker34558732012-11-26 17:18:12 +010017 shift
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020018 SO_CRYPTO=$1
19 ;;
20 --so-x509)
21 shift
22 SO_X509=$1
23 ;;
24 --so-tls)
25 shift
26 SO_TLS=$1
Paul Bakker34558732012-11-26 17:18:12 +010027 ;;
28 -v|--verbose)
29 # Be verbose
30 VERBOSE="1"
31 ;;
32 -h|--help)
33 # print help
34 echo "Usage: $0"
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020035 echo -e " -h|--help\t\tPrint this help."
Paul Bakker34558732012-11-26 17:18:12 +010036 echo -e " --version <version>\tVersion to bump to."
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020037 echo -e " --so-crypto <version>\tSO version to bump libmbedcrypto to."
38 echo -e " --so-x509 <version>\tSO version to bump libmbedx509 to."
39 echo -e " --so-tls <version>\tSO version to bump libmbedtls to."
Paul Bakker34558732012-11-26 17:18:12 +010040 echo -e " -v|--verbose\t\tVerbose."
41 exit 1
42 ;;
43 *)
44 # print error
45 echo "Unknown argument: '$1'"
46 exit 1
47 ;;
48 esac
49 shift
50done
51
52if [ "X" = "X$VERSION" ];
53then
54 echo "No version specified. Unable to continue."
55 exit 1
56fi
57
58[ $VERBOSE ] && echo "Bumping VERSION in library/CMakeLists.txt"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020059sed -e "s/ VERSION [0-9.]\{1,\}/ VERSION $VERSION/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010060mv tmp library/CMakeLists.txt
61
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020062if [ "X" != "X$SO_CRYPTO" ];
Paul Bakker34558732012-11-26 17:18:12 +010063then
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020064 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/CMakeLists.txt"
65 sed -e "/mbedcrypto/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_CRYPTO/g" < library/CMakeLists.txt > tmp
Paul Bakker34558732012-11-26 17:18:12 +010066 mv tmp library/CMakeLists.txt
Paul Bakker91180722013-11-05 11:28:32 +010067
Manuel Pégourié-Gonnard752c5012015-06-25 11:54:52 +020068 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedcrypto in library/Makefile"
69 sed -e "s/SOEXT_CRYPTO=so.[0-9]\{1,\}/SOEXT_CRYPTO=so.$SO_CRYPTO/g" < library/Makefile > tmp
70 mv tmp library/Makefile
71fi
72
73if [ "X" != "X$SO_X509" ];
74then
75 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/CMakeLists.txt"
76 sed -e "/mbedx509/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_X509/g" < library/CMakeLists.txt > tmp
77 mv tmp library/CMakeLists.txt
78
79 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedx509 in library/Makefile"
80 sed -e "s/SOEXT_X509=so.[0-9]\{1,\}/SOEXT_X509=so.$SO_X509/g" < library/Makefile > tmp
81 mv tmp library/Makefile
82fi
83
84if [ "X" != "X$SO_TLS" ];
85then
86 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/CMakeLists.txt"
87 sed -e "/mbedtls/ s/ SOVERSION [0-9]\{1,\}/ SOVERSION $SO_TLS/g" < library/CMakeLists.txt > tmp
88 mv tmp library/CMakeLists.txt
89
90 [ $VERBOSE ] && echo "Bumping SOVERSION for libmbedtls in library/Makefile"
91 sed -e "s/SOEXT_TLS=so.[0-9]\{1,\}/SOEXT_TLS=so.$SO_TLS/g" < library/Makefile > tmp
Paul Bakker91180722013-11-05 11:28:32 +010092 mv tmp library/Makefile
Paul Bakker34558732012-11-26 17:18:12 +010093fi
94
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000095[ $VERBOSE ] && echo "Bumping VERSION in include/mbedtls/version.h"
Paul Bakker34558732012-11-26 17:18:12 +010096read MAJOR MINOR PATCH <<<$(IFS="."; echo $VERSION)
97VERSION_NR="$( printf "0x%02X%02X%02X00" $MAJOR $MINOR $PATCH )"
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +000098cat include/mbedtls/version.h | \
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +020099 sed -e "s/_VERSION_MAJOR .\{1,\}/_VERSION_MAJOR $MAJOR/" | \
100 sed -e "s/_VERSION_MINOR .\{1,\}/_VERSION_MINOR $MINOR/" | \
101 sed -e "s/_VERSION_PATCH .\{1,\}/_VERSION_PATCH $PATCH/" | \
102 sed -e "s/_VERSION_NUMBER .\{1,\}/_VERSION_NUMBER $VERSION_NR/" | \
103 sed -e "s/_VERSION_STRING .\{1,\}/_VERSION_STRING \"$VERSION\"/" | \
104 sed -e "s/_VERSION_STRING_FULL .\{1,\}/_VERSION_STRING_FULL \"mbed TLS $VERSION\"/" \
Paul Bakker34558732012-11-26 17:18:12 +0100105 > tmp
Manuel Pégourié-Gonnard7f809972015-03-09 17:05:11 +0000106mv tmp include/mbedtls/version.h
Paul Bakker34558732012-11-26 17:18:12 +0100107
108[ $VERBOSE ] && echo "Bumping version in tests/suites/test_suite_version.data"
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200109sed -e "s/version:\".\{1,\}/version:\"$VERSION\"/g" < tests/suites/test_suite_version.data > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100110mv tmp tests/suites/test_suite_version.data
111
Manuel Pégourié-Gonnardf234ff82015-01-22 17:01:27 +0000112[ $VERBOSE ] && echo "Bumping PROJECT_NAME in doxygen/mbedtls.doxyfile and doxygen/input/doc_mainpage.h"
113for i in doxygen/mbedtls.doxyfile doxygen/input/doc_mainpage.h;
Paul Bakker34558732012-11-26 17:18:12 +0100114do
Manuel Pégourié-Gonnardace35992015-06-25 11:51:12 +0200115 sed -e "s/mbed TLS v[0-9\.]\{1,\}/mbed TLS v$VERSION/g" < $i > tmp
Paul Bakker34558732012-11-26 17:18:12 +0100116 mv tmp $i
117done
118
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200119[ $VERBOSE ] && echo "Re-generating library/error.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200120scripts/generate_errors.pl
Paul Bakker0f90d7d2014-04-30 11:49:44 +0200121
122[ $VERBOSE ] && echo "Re-generating library/version_features.c"
Manuel Pégourié-Gonnardd66f9002014-05-09 13:40:14 +0200123scripts/generate_features.pl
Manuel Pégourié-Gonnard71c8f202014-05-09 13:25:10 +0200124
125[ $VERBOSE ] && echo "Re-generating visualc files"
126scripts/generate_visualc_files.pl