Fixed c99 data-types after removal of typedefs.
[nasm/sigaren-mirror.git] / version.pl
blob0f9ea750830eeff42982314d47f5f8612154f35c
1 #!/usr/bin/perl
3 # version.pl
4 # $Id$
6 # Parse the NASM version file and produce appropriate macros
8 # The NASM version number is assumed to consist of:
10 # <major>.<minor>[.<subminor>][pl<patchlevel>]]<tail>
12 # ... where <tail> is not necessarily numeric.
14 # This defines the following macros:
16 # version.h:
17 # NASM_MAJOR_VER
18 # NASM_MINOR_VER
19 # NASM_SUBMINOR_VER -- this is zero if no subminor
20 # NASM_PATCHLEVEL_VER -- this is zero is no patchlevel
21 # NASM_VERSION_ID -- version number encoded
22 # NASM_VER -- whole version number as a string
24 # version.mac:
25 # __NASM_MAJOR__
26 # __NASM_MINOR__
27 # __NASM_SUBMINOR__
28 # __NASM_PATCHLEVEL__
29 # __NASM_VERSION_ID__
30 # __NASM_VER__
33 ($what) = @ARGV;
35 $line = <STDIN>;
36 chomp $line;
38 undef $man, $min, $smin, $plvl, $tail;
40 if ( $line =~ /^([0-9]+)\.([0-9]+)/ ) {
41 $maj = $1;
42 $min = $2;
43 $tail = $';
44 if ( $tail =~ /^\.([0-9]+)/ ) {
45 $smin = $1;
46 $tail = $';
48 if ( $tail =~ /^(pl|\.)([0-9]+)/ ) {
49 $plvl = $2;
50 $tail = $';
52 } else {
53 die "$0: Invalid input format\n";
56 $nmaj = $maj+0; $nmin = $min+0;
57 $nsmin = $smin+0; $nplvl = $plvl+0;
59 $nasm_id = ($nmaj << 24)+($nmin << 16)+($nsmin << 8)+$nplvl;
61 if ( $what eq 'h' ) {
62 print "#ifndef NASM_VERSION_H\n";
63 print "#define NASM_VERSION_H\n";
64 printf "#define NASM_MAJOR_VER %d\n", $nmaj;
65 printf "#define NASM_MINOR_VER %d\n", $nmin;
66 printf "#define NASM_SUBMINOR_VER %d\n", $nsmin;
67 printf "#define NASM_PATCHLEVEL_VER %d\n", $nplvl;
68 printf "#define NASM_VERSION_ID 0x%08x\n", $nasm_id;
69 printf "#define NASM_VER \"%s\"\n", $line;
70 print "#endif /* NASM_VERSION_H */\n";
71 } elsif ( $what eq 'mac' ) {
72 printf "%%define __NASM_MAJOR__ %d\n", $nmaj;
73 printf "%%define __NASM_MINOR__ %d\n", $nmin;
74 printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin;
75 printf "%%define __NASM_PATCHLEVEL__ %d\n", $nplvl;
76 printf "%%define __NASM_VERSION_ID__ 0%08Xh\n", $nasm_id;
77 printf "%%define __NASM_VER__ \"%s\"\n", $line;
78 } elsif ( $what eq 'id' ) {
79 print $nasm_id, "\n"; # Print ID in decimal
80 } elsif ( $what eq 'xid' ) {
81 printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
82 } else {
83 die "$0: Unknown output: $what\n";
86 exit 0;