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