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, but if it is of the form
12 # -<digits> it is assumed to be a snapshot release.
14 # This defines the following macros:
19 # NASM_SUBMINOR_VER -- this is zero if no subminor
20 # NASM_PATCHLEVEL_VER -- this is zero is no patchlevel
21 # NASM_SNAPSHOT -- if snapshot
22 # NASM_VERSION_ID -- version number encoded
23 # NASM_VER -- whole version number as a string
40 undef $man, $min, $smin, $plvl, $tail;
43 if ( $line =~ /^([0-9]+)\.([0-9]+)(.*)$/ ) {
47 if ( $tail =~ /^\.([0-9]+)(.*)$/ ) {
51 if ( $tail =~ /^(pl|\.)([0-9]+)(.*)$/ ) {
54 } elsif ( $tail =~ /^rc([0-9]+)(.*)$/ ) {
60 die "$0: Invalid input format\n";
63 if ($tail =~ /^\-([0-9]+)/) {
69 $nmaj = $maj+0; $nmin = $min+0;
70 $nsmin = $smin+0; $nplvl = $plvl+0;
87 $nasm_id = ($nmaj << 24)+($nmin << 16)+($nsmin << 8)+$nplvl;
89 $mangled_ver = sprintf("%d.%02d.%02d", $nmaj, $nmin, $nsmin);
90 $mangled_ver .= '.'.$nplvl if ($nplvl != 0);
91 ($mtail = $tail) =~ tr/-/./;
92 $mangled_ver .= $mtail;
95 print "#ifndef NASM_VERSION_H\n";
96 print "#define NASM_VERSION_H\n";
97 printf "#define NASM_MAJOR_VER %d\n", $nmaj;
98 printf "#define NASM_MINOR_VER %d\n", $nmin;
99 printf "#define NASM_SUBMINOR_VER %d\n", $nsmin;
100 printf "#define NASM_PATCHLEVEL_VER %d\n", $nplvl;
101 if (defined($snapshot)) {
102 printf "#define NASM_SNAPSHOT %d\n", $snapshot;
104 printf "#define NASM_VERSION_ID 0x%08x\n", $nasm_id;
105 printf "#define NASM_VER \"%s\"\n", $line;
106 print "#endif /* NASM_VERSION_H */\n";
107 } elsif ( $what eq 'mac' ) {
108 printf "%%define __NASM_MAJOR__ %d\n", $nmaj;
109 printf "%%define __NASM_MINOR__ %d\n", $nmin;
110 printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin;
111 printf "%%define __NASM_PATCHLEVEL__ %d\n", $nplvl;
112 if (defined($snapshot)) {
113 printf "%%define __NASM_SNAPSHOT__ %d\n", $snapshot;
115 printf "%%define __NASM_VERSION_ID__ 0%08Xh\n", $nasm_id;
116 printf "%%define __NASM_VER__ \"%s\"\n", $line;
117 } elsif ( $what eq 'sed' ) {
118 printf "s/\@\@NASM_MAJOR\@\@/%d/g\n", $nmaj;
119 printf "s/\@\@NASM_MINOR\@\@/%d/g\n", $nmin;
120 printf "s/\@\@NASM_SUBMINOR\@\@/%d/g\n", $nsmin;
121 printf "s/\@\@NASM_PATCHLEVEL\@\@/%d/g\n", $nplvl;
122 printf "s/\@\@NASM_SNAPSHOT\@\@/%d/g\n", $snapshot; # Possibly empty
123 printf "s/\@\@NASM_VERSION_ID\@\@/%d/g\n", $nasm_id;
124 printf "s/\@\@NASM_VERSION_XID\@\@/0x%08x/g\n", $nasm_id;
125 printf "s/\@\@NASM_VER\@\@/%s/g\n", $line;
126 printf "s/\@\@NASM_MANGLED_VER\@\@/%s/g\n", $mangled_ver;
127 } elsif ( $what eq 'make' ) {
128 printf "NASM_VER=%s\n", $line;
129 printf "NASM_MAJOR_VER=%d\n", $nmaj;
130 printf "NASM_MINOR_VER=%d\n", $nmin;
131 printf "NASM_SUBMINOR_VER=%d\n", $nsmin;
132 printf "NASM_PATCHLEVEL_VER=%d\n", $nplvl;
133 } elsif ( $what eq 'id' ) {
134 print $nasm_id, "\n"; # Print ID in decimal
135 } elsif ( $what eq 'xid' ) {
136 printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
138 die "$0: Unknown output: $what\n";