blob: 6af54256ae9f11dd8d18aeea2e29a51a5c27c01c [file] [log] [blame]
H. Peter Anvine87613b2002-05-04 03:57:52 +00001#!/usr/bin/perl
2#
3# version.pl
4# $Id$
5#
6# Parse the NASM version file and produce appropriate macros
7#
8# The NASM version number is assumed to consist of:
9#
10# <major>.<minor>[.<subminor>]<tail>
11#
12# ... where <tail> is not necessarily numeric.
13#
14# This defines the following macros:
15#
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
21#
22# version.mac:
23# __NASM_MAJOR__
24# __NASM_MINOR__
25# __NASM_SUBMINOR__
26# __NASM_VER__
27#
28
29($what) = @ARGV;
30
31$line = <STDIN>;
32chomp $line;
33
34if ( $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";
46}
47
48if ( $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";
63}
64
65exit 0;
66
67