summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
-rw-r--r--Makefile3
-rw-r--r--config.h3
-rwxr-xr-xmake_version_h.pl23
-rw-r--r--mkpasswd.c1
-rw-r--r--whois.c1
6 files changed, 29 insertions, 3 deletions
diff --git a/.gitignore b/.gitignore
index 1542cb1..f990909 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
*_del.h
tld_serv.h
servers_charset.h
+version.h
Makefile.depend
*.o
diff --git a/Makefile b/Makefile
index 30142b9..8c33c61 100644
--- a/Makefile
+++ b/Makefile
@@ -69,6 +69,9 @@ mkpasswd: $(mkpasswd_OBJECTS)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ $(mkpasswd_LDADD) $(LIBS)
##############################################################################
+version.h: debian/changelog make_version_h.pl
+ $(PERL) -w make_version_h.pl $< > $@
+
as_del.h: as_del_list make_as_del.pl
$(PERL) -w make_as_del.pl < $< > $@
diff --git a/config.h b/config.h
index f5830a3..4492e4b 100644
--- a/config.h
+++ b/config.h
@@ -1,6 +1,3 @@
-/* Program version */
-#define VERSION "5.1.1"
-
/* Configurable features */
/* Always hide legal disclaimers */
diff --git a/make_version_h.pl b/make_version_h.pl
new file mode 100755
index 0000000..d7344e9
--- /dev/null
+++ b/make_version_h.pl
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+my $changelog = $ARGV[0] or die "Usage: $0 debian/changelog\n";
+
+open(my $fh, '<', $changelog) or die "open($changelog): $!";
+my $line = <$fh>;
+close($fh) or die "close($changelog): $!";
+
+my ($ver) = $line =~ /^whois \s+ \( ( [^\)]+ ) \) \s+ \S+/x;
+die "Version number not found in $changelog!\n" if not $ver;
+
+$ver =~ s/ ( ~deb\d+.* | ubuntu\d+ ) $//x;
+
+# The version number must not deviate from this format or the -V option
+# to RIPE-like servers will break. If needed, update the previous regexp.
+die "Invalid version number in $changelog!\n"
+ unless $ver =~ /^ \d+\.\d+ ( \.\d+ )? $/x;
+
+print qq|#define VERSION "$ver"\n|;
+
diff --git a/mkpasswd.c b/mkpasswd.c
index d7c31a1..45d2c34 100644
--- a/mkpasswd.c
+++ b/mkpasswd.c
@@ -45,6 +45,7 @@
#endif
/* Application-specific */
+#include "version.h"
#include "utils.h"
/* Global variables */
diff --git a/whois.c b/whois.c
index 8734213..e1fb9e3 100644
--- a/whois.c
+++ b/whois.c
@@ -39,6 +39,7 @@
#endif
/* Application-specific */
+#include "version.h"
#include "data.h"
#include "whois.h"
#include "utils.h"