summaryrefslogtreecommitdiff
path: root/v4l/scripts/gentree.pl
diff options
context:
space:
mode:
Diffstat (limited to 'v4l/scripts/gentree.pl')
-rwxr-xr-xv4l/scripts/gentree.pl40
1 files changed, 34 insertions, 6 deletions
diff --git a/v4l/scripts/gentree.pl b/v4l/scripts/gentree.pl
index bd1ee94e2..1b4e44f26 100755
--- a/v4l/scripts/gentree.pl
+++ b/v4l/scripts/gentree.pl
@@ -87,7 +87,7 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ m|^\s*\#if\s+0\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
+ if ($line =~ m|^\s*\#\s*if\s+0\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
if ($1 eq ";") {
print OUT "#if 0\n";
} else {
@@ -132,7 +132,7 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ m|^\s*\#if\s+1\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
+ if ($line =~ m|^\s*\#\s*if\s+1\s*\/[\*]\s*[Kk][Ee].[Pp]\s*[\*]\/(.*)|) {
print OUT "#if 1$1\n";
$state{$level} = "ifother";
$if{$level} = 1;
@@ -180,7 +180,7 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^\s*#\s*ifndef.\s*I2C_PEC/) {
+ if ($line =~ /^\s*#\s*ifndef\s+I2C_PEC/) {
chomp($line);
$state{$level} = "if";
$if{$level} = 0;
@@ -188,7 +188,7 @@ sub filter_source ($$) {
$level++;
next;
}
- if ($line =~ /^\s*#\s*ifdef.\s*I2C_PEC/) {
+ if ($line =~ /^\s*#\s*ifdef\s+I2C_PEC/) {
chomp($line);
$state{$level} = "if";
$if{$level} = 1;
@@ -219,8 +219,36 @@ sub filter_source ($$) {
if ($line =~ /^\s*#\s*if.*LINUX_VERSION_CODE/) {
chomp($line);
$line =~ s@^#if\s*@@;
- $line =~ s@LINUX_VERSION_CODE@\$CODE@;
-print STDERR "/* BP orig: ($line) */\n" if $DEBUG;
+ $line =~ s@LINUX_VERSION_CODE@\$CODE@g;
+ print STDERR "/* BP orig: ($line) */\n" if $DEBUG;
+
+ $line =~ s@KERNEL_VERSION\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)@
+ sprintf("%d",$1*65536 + $2*256 + $3) @eg;
+ $if{$level} = eval $line;
+ $state{$level} = "if";
+ print STDERR "/* BP #if LINUX_VERSION_CODE state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+ $level++;
+ next;
+ }
+ if ($line =~ /^\s*#\s*elif.*LINUX_VERSION_CODE/) {
+ chomp($line);
+ if ( !$level ) {
+ die "elif without if";
+ }
+ $level--;
+ if ( $if{$level} ) {
+ # Else is 0
+ $if{$level} = 0;
+ $state{$level} = "elif";
+ print STDERR "/* BP #if LINUX_VERSION_CODE state=$state{$level} if=$if{$level} level=$level ($line) */\n" if $DEBUG;
+
+ $level++;
+ next;
+ }
+
+ $line =~ s@^#if\s*@@;
+ $line =~ s@LINUX_VERSION_CODE@\$CODE@g;
+ print STDERR "/* BP orig: ($line) */\n" if $DEBUG;
$line =~ s@KERNEL_VERSION\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*\)@
sprintf("%d",$1*65536 + $2*256 + $3) @eg;