-dnl Zebra, Index Data ApS, 1995-2008
+dnl This file is part of the Zebra server.
+dnl Copyright (C) 1994-2008 Index Data
dnl
AC_PREREQ(2.60)
AC_INIT([idzebra],[2.0.34],[zebra-help@indexdata.dk])
dnl ------ ANSI C Header files
AC_STDC_HEADERS
if test "$ac_cv_header_stdc" = "no"; then
- AC_MSG_WARN(Your system doesn't seem to support ANSI C)
+ AC_MSG_WARN([Your system does not seem to support ANSI C])
fi
AC_SUBST(IDZEBRA_SRC_ROOT)
AC_SUBST(IDZEBRA_BUILD_ROOT)
IDZEBRA_SRC_ROOT=`cd ${srcdir}; pwd`
IDZEBRA_BUILD_ROOT=`pwd`
+dnl
+dnl ------ versioning
+dnl
+WIN_FILEVERSION=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { m = $4; printf("%d,%d,%d,%d", $1, $2, $3 == "" ? "0" : $3, $4 == "" ? "1" : $4);}'`
+AC_SUBST([WIN_FILEVERSION])
+VERSION_HEX=`echo $PACKAGE_VERSION | $AWK 'BEGIN { FS = "."; } { printf("%x", ($1 * 256 + $2) * 256 + $3);}'`
+AC_SUBST([VERSION_HEX])
+if test -d ${srcdir}/.git; then
+ VERSION_SHA1=`git show --pretty=format:%H|head -1`
+else
+ VERSION_SHA1=`head -1 ${srcdir}/ChangeLog|awk '{print $2}'`
+fi
+AC_SUBST([VERSION_SHA1])
+dnl
dnl ------ Create Makefiles
+dnl
AC_OUTPUT([
Makefile
util/Makefile
idzebra.spec
idzebra-config-2.0
Doxyfile
+ include/idzebra/version.h
],[sed s%echo_source=yes%echo_source=no%g < idzebra-config-2.0 > util/idzebra-config-2.0 && chmod +x idzebra-config-2.0 util/idzebra-config-2.0])
echo \
Makefile
Makefile.in
+version.h
*~
bfile.h dict.h isam-codec.h isams.h isamc.h isamb.h util.h \
snippet.h flock.h
+EXTRA_DIST = version.h.in
\ No newline at end of file
+++ /dev/null
-/* This file is part of the Zebra server.
- Copyright (C) 1995-2008 Index Data
-
-Zebra is free software; you can redistribute it and/or modify it under
-the terms of the GNU General Public License as published by the Free
-Software Foundation; either version 2, or (at your option) any later
-version.
-
-Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
-WARRANTY; without even the implied warranty of MERCHANTABILITY or
-FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-*/
-
-#ifndef IDZEBRA_VERSION_H
-#define IDZEBRA_VERSION_H
-
-#include <yaz/yconfig.h>
-
-YAZ_BEGIN_CDECL
-
-#define ZEBRAVER "2.0.34"
-
-#define ZEBRA_FILEVERSION 2,0,34,1
-
-/** \brief Returns Zebra version and system info.
- \param version_str buffer for version (at least 16 bytes)
- \param sys_str buffer for system info (at least 80 bytes)
- \returns version as integer
-*/
-YAZ_EXPORT
-void zebra_get_version(char *version_str, char *sys_str);
-
-YAZ_END_CDECL
-
-#endif
-/*
- * Local variables:
- * c-basic-offset: 4
- * indent-tabs-mode: nil
- * End:
- * vim: shiftwidth=4 tabstop=8 expandtab
- */
-
--- /dev/null
+/* This file is part of the Zebra server.
+ Copyright (C) 1995-2008 Index Data
+
+Zebra is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Zebra is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+*/
+
+#ifndef IDZEBRA_VERSION_H
+#define IDZEBRA_VERSION_H
+
+#include <yaz/yconfig.h>
+
+YAZ_BEGIN_CDECL
+
+/** \brief Version as string */
+#define ZEBRAVER "@VERSION@"
+
+/** \brief Version as integer (for comparison purposes) */
+#define ZEBRA_VERSIONL 0x@VERSION_HEX@
+
+/** \brief Version for Windows DLL/EXE */
+#define ZEBRA_FILEVERSION @WIN_FILEVERSION@
+
+/** \brief SHA1 ID as generated by Git */
+#define ZEBRA_VERSION_SHA1 "@VERSION_SHA1@"
+
+/** \brief Returns Zebra version and SHA1 ID as generated by Git
+ \param version_str buffer for version (at least 16 bytes)
+ \param sha1_str SHA1 ID. Use NULL for not getting the ID
+ \returns version as integer
+
+ The sha1_str if non-NULL must point to a buffer of at least
+ 65 bytes (64 ID + null char).
+*/
+YAZ_EXPORT
+void zebra_get_version(char *version_str, char *sha1_str);
+
+YAZ_END_CDECL
+
+#endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+
--- /dev/null
+#!/usr/bin/tclsh
+
+proc usage {} {
+ puts {mk_version.tcl [-v] configure.ac infile ..}
+ exit 1
+}
+
+set verbose 0
+set l [llength $argv]
+set i 0
+while {$i < $l} {
+ set arg [lindex $argv $i]
+ switch -glob -- $arg {
+ -v {
+ incr verbose
+ }
+ default {
+ if {![info exists conffile]} {
+ set conffile $arg
+ } else {
+ lappend infiles $arg
+ }
+ }
+ }
+ incr i
+}
+if {![info exists infiles]} {
+ puts "mk_version.tcl: missing input file(s)"
+ usage
+}
+
+set f [open $conffile r]
+while {1} {
+ set cnt [gets $f line]
+ if {$cnt < 0} {
+ break
+ }
+ regexp {AC_INIT\([^,]+,\[([0-9.]+)\]} $line s version
+}
+close $f
+
+set maps(VERSION) $version
+
+set c [split $version .]
+
+set versionl [expr ([lindex $c 0] * 256 + [lindex $c 1]) * 256 + [lindex $c 2]]
+set maps(YAZ_VERSION_HEX) [format %x $versionl]
+
+if {[llength $c] == 3} {
+ lappend c 1
+}
+set maps(WIN_FILEVERSION) [join $c ,]
+
+set maps(VERSION_SHA1) {}
+
+foreach x [array names maps] {
+ puts "$x=$maps($x)"
+}
+
+foreach ifile $infiles {
+ set if [open "${ifile}.in" r]
+ set of [open "${ifile}" w]
+
+ while {1} {
+ set cnt [gets $if line]
+ if {$cnt < 0} {
+ break
+ }
+ foreach x [array names maps] {
+ regsub -all "@$x@" $line $maps($x) line
+ }
+ puts $of $line
+ }
+ close $if
+ close $of
+}
#include <string.h>
#include <idzebra/version.h>
-void zebra_get_version(char *version_str, char *sys_str)
+void zebra_get_version(char *version_str, char *sha1_str)
{
if (version_str)
strcpy(version_str, ZEBRAVER);
- if (sys_str)
- {
- strcpy(sys_str, "unknown");
-
-#ifdef WIN32
- strcpy(sys_str, "win32");
-#ifdef _MSC_VER
- yaz_snprintf(sys_str+strlen(sys_str), 25, "; mscver %lu",
- (unsigned long) _MSC_VER);
-#endif
-#endif
-#ifdef HOST_TRIPLET
- strcpy(sys_str, HOST_TRIPLET);
-#endif
- }
+ if (sha1_str)
+ strcpy(sha1_str, ZEBRA_VERSION_SHA1);
}
/*