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", $nmaj, $nmin);
90 if ($nsmin || $nplvl || defined($snapshot)) {
91 $mangled_ver .= sprintf(".%02d", $nsmin);
92 if ($nplvl || defined($snapshot)) {
93 $mangled_ver .= '.'.$nplvl;
96 ($mtail = $tail) =~ tr/-/./;
97 $mangled_ver .= $mtail;
100 print "#ifndef NASM_VERSION_H\n";
101 print "#define NASM_VERSION_H\n";
102 printf "#define NASM_MAJOR_VER %d\n", $nmaj;
103 printf "#define NASM_MINOR_VER %d\n", $nmin;
104 printf "#define NASM_SUBMINOR_VER %d\n", $nsmin;
105 printf "#define NASM_PATCHLEVEL_VER %d\n", $nplvl;
106 if (defined($snapshot)) {
107 printf "#define NASM_SNAPSHOT %d\n", $snapshot;
109 printf "#define NASM_VERSION_ID 0x%08x\n", $nasm_id;
110 printf "#define NASM_VER \"%s\"\n", $line;
111 print "#endif /* NASM_VERSION_H */\n";
112 } elsif ( $what eq 'mac' ) {
113 printf "%%define __NASM_MAJOR__ %d\n", $nmaj;
114 printf "%%define __NASM_MINOR__ %d\n", $nmin;
115 printf "%%define __NASM_SUBMINOR__ %d\n", $nsmin;
116 printf "%%define __NASM_PATCHLEVEL__ %d\n", $nplvl;
117 if (defined($snapshot)) {
118 printf "%%define __NASM_SNAPSHOT__ %d\n", $snapshot;
120 printf "%%define __NASM_VERSION_ID__ 0%08Xh\n", $nasm_id;
121 printf "%%define __NASM_VER__ \"%s\"\n", $line;
122 } elsif ( $what eq 'sed' ) {
123 printf "s/\@\@NASM_MAJOR\@\@/%d/g\n", $nmaj;
124 printf "s/\@\@NASM_MINOR\@\@/%d/g\n", $nmin;
125 printf "s/\@\@NASM_SUBMINOR\@\@/%d/g\n", $nsmin;
126 printf "s/\@\@NASM_PATCHLEVEL\@\@/%d/g\n", $nplvl;
127 printf "s/\@\@NASM_SNAPSHOT\@\@/%d/g\n", $snapshot; # Possibly empty
128 printf "s/\@\@NASM_VERSION_ID\@\@/%d/g\n", $nasm_id;
129 printf "s/\@\@NASM_VERSION_XID\@\@/0x%08x/g\n", $nasm_id;
130 printf "s/\@\@NASM_VER\@\@/%s/g\n", $line;
131 printf "s/\@\@NASM_MANGLED_VER\@\@/%s/g\n", $mangled_ver;
132 } elsif ( $what eq 'make' ) {
133 printf "NASM_VER=%s\n", $line;
134 printf "NASM_MAJOR_VER=%d\n", $nmaj;
135 printf "NASM_MINOR_VER=%d\n", $nmin;
136 printf "NASM_SUBMINOR_VER=%d\n", $nsmin;
137 printf "NASM_PATCHLEVEL_VER=%d\n", $nplvl;
138 } elsif ( $what eq 'nsis' ) {
139 printf "!define VERSION \"%s\"\n", $line;
140 printf "!define MAJOR_VER %d\n", $nmin;
141 printf "!define MINOR_VER %d\n", $nmin;
142 printf "!define SUBMINOR_VER %d\n", $nsmin;
143 printf "!define PATCHLEVEL_VER %d\n", $nplvl;
144 } elsif ( $what eq 'id' ) {
145 print $nasm_id, "\n"; # Print ID in decimal
146 } elsif ( $what eq 'xid' ) {
147 printf "0x%08x\n", $nasm_id; # Print ID in hexadecimal
149 die "$0: Unknown output: $what\n";