Adding debian version 3.70~pre8+dfsg-1.
[syslinux-debian/hramrach.git] / gpxe / src / util / parserom.pl
blob3d41b544056140ec92973f71f941837192b91b32
1 #!/usr/bin/perl -w
3 # Parse PCI_ROM and ISA_ROM entries from a source file on stdin and
4 # output the relevant Makefile variable definitions to stdout
6 # Based upon portions of Ken Yap's genrules.pl
8 use strict;
9 use warnings;
11 die "Syntax: $0 driver_source.c" unless @ARGV == 1;
12 my $source = shift;
13 open DRV, "<$source" or die "Could not open $source: $!\n";
15 ( my $family, my $driver_name ) = ( $source =~ /^(.*?([^\/]+))\..$/ )
16 or die "Could not parse source file name \"$source\"\n";
18 my $printed_family;
20 sub rom {
21 ( my $type, my $image, my $desc, my $vendor, my $device ) = @_;
22 my $ids = $vendor ? "$vendor,$device" : "-";
23 unless ( $printed_family ) {
24 print "\n";
25 print "# NIC\t\n";
26 print "# NIC\tfamily\t$family\n";
27 print "DRIVERS += $driver_name\n";
28 $printed_family = 1;
30 print "\n";
31 print "# NIC\t$image\t$ids\t$desc\n";
32 print "DRIVER_$image = $driver_name\n";
33 print "ROM_TYPE_$image = $type\n";
34 print "ROM_DESCRIPTION_$image = \"$desc\"\n";
35 print "PCI_VENDOR_$image = 0x$vendor\n" if $vendor;
36 print "PCI_DEVICE_$image = 0x$device\n" if $device;
37 print "ROMS += $image\n";
38 print "ROMS_$driver_name += $image\n";
41 while ( <DRV> ) {
42 next unless /(PCI|ISA)_ROM\s*\(/;
44 if ( /^\s*PCI_ROM\s*\(
45 \s*0x([0-9A-Fa-f]{4})\s*, # PCI vendor
46 \s*0x([0-9A-Fa-f]{4})\s*, # PCI device
47 \s*\"([^\"]*)\"\s*, # Image
48 \s*\"([^\"]*)\"\s* # Description
49 \)/x ) {
50 ( my $vendor, my $device, my $image, my $desc ) = ( lc $1, lc $2, $3, $4 );
51 rom ( "pci", $image, $desc, $vendor, $device );
52 rom ( "pci", lc "${vendor}${device}", $desc, $vendor, $device );
53 } elsif ( /^\s*ISA_ROM\s*\(
54 \s*\"([^\"]*)\"\s*, # Image
55 \s*\"([^\"]*)\"\s* # Description
56 \)/x ) {
57 ( my $image, my $desc ) = ( $1, $2 );
58 rom ( "isa", $image, $desc );
59 } else {
60 warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";
64 close DRV;