summaryrefslogtreecommitdiff
path: root/win32utils/makeversion.pl
blob: 17ffb8c714ad3a41348675f1de9ca5321c22482a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/perl
#
# Copyright (C) 2004, 2007, 2012, 2013  Internet Systems Consortium, Inc. ("ISC")
# Copyright (C) 2001  Internet Software Consortium.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
# AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
# PERFORMANCE OF THIS SOFTWARE.

# $Id$ 

# This script takes the version information from the version file located
# at the root of the source tree and the api files in each library directory
# and writes the resulting information into a version.h file that the build
# process uses to build the executable code.
# This program was written by PDM. danny.mayer@nominum.com 1-Jul-2001.

# List of directories with version files
@dirlist = ("isc","dns","isccc","isccfg","lwres","bind9");
$LibMacros{"isc"} = "LIBISC_EXPORTS";
$LibMacros{"dns"} = "LIBDNS_EXPORTS";
$LibMacros{"isccc"} = "LIBISCCC_EXPORTS";
$LibMacros{"isccfg"} = "LIBISCCFG_EXPORTS";
$LibMacros{"lwres"} = "LIBLWRES_EXPORTS";
$LibMacros{"bind9"} = "LIBBIND9_EXPORTS";


@VersionNames = ("LIBINTERFACE", "LIBREVISION", "LIBAGE");
$versionfile = "versions.h";
$versionpath = "../$versionfile";

#
# First get the version information
#
open (VERSIONFILE, "../version");
while (<VERSIONFILE>) {
	chomp;
	($data) = split(/\#/);
	if($data) {
		($name, $value) = split(/=/,$data);
		($name) = split(/\s+/, $name);
                if ($name eq 'PRODUCT' || $name eq 'DESCRIPTION') {
                        ($value) =~ s/^["\s]+//;
                        ($value) =~ s/["\s]+$//;
                } else {
                        ($value) = split(/\s+/, $value);
                }
		$Versions{$name} = $value;
	}
}
close(VERSIONFILE);

# Now set up the output version file

$ThisDate = scalar localtime();
open (OUTVERSIONFILE, ">$versionpath") ||
      die "Can't open output file $versionpath: $!";

#Standard Header

print OUTVERSIONFILE '/*
 * Copyright (C) 2001  Internet Software Consortium.
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM
 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

';

print OUTVERSIONFILE "/*\n";
print OUTVERSIONFILE " * $versionfile.";
print OUTVERSIONFILE "  Generated automatically by makeversion.pl.\n";
print OUTVERSIONFILE " * Date generated: $ThisDate\n";
print OUTVERSIONFILE " */\n\n";

print OUTVERSIONFILE '
#ifndef  VERSIONS_H
#define VERSIONS_H 1

';

if ($Versions{'PATCHVER'} != "") {
$Version = "$Versions{'MAJORVER'}.$Versions{'MINORVER'}.$Versions{'PATCHVER'}";
} else {
	$Version = "$Versions{'MAJORVER'}.$Versions{'MINORVER'}";
}
$Version = "$Version$Versions{'RELEASETYPE'}$Versions{'RELEASEVER'}";
print "BIND Version: $Version\n";

print OUTVERSIONFILE "#define VERSION \"$Version\"\n";
print OUTVERSIONFILE "#define PRODUCT \"$Versions{'PRODUCT'}\"\n\n";
print OUTVERSIONFILE "#define DESCRIPTION \"$Versions{'DESCRIPTION'}\"\n\n";

foreach $dir (@dirlist) {
	$apifile = "../lib/$dir/api";
	open (APIVERSION, $apifile);
	while (<APIVERSION>) {
		chomp;
		($data) = split(/\#/);
		if ($data) {
			($name, $value) = split(/=/, $data);
			$name =~ s/\s+//;
			$value =~ s/\s+//;
			 $ApiVersions{$name} = $value;
		}
	}

	print OUTVERSIONFILE "\n#ifdef $LibMacros{$dir}\n";
	foreach $name (@VersionNames) {
		print OUTVERSIONFILE "#define $name\t$ApiVersions{$name}\n";
	}
	print OUTVERSIONFILE "#endif\n\n";
}

print OUTVERSIONFILE "#endif /* VERSIONS_H */\n";
close OUTVERSIONFILE;