Version 0.99.03
[nasm/avx512.git] / version.pl
blobd8fdad49ffcf7c415496dd0459e809a7052715b9
1 #!/usr/bin/perl
3 # version.pl
5 # Parse the NASM version file and produce appropriate macros
7 # The NASM version number is assumed to consist of:
9 # <major>.<minor>[.<subminor>][pl<patchlevel>]]<tail>
11 # ... where <tail> is not necessarily numeric.
13 # This defines the following macros:
15 # version.h:
16 # NASM_MAJOR_VER
17 # NASM_MINOR_VER
18 # NASM_SUBMINOR_VER -- this is zero if no subminor
19 # NASM_PATCHLEVEL_VER -- this is zero is no patchlevel
20 # NASM_VERSION_ID -- version number encoded
21 # NASM_VER -- whole version number as a string
23 # version.mac:
24 # __NASM_MAJOR__
25 # __NASM_MINOR__
26 # __NASM_SUBMINOR__
27 # __NASM_PATCHLEVEL__
28 # __NASM_VERSION_ID__
29 # __NASM_VER__
32 ($what) = @ARGV;
34 $line = <STDIN>;
35 chomp $line;
37 undef $man, $min, $smin, $plvl, $tail;
39 if ( $line =~ /^([0-9]+)\.([0-9]+)/ ) {
40 $maj = $1;
41 $min = $2;
42 $tail = $';
43 if ( $tail =~ /^\.([0-9]+)/ ) {
44 $smin = $1;
45 $tail = $';
47 if ( $tail =~ /^(pl|\.)([0-9]+)/ ) {
48 $plvl = $2;
49 $tail = $';
51 } else {
52 die "$0: Invalid input format\n";
55 $nmaj = $maj+0; $nmin = $min+0;
56 $nsmin = $smin+0; $nplvl = $plvl+0;
58 $nasm_id = ($nmaj << 24)+($nmin << 16)+($nsmin << 8)+$nplvl;
60 if ( $what eq 'h' ) {
61 print "#ifndef NASM_VERSION_H\n";
62 print "#define NASM_VERSION_H\n";
63 printf "#define NASM_MAJOR_VER %d\n", $nmaj;
64 printf "#define NASM_MINOR_VER %d\n", $nmin;
65 printf "#define NASM_SUBMINOR_VER %d\n", $nsmin;
66 printf "#define NASM_PATCHLEVEL_VER %d\n", $nplvl;
67 printf "#define NASM_VERSION_ID 0x%08x\n", $nasm_id;
68 printf "#define NASM_VER \"%s\"\n", $line;
69 print "#endif /* NASM_VERSION_H */\n";
70 } elsif ( $what eq 'mac' ) {
71 printf "%%define __NASM_MAJOR__ %d\n", $nmaj;
72 printf "%%define __NASM_MINOR__ %d\n", $nmin;
73 printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin;
74 printf "%%define __NASM_PATCHLEVEL__ %d\n", $nplvl;
75 printf "%%define __NASM_VERSION_ID__ 0%08Xh\n", $nasm_id;
76 printf "%%define __NASM_VER__ \"%s\"\n", $line;
77 } elsif ( $what eq 'id' ) {
78 print $nasm_id, "\n"; # Print ID in decimal
79 } elsif ( $what eq 'xid' ) {
80 printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
81 } else {
82 die "$0: Unknown output: $what\n";
85 exit 0;