Check in the rest of the Cygwin support patch...
[nasm/avx512.git] / version.pl
blob14dd40e8003d3c09c842beda0bb97473beb5f9d3
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>]<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_VER -- whole version number as a string
22 # version.mac:
23 # __NASM_MAJOR__
24 # __NASM_MINOR__
25 # __NASM_SUBMINOR__
26 # __NASM_VER__
29 ($what) = @ARGV;
31 $line = <STDIN>;
32 chomp $line;
34 if ( $line =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)/ ) {
35 $maj = $1; $nmaj = $maj+0;
36 $min = $2; $nmin = $min+0;
37 $smin = $3; $nsmin = $smin+0;
38 $tail = $';
39 } elsif ( $line =~ /^([0-9]+)\.([0-9]+)/ ) {
40 $maj = $1; $nmaj = $maj+0;
41 $min = $2; $nmin = $min+0;
42 $smin = ''; $nsmin = 0;
43 $tail = $';
44 } else {
45 die "$0: Invalid input format\n";
48 if ( $what eq 'h' ) {
49 print "#ifndef NASM_VERSION_H\n";
50 print "#define NASM_VERSION_H\n";
51 printf "#define NASM_MAJOR_VER %d\n", $nmaj;
52 printf "#define NASM_MINOR_VER %d\n", $nmin;
53 printf "#define NASM_SUBMINOR_VER %d\n", $nsmin;
54 printf "#define NASM_VER \"%s\"\n", $line;
55 print "#endif /* NASM_VERSION_H */\n";
56 } elsif ( $what eq 'mac' ) {
57 printf "%%define __NASM_MAJOR__ %d\n", $nmaj;
58 printf "%%define __NASM_MINOR__ %d\n", $nmin;
59 printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin;
60 printf "%%define __NASM_VER__ \"%s\"\n", $line;
61 } else {
62 die "$0: Unknown output: $what\n";
65 exit 0;