"origin" appears to be a safer bet than "@{upstream}".
[metze/wireshark/wip.git] / make-version.pl
1 #!/usr/bin/perl -w
2 #
3 # Copyright 2004 Jörg Mayer (see AUTHORS file)
4 #
5 # $Id$
6 #
7 # Wireshark - Network traffic analyzer
8 # By Gerald Combs <gerald@wireshark.org>
9 # Copyright 1998 Gerald Combs
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License
13 # as published by the Free Software Foundation; either version 2
14 # of the License, or (at your option) any later version.
15 #
16 # This program is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19 # GNU General Public License for more details.
20 #
21 # You should have received a copy of the GNU General Public License
22 # along with this program; if not, write to the Free Software
23 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
24
25 # See below for usage
26 #
27 # If "version.conf" is present, it is parsed for configuration values.
28 # Possible values are:
29 #
30 #   enable     - Enable or disable versioning.  Zero (0) disables, nonzero
31 #                enables.
32 #   svn_client - Use svn client i.s.o. ugly internal SVN file hack
33 #   format     - A strftime() formatted string to use as a template for
34 #                the version string. The sequence "%#" will substitute
35 #                the SVN revision number.
36 #   pkg_enable - Enable or disable local package versioning.
37 #   pkg_format - Like "format", but used for the local package version.
38 #
39 # If run with the "-r" or "--set-release" argument the AC_INIT macro in
40 # configure.ac and the VERSION macro in config.nmake will have the
41 # pkg_format template appended to the version number. version.h will
42 # _not_ be generated if either argument is present.
43 #
44 # Default configuration:
45 #
46 # enable: 1
47 # svn_client: 1
48 # format: SVN %Y%m%d%H%M%S
49 # pkg_enable: 1
50 # pkg_format: -%#
51
52 # XXX - We're pretty dumb about the "%#" substitution, and about having
53 # spaces in the package format.
54
55 use strict;
56
57 use Time::Local;
58 use File::Basename;
59 use POSIX qw(strftime);
60 use Getopt::Long;
61 use Pod::Usage;
62 use IO::Handle;
63 use English;
64
65 my $version_file = 'version.h';
66 my $package_string = "";
67 my $vconf_file = 'version.conf';
68 my $tortoise_file = "tortoise_template";
69 my $last_change = 0;
70 my $num_commits = 0;
71 my $commit_id = '';
72 my $repo_branch = "unknown";
73 my $git_description = undef;
74 my $get_svn = 0;
75 my $set_svn = 0;
76 my $set_version = 0;
77 my $set_release = 0;
78 my %version_pref = (
79         "version_major" => 1,
80         "version_minor" => 11,
81         "version_micro" => 3,
82         "version_build" => 0,
83
84         "enable"        => 1,
85         "git_client"    => 0,
86         "svn_client"    => 1,
87         "tortoise_svn"  => 0,
88         "format"        => "git %Y%m%d%H%M%S",
89         "is_release"    => 0,
90
91         # Normal development builds
92         "pkg_enable" => 1,
93         "pkg_format" => "-%#",
94
95         # Development releases
96         #"pkg_enable" => 0,
97         #"pkg_format" => "",
98         );
99 my $srcdir = ".";
100 my $info_cmd = "";
101
102 # Ensure we run with correct locale
103 $ENV{LANG} = "C";
104 $ENV{LC_ALL} = "C";
105 $ENV{GIT_PAGER} = "";
106
107 # Run "svn info".  Parse out the most recent modification time and the
108 # revision number.
109 sub read_repo_info {
110         my $line;
111         my $version_format = $version_pref{"format"};
112         my $package_format = "";
113         my $in_entries = 0;
114         my $svn_name;
115         my $repo_version;
116         my $repo_root = undef;
117         my $repo_url = undef;
118         my $do_hack = 1;
119         my $info_source = "Unknown";
120
121         if ($version_pref{"pkg_enable"}) {
122                 $package_format = $version_pref{"pkg_format"};
123         }
124
125         if (-d "$srcdir/.git" && ! -d "$srcdir/.git/svn") {
126                 $info_source = "Command line (git)";
127                 $version_pref{"git_client"} = 1;
128         } elsif (-d "$srcdir/.svn" or -d "$srcdir/../.svn") {
129                 $info_source = "Command line (svn info)";
130                 $info_cmd = "svn info $srcdir";
131         } elsif (-d "$srcdir/.git/svn") {
132                 $info_source = "Command line (git-svn)";
133                 $info_cmd = "(cd $srcdir; git svn info)";
134         }
135
136         #Git can give us:
137         #
138         # A big ugly hash: git rev-parse HEAD
139         # 1ddc83849075addb0cac69a6fe3782f4325337b9
140         #
141         # A small ugly hash: git rev-parse --short HEAD
142         # 1ddc838
143         #
144         # The upstream branch path: git rev-parse --abbrev-ref --symbolic-full-name origin
145         # origin/master-1.8
146         #
147         # A version description: git describe --tags --dirty
148         # wireshark-1.8.12-15-g1ddc838
149         #
150         # Number of commits in this branch: git rev-list --count HEAD
151         # 48879
152         #
153         # Number of commits since 1.8.0: git rev-list --count 5e212d72ce098a7fec4332cbe6c22fcda796a018..HEAD
154         # 320
155         #
156         # Refs: git ls-remote code.wireshark.org:wireshark
157         # ea19c7f952ce9fc53fe4c223f1d9d6797346258b (r48972, changed version to 1.11.0)
158
159         if ($version_pref{"git_client"}) {
160                 eval {
161                         use warnings "all";
162                         no warnings "all";
163
164                         chomp($line = qx{git --git-dir=$srcdir/.git log -1 --pretty=format:%at});
165                         if ($? == 0 && length($line) > 1) {
166                                 $last_change = $line;
167                         }
168
169                         # Commits since last annotated tag.
170                         chomp($line = qx{git --git-dir=$srcdir/.git describe --long --always});
171                         if ($? == 0 && length($line) > 1) {
172                                 my @parts = split(/-/, $line);
173                                 $num_commits = $parts[-2];
174                                 $commit_id = $parts[-1];
175                         }
176
177                         # Current short hash prefixed with "g"
178                         chomp($line = qx{git --git-dir=$srcdir/.git rev-parse --short HEAD});
179                         if ($? == 0 && length($line) > 1) {
180                         }
181
182                         chomp($line = qx{git --git-dir=$srcdir/.git ls-remote --get-url origin});
183                         if ($? == 0 && length($line) > 1) {
184                                 $repo_url = $line;
185                         }
186
187                         # Probably not quite what we're looking for
188                         chomp($line = qx{git --git-dir=$srcdir/.git rev-parse --abbrev-ref --symbolic-full-name origin});
189                         if ($? == 0 && length($line) > 1) {
190                                 $repo_branch = basename($line);
191                         }
192
193                         chomp($line = qx{git --git-dir=$srcdir/.git describe --dirty --match "v*"});
194                         if ($? == 0 && length($line) > 1) {
195                                 $git_description = "wireshark-" . substr($line, 1);
196                         }
197
198                         1;
199                 };
200
201                 if ($last_change && $num_commits && $repo_url && $repo_branch) {
202                         $do_hack = 0;
203                 }
204         } elsif ($version_pref{"svn_client"}) {
205                 eval {
206                         use warnings "all";
207                         no warnings "all";
208                         $line = qx{$info_cmd};
209                         if (defined($line)) {
210                                 if ($line =~ /Last Changed Date: (\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
211                                         $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
212                                 }
213                                 if ($line =~ /Last Changed Rev: (\d+)/) {
214                                         $num_commits = $1;
215                                 }
216                                 if ($line =~ /URL: (\S+)/) {
217                                         $repo_url = $1;
218                                 }
219                                 if ($line =~ /Repository Root: (\S+)/) {
220                                         $repo_root = $1;
221                                 }
222                         }
223                         1;
224                 };
225
226                 if ($last_change && $num_commits && $repo_url && $repo_root) {
227                         $do_hack = 0;
228                 }
229         } elsif ($version_pref{"tortoise_svn"}) {
230                 # Dynamically generic template file needed by TortoiseSVN
231                 open(TORTOISE, ">$tortoise_file");
232                 print TORTOISE "#define GITVERSION \"\$WCREV\$\"\r\n";
233                 print TORTOISE "#define GITBRANCH \"\$WCURL\$\"\r\n";
234                 close(TORTOISE);
235
236                 $info_source = "Command line (SubWCRev)";
237                 $info_cmd = "SubWCRev $srcdir $tortoise_file $version_file";
238                 my $tortoise = system($info_cmd);
239                 if ($tortoise == 0) {
240                         $do_hack = 0;
241                 }
242
243                 #clean up the template file
244                 unlink($tortoise_file);
245         }
246
247         if ($num_commits == 0) {
248                 # Fall back to config.nmake
249                 $info_source = "Prodding config.nmake";
250                 my $filepath = "$srcdir/config.nmake";
251                 open(CFGNMAKE, "< $filepath") || die "Can't read $filepath!";
252                 while ($line = <CFGNMAKE>) {
253                         if ($line =~ /^GIT_REVISION=(\d+)/) {
254                                 $num_commits = $1;
255                                 $do_hack = 0;
256                                 last;
257                         }
258                 }
259                 close (CFGNMAKE);
260         }
261         if ($num_commits == 0 and -d "$srcdir/.git") {
262
263                 # Try git...
264                 eval {
265                         use warnings "all";
266                         no warnings "all";
267                         # If someone had properly tagged 1.9.0 we could also use
268                         # "git describe --abbrev=1 --tags HEAD"
269                         
270                         $info_cmd = "(cd $srcdir; git log --format='%b' -n 1)";
271                         $line = qx{$info_cmd};
272                         if (defined($line)) {
273                                 if ($line =~ /svn path=.*; revision=(\d+)/) {
274                                         $num_commits = $1;
275                                 }
276                         }
277                         $info_cmd = "(cd $srcdir; git log --format='%ad' -n 1 --date=iso)";
278                         $line = qx{$info_cmd};
279                         if (defined($line)) {
280                                 if ($line =~ /(\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
281                                         $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
282                                 }
283                         }
284                         $info_cmd = "(cd $srcdir; git branch)";
285                         $line = qx{$info_cmd};
286                         if (defined($line)) {
287                                 if ($line =~ /\* (\S+)/) {
288                                         $repo_branch = $1;
289                                 }
290                         }
291                         1;
292                         };
293         }
294         if ($num_commits == 0 and -d "$srcdir/.bzr") {
295
296                 # Try bzr...
297                 eval {
298                         use warnings "all";
299                         no warnings "all";
300                         $info_cmd = "(cd $srcdir; bzr log -l 1)";
301                         $line = qx{$info_cmd};
302                         if (defined($line)) {
303                                 if ($line =~ /timestamp: \S+ (\d{4})-(\d\d)-(\d\d) (\d\d):(\d\d):(\d\d)/) {
304                                         $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
305                                 }
306                                 if ($line =~ /svn revno: (\d+) \(on (\S+)\)/) {
307                                         $num_commits = $1;
308                                         $repo_branch = $2;
309                                 }
310                         }
311                         1;
312                         };
313         }
314
315
316         # 'svn info' failed or the user really wants us to dig around in .svn/entries
317         if ($do_hack) {
318                 # Start of ugly internal SVN file hack
319                 if (! open (ENTRIES, "< $srcdir/.svn/entries")) {
320                         print ("Unable to open $srcdir/.svn/entries\n");
321                 } else {
322                         $info_source = "Prodding .svn";
323                         # We need to find out whether our parser can handle the entries file
324                         $line = <ENTRIES>;
325                         chomp $line;
326                         if ($line eq '<?xml version="1.0" encoding="utf-8"?>') {
327                                 $repo_version = "pre1.4";
328                         } elsif ($line =~ /^8$/) {
329                                 $repo_version = "1.4";
330                         } else {
331                                 $repo_version = "unknown";
332                         }
333
334                         if ($repo_version eq "pre1.4") {
335                                 # The entries schema is flat, so we can use regexes to parse its contents.
336                                 while ($line = <ENTRIES>) {
337                                         if ($line =~ /<entry$/ || $line =~ /<entry\s/) {
338                                                 $in_entries = 1;
339                                                 $svn_name = "";
340                                         }
341                                         if ($in_entries) {
342                                                 if ($line =~ /name="(.*)"/) { $svn_name = $1; }
343                                                 if ($line =~ /committed-date="(\d{4})-(\d\d)-(\d\d)T(\d\d):(\d\d):(\d\d)/) {
344                                                         $last_change = timegm($6, $5, $4, $3, $2 - 1, $1);
345                                                 }
346                                                 if ($line =~ /revision="(\d+)"/) { $num_commits = $1; }
347                                         }
348                                         if ($line =~ /\/>/) {
349                                                 if (($svn_name eq "" || $svn_name eq "svn:this_dir") &&
350                                                                 $last_change && $num_commits) {
351                                                         $in_entries = 0;
352                                                         last;
353                                                 }
354                                         }
355                                         # XXX - Fetch the repository root & URL
356                                 }
357                         }
358                         close ENTRIES;
359                 }
360         }
361
362         # If we picked up the revision and modification time,
363         # generate our strings.
364         if ($num_commits && $last_change) {
365                 $version_format =~ s/%#/$num_commits/;
366                 $package_format =~ s/%#/$num_commits-$commit_id/;
367                 $package_string = strftime($package_format, gmtime($last_change));
368         }
369
370         if ($repo_url && $repo_root && index($repo_url, $repo_root) == 0) {
371                 $repo_branch = substr($repo_url, length($repo_root));
372         }
373
374         if ($get_svn) {
375                 print <<"Fin";
376 Commit distance : $num_commits
377 Commit ID       : $commit_id
378 Revision source : $info_source
379 Release stamp   : $package_string
380 Fin
381         }
382 }
383
384
385 # Read configure.ac, then write it back out with an updated
386 # "AC_INIT" line.
387 sub update_configure_ac
388 {
389         my $line;
390         my $contents = "";
391         my $version = "";
392         my $filepath = "$srcdir/configure.ac";
393
394         return if (!$set_version && $package_string eq "");
395
396         open(CFGIN, "< $filepath") || die "Can't read $filepath!";
397         while ($line = <CFGIN>) {
398                 if ($line =~ /^m4_define\( *\[?version_major\]? *,.*([\r\n]+)$/) {
399                         $line = sprintf("m4_define([version_major], [%d])$1", $version_pref{"version_major"});
400                 } elsif ($line =~ /^m4_define\( *\[?version_minor\]? *,.*([\r\n]+)$/) {
401                         $line = sprintf("m4_define([version_minor], [%d])$1", $version_pref{"version_minor"});
402                 } elsif ($line =~ /^m4_define\( *\[?version_micro\]? *,.*([\r\n]+)$/) {
403                         $line = sprintf("m4_define([version_micro], [%d])$1", $version_pref{"version_micro"});
404                 } elsif ($line =~ /^m4_append\( *\[?version_micro_extra\]? *,.*([\r\n]+)$/) {
405                         $line = sprintf("m4_append([version_micro_extra], [%s])$1", $package_string);
406                 }
407                 $contents .= $line
408         }
409
410         open(CFGIN, "> $filepath") || die "Can't write $filepath!";
411         print(CFGIN $contents);
412         close(CFGIN);
413         print "$filepath has been updated.\n";
414 }
415
416 # Read config.nmake, then write it back out with an updated
417 # "VERSION" line.
418 sub update_config_nmake
419 {
420         my $line;
421         my $contents = "";
422         my $version = "";
423         my $filepath = "$srcdir/config.nmake";
424
425         open(CFGNMAKE, "< $filepath") || die "Can't read $filepath!";
426         while ($line = <CFGNMAKE>) {
427                 if ($line =~ /^GIT_REVISION=.*([\r\n]+)$/) {
428                         $line = sprintf("GIT_REVISION=%d$1", $num_commits);
429                 } elsif ($set_version && $line =~ /^VERSION_MAJOR=.*([\r\n]+)$/) {
430                         $line = sprintf("VERSION_MAJOR=%d$1", $version_pref{"version_major"});
431                 } elsif ($set_version && $line =~ /^VERSION_MINOR=.*([\r\n]+)$/) {
432                         $line = sprintf("VERSION_MINOR=%d$1", $version_pref{"version_minor"});
433                 } elsif ($set_version && $line =~ /^VERSION_MICRO=.*([\r\n]+)$/) {
434                         $line = sprintf("VERSION_MICRO=%d$1", $version_pref{"version_micro"});
435                 } elsif ($line =~ /^VERSION_EXTRA=.*([\r\n]+)$/) {
436                         $line = "VERSION_EXTRA=$package_string$1";
437                 }
438                 $contents .= $line
439         }
440
441         open(CFGNMAKE, "> $filepath") || die "Can't write $filepath!";
442         print(CFGNMAKE $contents);
443         close(CFGNMAKE);
444         print "$filepath has been updated.\n";
445 }
446
447 # Read docbook/asciidoc.conf, then write it back out with an updated
448 # wireshark-version replacement line.
449 sub update_release_notes
450 {
451         my $line;
452         my $contents = "";
453         my $version = "";
454         my $filepath = "$srcdir/docbook/asciidoc.conf";
455
456         return if (!$set_version);
457
458         open(ADOC_CONF, "< $filepath") || die "Can't read $filepath!";
459         while ($line = <ADOC_CONF>) {
460                 # wireshark-version:\[\]=1.9.1
461
462                 if ($line =~ /^wireshark-version:\\\[\\\]=.*([\r\n]+)$/) {
463                         $line = sprintf("wireshark-version:\\\[\\\]=%d.%d.%d$1",
464                                         $version_pref{"version_major"},
465                                         $version_pref{"version_minor"},
466                                         $version_pref{"version_micro"},
467                                        );
468                 }
469                 $contents .= $line
470         }
471
472         open(ADOC_CONF, "> $filepath") || die "Can't write $filepath!";
473         print(ADOC_CONF $contents);
474         close(ADOC_CONF);
475         print "$filepath has been updated.\n";
476 }
477
478 # Read debian/changelog, then write back out an updated version.
479 sub update_debian_changelog
480 {
481         my $line;
482         my $contents = "";
483         my $version = "";
484         my $filepath = "$srcdir/debian/changelog";
485
486         return if ($set_version == 0);
487
488         open(CHANGELOG, "< $filepath") || die "Can't read $filepath!";
489         while ($line = <CHANGELOG>) {
490                 if ($set_version && CHANGELOG->input_line_number() == 1) {
491                         $line = sprintf("wireshark (%d.%d.%d) unstable; urgency=low\n",
492                                         $version_pref{"version_major"},
493                                         $version_pref{"version_minor"},
494                                         $version_pref{"version_micro"},
495                                        );
496                 }
497                 $contents .= $line
498         }
499
500         open(CHANGELOG, "> $filepath") || die "Can't write $filepath!";
501         print(CHANGELOG $contents);
502         close(CHANGELOG);
503         print "$filepath has been updated.\n";
504 }
505
506 # Read debian/wireshark-common.files, then write back out an updated version.
507 # The libraries updated here MUST match the updates made by update_lib_releases
508 # below. We should do this automatically.
509 sub update_debian_wcf
510 {
511         my $line;
512         my $contents = "";
513         my $version = "";
514         my $filepath = "$srcdir/debian/wireshark-common.files";
515
516         return if (!$set_version);
517
518         open(DWCF, "< $filepath") || die "Can't read $filepath!";
519         while ($line = <DWCF>) {
520                 # /usr/lib/wireshark/libwireshark.so.1.1.0
521
522                 if ($line =~ qr{^(/usr/lib/wireshark/lib(wireshark|wiretap|filetap).so\.\d+\.\d+\.)\d+$}) {
523                         $line = sprintf("$1%d\n", $version_pref{"version_micro"});
524                 }
525                 $contents .= $line
526         }
527
528         open(DWCF, "> $filepath") || die "Can't write $filepath!";
529         print(DWCF $contents);
530         close(DWCF);
531         print "$filepath has been updated.\n";
532 }
533
534 # Read Makefile.am for each library, then write back out an updated version.
535 sub update_lib_releases
536 {
537         my $line;
538         my $contents = "";
539         my $version = "";
540         my $filedir;
541         my $filepath;
542
543         return if (!$set_version);
544
545         # The Libtool manual says
546         #   "If the library source code has changed at all since the last
547         #    update, then increment revision (‘c:r:a’ becomes ‘c:r+1:a’)."
548         # epan changes with each minor release, almost by definition. wiretap
549         # and filetap changes with *most* releases.
550         #
551         # http://www.gnu.org/software/libtool/manual/libtool.html#Updating-version-info
552         for $filedir ("epan", "wiretap", "filetap") {   # "wsutil"
553                 $contents = "";
554                 $filepath = $filedir . "/Makefile.am";
555                 open(MAKEFILE_AM, "< $filepath") || die "Can't read $filepath!";
556                 while ($line = <MAKEFILE_AM>) {
557                         # libwireshark_la_LDFLAGS = -version-info 2:1:1 -export-symbols
558
559                         if ($line =~ /^(lib\w+_la_LDFLAGS.*version-info\s+\d+:)\d+(:\d+.*)/) {
560                                 $line = sprintf("$1%d$2\n", $version_pref{"version_micro"});
561                         }
562                         $contents .= $line
563                 }
564
565                 open(MAKEFILE_AM, "> $filepath") || die "Can't write $filepath!";
566                 print(MAKEFILE_AM $contents);
567                 close(MAKEFILE_AM);
568                 print "$filepath has been updated.\n";
569         }
570 }
571
572 # Update distributed files that contain any version information
573 sub update_versioned_files
574 {
575         &update_configure_ac;
576         &update_config_nmake;
577         &update_release_notes;
578         &update_debian_changelog;
579         &update_debian_wcf;
580         &update_lib_releases;
581 }
582
583 # Print the SVN version to $version_file.
584 # Don't change the file if it is not needed.
585 sub print_GIT_REVISION
586 {
587         my $GIT_REVISION;
588         my $needs_update = 1;
589
590         if ($git_description) {
591                 $GIT_REVISION = "#define GITVERSION \"" .
592                         $git_description . "\"\n" .
593                         "#define GITBRANCH \"" . $repo_branch . "\"\n";
594         } elsif ($last_change && $num_commits) {
595                 $GIT_REVISION = "#define GITVERSION \"Git Rev " .
596                         $num_commits . "\"\n" .
597                         "#define GITBRANCH \"" . $repo_branch . "\"\n";
598         } else {
599                 $GIT_REVISION = "#define GITVERSION \"Git Rev Unknown\"\n" .
600                         "#define GITBRANCH \"unknown\"\n";
601         }
602         if (open(OLDREV, "<$version_file")) {
603                 my $old_GIT_REVISION = <OLDREV> . <OLDREV>;
604                 if ($old_GIT_REVISION eq $GIT_REVISION) {
605                         $needs_update = 0;
606                 }
607                 close OLDREV;
608         }
609
610         if (! $set_svn) { return; }
611
612         if ($needs_update) {
613                 # print "Updating $version_file so it contains:\n$GIT_REVISION";
614                 open(VER, ">$version_file") || die ("Cannot write to $version_file ($!)\n");
615                 print VER "$GIT_REVISION";
616                 close VER;
617                 print "$version_file has been updated.\n";
618         } else {
619                 print "$version_file unchanged.\n";
620         }
621 }
622
623 # Read values from the configuration file, if it exists.
624 sub get_config {
625         my $arg;
626         my $show_help = 0;
627
628         # Get our command-line args
629         # XXX - Do we need an option to undo --set-release?
630         GetOptions(
631                    "help|h", \$show_help,
632                    "get-svn|g", \$get_svn,
633                    "set-svn|s", \$set_svn,
634                    "set-version|v", \$set_version,
635                    "set-release|r|package-version|p", \$set_release
636                    ) || pod2usage(2);
637
638         if ($show_help) { pod2usage(1); }
639
640         if ( !( $show_help || $get_svn || $set_svn || $set_version || $set_release ) ) {
641                 $set_svn = 1;
642         }
643
644         if ($#ARGV >= 0) {
645                 $srcdir = $ARGV[0]
646         }
647
648         if (! open(FILE, "<$vconf_file")) {
649                 print STDERR "Version configuration file $vconf_file not "
650                 . "found.  Using defaults.\n";
651                 return 1;
652         }
653
654         while (<FILE>) {
655                 chomp;
656                 next if (/^#/);
657                 next unless (/^(\w+)(:|=)\s*(\S.*)/);
658                 $version_pref{$1} = $3;
659         }
660         close FILE;
661         return 1;
662 }
663
664 ##
665 ## Start of code
666 ##
667
668 &get_config();
669
670 &read_repo_info();
671
672 &print_GIT_REVISION;
673
674 if ($set_version || $set_release) {
675         if ($set_version) {
676                 print "Generating version information\n";
677         }
678
679         if ($version_pref{"enable"} == 0) {
680                 print "Release information disabled in $vconf_file.\n";
681                 $set_release = 0;
682         }
683
684         if ($set_release) {
685                 print "Generating release information\n";
686         } else {
687                 print "Resetting release information\n";
688                 $num_commits = 0;
689                 $package_string = "";
690         }
691
692         &update_versioned_files;
693 }
694
695 __END__
696
697 =head1 NAM
698
699 make-version.pl - Get and set build-time version information for Wireshark
700
701 =head1 SYNOPSIS
702
703 make-version.pl [options] [source directory]
704
705   Options:
706
707     --help, -h                 This help message
708     --get-svn, -g              Print the SVN revision and source.
709     --set-svn, -s              Set the information in version.h
710     --set-version, -v          Set the major, minor, and micro versions in
711                                configure.ac, config.nmake, debian/changelog,
712                                and docbook/asciidoc.conf.
713                                Resets the release information when used by
714                                itself.
715     --set-release, -r          Set the release information in configure.ac
716                                and config.nmake
717     --package-version, -p      Deprecated. Same as --set-release.
718
719 Options can be used in any combination. If none are specified B<--set-svn>
720 is assumed.
721
722 #
723 # Editor modelines  -  http://www.wireshark.org/tools/modelines.html
724 #
725 # Local variables:
726 # c-basic-offset: 8
727 # tab-width: 8
728 # indent-tabs-mode: t
729 # End:
730 #
731 # vi: set shiftwidth=8 tabstop=8 noexpandtab:
732 # :indentSize=8:tabSize=8:noTabs=false:
733 #
734 #