File: export-symbols.perl

package info (click to toggle)
alsa-driver 1.0.17.dfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 22,092 kB
  • ctags: 56,478
  • sloc: ansic: 367,853; sh: 2,470; makefile: 2,240; python: 1,527; perl: 1,316; awk: 66
file content (71 lines) | stat: -rw-r--r-- 1,618 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/perl
use File::Basename;

die "Usage: $0 file.sym\n" unless (-r $ARGV[0]); 

$KERNEL=`uname -r`;
($KVERSION,$KPATCHLEVEL,$KSUBLEVEL)=split /\./, $KERNEL;

$SRC=$ARGV[0];
$BASE=basename($SRC,".sym");
$BASE1=$BASE;
$BASE1 =~ s/-/_/g;

$DEST= $BASE . ".c";

$XSYM1="unknown";
$XSYM2="unknown";

if ($KVERSION == 2) {
  if ($KPATCHLEVEL == 1) {
    $XSYM1="EXPORT_SYMBOL(";
    $XSYM2=");\n";
  }
  else {
    $XSYM1="X(";
    $XSYM2="),\n";
  }
}

die "$SRC = $DEST: Error (1)\n" if ($SRC eq $DEST);

print "generating $DEST from $SRC... ";
  
open (SRC, "<$SRC") or die "Cannot open >> $SRC <<\n";
@SRCtext=<SRC>;

open (DEST, ">$DEST") or die "Cannot write to >> $DEST <<\n";

print DEST qq(/*\n);
print DEST qq( *  File generated by script export-symbols from file $SRC...\n);
print DEST qq( *  Don\'t edit!!!\n);
print DEST qq( */\n);
print DEST qq(\n);
print DEST qq(\#define EXPORT_SYMTAB\n);
print DEST qq(\#include "driver.h"\n);

foreach $line (@SRCtext) {
  if ( substr($line,0,1) eq "+" ) { 
    print DEST substr($line , 2);
  }
}

print DEST qq(\#ifndef LINUX_2_1\n);
print DEST qq(struct symbol_table snd_symbol_table_$BASE1 = \{\n);
print DEST qq(\#include <linux/symtab_begin.h>\n);
print DEST qq(\#endif\n);

foreach $line (@SRCtext) {
  chomp($line);
  print DEST "  /* ", substr($line,2), "*/\n" 
    if ( substr($line,0,1) eq "\#" );
  print DEST $XSYM1, $line, $XSYM2 
    if ( substr($line,0,1) ne "\#" && substr($line,0,1) ne "+" );
}

print DEST qq(\#ifndef LINUX_2_1\n);
print DEST qq(\#include <linux/symtab_end.h>\n);
print DEST qq(}\;\n);
print DEST qq(\#endif\n);

print "done\n";