Commit e8d15668 authored by Ondřej Surý's avatar Ondřej Surý

Move the version to libknot/version.h, use awk/sed/shell to get the version number

parent 4356080a
......@@ -4,7 +4,7 @@ AC_PREREQ([2.60])
AC_CONFIG_SRCDIR([src/knot/main.c])
# We extract version numbers from src/libknot/libknot.h
define([gv],[perl ./getver.pl ]$1 ./src/libknot/libknot.h)
define([gv],[./getver.sh ]$1)
m4_define([libknot_MAJOR],esyscmd(gv(MAJOR)))dnl
m4_define([libknot_MINOR],esyscmd(gv(MINOR)))dnl
m4_define([libknot_REVISION],esyscmd(gv(RELEASE)))dnl
......
#!/usr/bin/env perl
# Simple script to extract the version number parts from
# src/libknot/libknot.h. If called with the middle word of the
# version macro, it prints the value of that macro. If called with no
# argument, it outputs a human-readable version string. This must be
# run in the project root. It is used by configure.ac and
# docs/naturaldocs/run_docs.sh.
use strict;
my $key = shift;
my $file = shift;
my @version_parts = ();
open FH, "<$file" # old-style filehandle for max. portability
or die "Unable to open 'src/libknot/libknot.h' for reading.\n";
while(<FH>) {
next unless m{versiong3d31a91};
next unless /^#define\s+LIBKNOT_([A-Z0-9]+)_VERSION+\s+(\S+)/;
my ($lk, $lv) = ($1, $2);
if ($lk eq $key) {
chomp $lv;
$lv =~ s/"//g;
print $lv; # no newline
exit(0); # success!
}
push @version_parts, $lv if (!$key);
}
close(FH);
if (scalar @version_parts == 4) {
my $result = join(".", @version_parts[0..2]);
$result .= $version_parts[3];
$result =~ s/"//g;
print $result;
exit(0);
}
exit(1); # failure
#!/bin/sh
echo -n $(awk '/^#define LIBKNOT_'$1'_VERSION/ { print $3 }' src/libknot/version.h | sed -e 's/"//g')
......@@ -26,16 +26,7 @@
#pragma once
/* Version information. This gets parsed by build scripts as well as
* gcc so each #define line in this group must also be splittable on
* whitespace, take the form LIBKNOT_*_VERSION and contain the magical
* trailing comment. */
#define LIBKNOT_MAJOR_VERSION 2 /*versiong3d31a91*/
#define LIBKNOT_MINOR_VERSION 1 /*versiong3d31a91*/
#define LIBKNOT_RELEASE_VERSION 0 /*versiong3d31a91*/
#define LIBKNOT_EXTRA_VERSION "-dev" /*versiong3d31a91*/
/* End parsable section. */
#include "libknot/version.h"
#include "libknot/binary.h"
#include "libknot/codes.h"
#include "libknot/consts.h"
......
/*!
* \file libknot.h
*
* \author Ondřej Surý <ondrej.sury@nic.cz>
*
* \brief Convenience header with version number
*
* \addtogroup libknot
* @{
*/
/* Copyright (C) 2011 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
This program 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 3 of the License, or
(at your option) any later version.
This program 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, see <http://www.gnu.org/licenses/>.
*/
#pragma once
/* Version information. This gets parsed by build scripts as well as
* gcc so each #define line in this group must also be splittable on
* whitespace, take the form LIBKNOT_*_VERSION and contain the magical
* trailing comment. */
#define LIBKNOT_MAJOR_VERSION 2 /*versiong3d31a91*/
#define LIBKNOT_MINOR_VERSION 1 /*versiong3d31a91*/
#define LIBKNOT_RELEASE_VERSION 0 /*versiong3d31a91*/
#define LIBKNOT_EXTRA_VERSION "-dev" /*versiong3d31a91*/
/* End parsable section. */
/*! @} */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment