1#!/usr/bin/perl 2# 3# Copyright (C) 2004, 2007, 2012 Internet Systems Consortium, Inc. ("ISC") 4# Copyright (C) 2001 Internet Software Consortium. 5# 6# Permission to use, copy, modify, and/or distribute this software for any 7# purpose with or without fee is hereby granted, provided that the above 8# copyright notice and this permission notice appear in all copies. 9# 10# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH 11# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, 13# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16# PERFORMANCE OF THIS SOFTWARE. 17 18# Id 19 20# This script takes the version information from the version file located 21# at the root of the source tree and the api files in each library directory 22# and writes the resulting information into a version.h file that the build 23# process uses to build the executable code. 24# This program was written by PDM. danny.mayer@nominum.com 1-Jul-2001. 25 26# List of directories with version files 27@dirlist = ("isc","dns","isccc","isccfg","lwres","bind9"); 28$LibMacros{"isc"} = "LIBISC_EXPORTS"; 29$LibMacros{"dns"} = "LIBDNS_EXPORTS"; 30$LibMacros{"isccc"} = "LIBISCCC_EXPORTS"; 31$LibMacros{"isccfg"} = "LIBISCCFG_EXPORTS"; 32$LibMacros{"lwres"} = "LIBLWRES_EXPORTS"; 33$LibMacros{"bind9"} = "LIBBIND9_EXPORTS"; 34 35 36@VersionNames = ("LIBINTERFACE", "LIBREVISION", "LIBAGE"); 37$versionfile = "versions.h"; 38$versionpath = "../$versionfile"; 39 40# 41# First get the version information 42# 43open (VERSIONFILE, "../version"); 44while (<VERSIONFILE>) { 45 chomp; 46 ($data) = split(/\#/); 47 if($data) { 48 ($name, $value) = split(/=/,$data); 49 ($name) = split(/\s+/, $name); 50 ($value) = split(/\s+/, $value); 51 $Versions{$name} = $value; 52 } 53} 54close(VERSIONFILE); 55 56# Now set up the output version file 57 58$ThisDate = scalar localtime(); 59open (OUTVERSIONFILE, ">$versionpath") || 60 die "Can't open output file $versionpath: $!"; 61 62#Standard Header 63 64print OUTVERSIONFILE '/* 65 * Copyright (C) 2001 Internet Software Consortium. 66 * 67 * Permission to use, copy, modify, and distribute this software for any 68 * purpose with or without fee is hereby granted, provided that the above 69 * copyright notice and this permission notice appear in all copies. 70 * 71 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM 72 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL 73 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL 74 * INTERNET SOFTWARE CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, 75 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING 76 * FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, 77 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION 78 * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 79 */ 80 81'; 82 83print OUTVERSIONFILE "/*\n"; 84print OUTVERSIONFILE " * $versionfile."; 85print OUTVERSIONFILE " Generated automatically by makeversion.pl.\n"; 86print OUTVERSIONFILE " * Date generated: $ThisDate\n"; 87print OUTVERSIONFILE " */\n\n"; 88 89print OUTVERSIONFILE ' 90#ifndef VERSIONS_H 91#define VERSIONS_H 1 92 93'; 94 95$Version = "$Versions{'MAJORVER'}.$Versions{'MINORVER'}.$Versions{'PATCHVER'}"; 96$Version = "$Version$Versions{'RELEASETYPE'}$Versions{'RELEASEVER'}"; 97print "BIND Version: $Version\n"; 98 99print OUTVERSIONFILE "#define VERSION \"$Version\"\n\n"; 100 101foreach $dir (@dirlist) { 102 $apifile = "../lib/$dir/api"; 103 open (APIVERSION, $apifile); 104 while (<APIVERSION>) { 105 chomp; 106 ($data) = split(/\#/); 107 if ($data) { 108 ($name, $value) = split(/=/, $data); 109 $name =~ s/\s+//; 110 $value =~ s/\s+//; 111 $ApiVersions{$name} = $value; 112 } 113 } 114 115 print OUTVERSIONFILE "\n#ifdef $LibMacros{$dir}\n"; 116 foreach $name (@VersionNames) { 117 print OUTVERSIONFILE "#define $name\t$ApiVersions{$name}\n"; 118 } 119 print OUTVERSIONFILE "#endif\n\n"; 120} 121 122print OUTVERSIONFILE "#endif /* VERSIONS_H */\n"; 123close OUTVERSIONFILE; 124 125 126