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
11 die "Syntax: $0 driver_source.c" unless @ARGV == 1;
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";
21 ( my $type, my $image, my $desc, my $vendor, my $device ) = @_;
22 my $ids = $vendor ?
"$vendor,$device" : "-";
23 unless ( $printed_family ) {
26 print "# NIC\tfamily\t$family\n";
27 print "DRIVERS += $driver_name\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";
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
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
57 ( my $image, my $desc ) = ( $1, $2 );
58 rom
( "isa", $image, $desc );
60 warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";