1#! /bin/sh 2# Script to build release-archives with 3# 4 5version=$1 6 7if [ -z "$version" ]; then 8 echo "Specify a version number!" 9 exit 10fi 11 12if [ "xonly" = "x$2" ]; then 13 echo "Setup version number only!" 14 only=1 15fi 16 17libversion="$version" 18 19major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"` 20minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"` 21patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"` 22 23numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"` 24 25HEADER=include/libssh2.h 26 27if test -z "$only"; then 28 ext=".dist" 29 # when not setting up version numbers locally 30 for a in $HEADER; do 31 cp $a "$a$ext" 32 done 33 HEADER="$HEADER$ext" 34fi 35 36# requires a date command that knows -u for UTC time zone 37datestamp=`LC_TIME=C date -u` 38 39# Replace in-place version number in header file: 40sed -i -e 's/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION "'$libversion'"/g' \ 41 -e 's/^#define LIBSSH2_VERSION_NUM .*/#define LIBSSH2_VERSION_NUM 0x'$numeric'/g' \ 42 -e 's/^#define LIBSSH2_VERSION_MAJOR .*/#define LIBSSH2_VERSION_MAJOR '$major'/g' \ 43 -e 's/^#define LIBSSH2_VERSION_MINOR .*/#define LIBSSH2_VERSION_MINOR '$minor'/g' \ 44 -e 's/^#define LIBSSH2_VERSION_PATCH .*/#define LIBSSH2_VERSION_PATCH '$patch'/g' \ 45 -e "s/^#define LIBSSH2_TIMESTAMP .*/#define LIBSSH2_TIMESTAMP \"$datestamp\"/g" \ 46 $HEADER 47 48echo "libssh2 version $libversion" 49echo "libssh2 numerical $numeric" 50echo "datestamp $datestamp" 51 52if test -n "$only"; then 53 # done! 54 exit; 55fi 56 57findprog() 58{ 59 file="$1" 60 for part in `echo $PATH| tr ':' ' '`; do 61 path="$part/$file" 62 if [ -x "$path" ]; then 63 # there it is! 64 return 1 65 fi 66 done 67 68 # no such executable 69 return 0 70} 71 72############################################################################ 73# 74# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has 75# been modified. 76# 77 78if { findprog automake >/dev/null 2>/dev/null; } then 79 echo "- Could not find or run automake, I hope you know what you're doing!" 80else 81 echo "Runs automake --include-deps" 82 automake --include-deps Makefile >/dev/null 83fi 84 85####################################################################### 86# 87# Generate the changelog 88# 89echo "generate NEWS" 90git log --pretty=fuller --no-color --date=short --decorate=full -1000 | ./git2news.pl > NEWS.dist 91 92############################################################################ 93# 94# Now run make dist to generate a tar.gz archive 95# 96 97echo "make dist" 98targz="libssh2-$version.tar.gz" 99make -s dist VERSION=$version 100