From d574d7dea0b4bba04ac0d8233453957436e2eb99 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Sun, 15 Jul 2007 21:36:29 +0000 Subject: [PATCH] Added LIBSSH2_TIMESTAMP to the public header and it contains the timestamp of the making of the release archive. Added 'maketgz' as a script to build release archives with, including automated snapshots or whatever. It updates the defines in include/libssh2.h. configure now extracts the version number from the include/libssh2.h header in the source tree instead of using it fixed set in the script (to remove the need for regenerating the configure script when we run maketgz). Makefile.am now has a dist-hook that puts ".dist" files in the release tree instead of the file without the .dist extension, so that we can easily add modified files in release archives. Like maketgz. --- Makefile.am | 9 ++++++ configure.in | 21 ++++++++++++-- include/libssh2.h | 11 +++++++ maketgz | 73 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 112 insertions(+), 2 deletions(-) create mode 100755 maketgz diff --git a/Makefile.am b/Makefile.am index 127e8eb5..2c02c220 100644 --- a/Makefile.am +++ b/Makefile.am @@ -20,3 +20,12 @@ ChangeLog: if test -f .cvsusers; then \ cvs2cl --utc --fsf --FSF --usermap .cvsusers -I ChangeLog -I .cvs; \ fi + +dist-hook: + rm -rf $(top_builddir)/tests/log + find $(distdir) -name "*.dist" -exec rm {} \; + (distit=`find $(srcdir) -name "*.dist"`; \ + for file in $$distit; do \ + strip=`echo $$file | sed -e s/^$(srcdir)// -e s/\.dist//`; \ + cp $$file $(distdir)$$strip; \ + done) diff --git a/configure.in b/configure.in index 2833779a..38ed411d 100644 --- a/configure.in +++ b/configure.in @@ -1,8 +1,25 @@ # AC_PREREQ(2.57) -AC_INIT(libssh2, 0.15, libssh2-devel@lists.sourceforge.net) -AM_INIT_AUTOMAKE(libssh2, 0.15) +AC_INIT(libssh2, [-], libssh2-devel@lists.sourceforge.net) AC_CONFIG_SRCDIR([src]) AC_CONFIG_HEADER([src/libssh2_config.h]) + +dnl SED is needed by some of the tools +AC_PATH_PROG( SED, sed, sed-was-not-found-by-configure, + $PATH:/usr/bin:/usr/local/bin) +AC_SUBST(SED) + +if test "x$SED" = "xsed-was-not-found-by-configure"; then + AC_MSG_WARN([sed was not found, this may ruin your chances to build fine]) +fi + +dnl figure out the libssh2 version +VERSION=`$SED -ne 's/^#define LIBSSH2_VERSION *"\(.*\)"/\1/p' ${srcdir}/include/libssh2.h` +AM_INIT_AUTOMAKE(libssh2,$VERSION) +AC_MSG_CHECKING([libssh2 version]) +AC_MSG_RESULT($VERSION) + +AB_VERSION=$VERSION + AB_INIT # Check for the OS. diff --git a/include/libssh2.h b/include/libssh2.h index 54876b2c..cffd240a 100644 --- a/include/libssh2.h +++ b/include/libssh2.h @@ -104,6 +104,17 @@ typedef long long libssh2_int64_t; */ #define LIBSSH2_VERSION_NUM 0x001000 +/* + * This is the date and time when the full source package was created. The + * timestamp is not stored in CVS, as the timestamp is properly set in the + * tarballs by the maketgz script. + * + * The format of the date should follow this template: + * + * "Mon Feb 12 11:35:33 UTC 2007" + */ +#define LIBSSH2_TIMESTAMP "CVS" + #define LIBSSH2_APINO 200706151200L /* Part of every banner, user specified or not */ diff --git a/maketgz b/maketgz new file mode 100755 index 00000000..ab6656fd --- /dev/null +++ b/maketgz @@ -0,0 +1,73 @@ +#! /bin/sh +# Script to build release-archives with +# + +version=$1 + +if [ -z "$version" ]; then + echo "Specify a version number!" + exit +fi + +libversion="$version" + +major=`echo $libversion |cut -d. -f1 | sed -e "s/[^0-9]//g"` +minor=`echo $libversion |cut -d. -f2 | sed -e "s/[^0-9]//g"` +patch=`echo $libversion |cut -d. -f3 | cut -d- -f1 | sed -e "s/[^0-9]//g"` + +numeric=`perl -e 'printf("%02x%02x%02x\n", '"$major, $minor, $patch);"` + +HEADER=include/libssh2.h + +# requires a date command that knows -u for UTC time zone +datestamp=`date -u` + +# Replace version number in header file: +sed -e 's/^#define LIBSSH2_VERSION .*/#define LIBSSH2_VERSION "'$libversion'"/g' \ + -e 's/^#define LIBSSH2_VERSION_NUM .*/#define LIBSSH2_VERSION_NUM 0x'$numeric'/g' \ + -e 's/^#define LIBSSH2_VERSION_MAJOR .*/#define LIBSSH2_VERSION_MAJOR '$major'/g' \ + -e 's/^#define LIBSSH2_VERSION_MINOR .*/#define LIBSSH2_VERSION_MINOR '$minor'/g' \ + -e 's/^#define LIBSSH2_VERSION_PATCH .*/#define LIBSSH2_VERSION_PATCH '$patch'/g' \ + -e "s/^#define LIBSSH2_TIMESTAMP .*/#define LIBSSH2_TIMESTAMP \"$datestamp\"/g" \ + $HEADER >$HEADER.dist + +echo "libssh2 version $libversion" +echo "libssh2 numerical $numeric" +echo "datestamp $datestamp" + +findprog() +{ + file="$1" + for part in `echo $PATH| tr ':' ' '`; do + path="$part/$file" + if [ -x "$path" ]; then + # there it is! + return 1 + fi + done + + # no such executable + return 0 +} + +############################################################################ +# +# automake is needed to run to make a non-GNU Makefile.in if Makefile.am has +# been modified. +# + +if { findprog automake >/dev/null 2>/dev/null; } then + echo "- Could not find or run automake, I hope you know what you're doing!" +else + echo "Runs automake --include-deps" + automake --include-deps Makefile >/dev/null +fi + +############################################################################ +# +# Now run make dist to generate a tar.gz archive +# + +echo "make dist" +targz="libssh2-$version.tar.gz" +make -s dist VERSION=$version