root/i2c/branches/lk2-4/mkpatch/mkpatch.pl @ 3805

Revision 3805, 24.7 KB (checked in by mds, 10 years ago)

mkpatch fixes:

remove dead drivers/char/mem.c patch code in mkpatch.pl;
add <linux/version.h> in i2c.h so it will work in patched kernel;
put back a dummy i2c_init_all() in i2c-core so we don't
need to remove the call in mem.c.

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1#!/usr/bin/perl
2
3#    mkpatch - Create patches against the Linux kernel
4#    Copyright (c) 1999  Frodo Looijaard <frodol@dds.nl>
5#
6#    This program is free software; you can redistribute it and/or modify
7#    it under the terms of the GNU General Public License as published by
8#    the Free Software Foundation; either version 2 of the License, or
9#    (at your option) any later version.
10#
11#    This program is distributed in the hope that it will be useful,
12#    but WITHOUT ANY WARRANTY; without even the implied warranty of
13#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14#    GNU General Public License for more details.
15#
16#    You should have received a copy of the GNU General Public License
17#    along with this program; if not, write to the Free Software
18#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20use strict;
21
22use vars qw($temp);
23$temp = "mkpatch/.temp";
24
25# Forward declaration
26sub gen_drivers_char_Makefile;
27
28# Generate a diff between the old kernel file and the new I2C file. We
29# arrange the headers to tell us the old tree was under directory
30# `linux-old', and the new tree under `linux'.
31# $_[0]: i2c package root (like /tmp/i2c)
32# $_[1]: Linux kernel tree (like /usr/src/linux)
33# $_[2]: Name of the kernel file
34# $_[3]: Name of the patched file
35sub print_diff
36{
37  my ($package_root,$kernel_root,$kernel_file,$package_file) = @_;
38  my ($diff_command,$dummy);
39
40  $diff_command = "diff -u2";
41  if ( -e "$kernel_root/$kernel_file") {
42    $diff_command .= " $kernel_root/$kernel_file ";
43  } else {
44    $diff_command .= " /dev/null ";
45  }
46  if ( -e "$package_root/$package_file") {
47    $diff_command .= " $package_root/$package_file ";
48  } else {
49    $diff_command .= " /dev/null";
50  }
51  open INPUT, "$diff_command|" or die "Can't call `$diff_command'";
52  $dummy = <INPUT>;
53  $dummy = <INPUT>;
54  print "--- linux-old/$kernel_file\t".`date`;
55  print "+++ linux/$kernel_file\t".`date`;
56   
57  while (<INPUT>) {
58    print;
59  }
60  close INPUT;
61}
62
63# Find all the lm_sensors code in a file
64# $_[0]: Linux kernel tree (like /usr/src/linux)
65# $_[1]: Name of the kernel file
66# Returns a list of strings with the sensors codes
67sub find_sensors_code
68{
69  my ($kernel_root,$kernel_file) = @_;
70  my @res;
71  open INPUT, "$kernel_root/$kernel_file" 
72       or return @res;
73  while (<INPUT>) {
74    if (m@sensors code starts here@) {
75      push @res,"";
76      while (<INPUT>) {
77        last if m@sensors code ends here@;
78        $res[$#res] .= $_;
79      }
80    }
81  }
82  return @res;   
83} 
84
85# Here we generate diffs for all kernel files mentioned in OLDI2C
86# which change the invocation # `#include <linux/i2c.h>' to
87# `#include <linux/i2c-old.h>'. But first, we generate diffs to copy
88# file <linux/i2c.h> to <linux/i2c-old.h>, if the kernel does not have
89# this file yet.
90# $_[0]: sensors package root (like /tmp/sensors)
91# $_[1]: Linux kernel tree (like /usr/src/linux)
92sub patch_old_i2c
93{
94  my ($package_root,$kernel_root) = @_;
95  my (@files,$file,$f);
96  # If i2c.c does not exist, either we renamed it earlier, or there is no
97  # i2c support in this kernel at all.
98  return if not -e "$kernel_root/drivers/char/i2c.c";
99
100  print_diff $kernel_root,$kernel_root,"include/linux/i2c-old.h", 
101             "include/linux/i2c.h";
102
103
104  open INPUT, "$package_root/mkpatch/OLDI2C" 
105        or die "Can't open `$package_root/mkpatch/OLDI2C'";
106  @files = <INPUT>;
107  close INPUT;
108
109  foreach $f (@files,"drivers/char/i2c-old.c") {
110    $file = $f; # Ugly, but seemingly needed to run on Perl 5.6.
111    chomp $file;
112    if ($file eq "drivers/char/i2c-old.c") {
113      open INPUT, "$kernel_root/drivers/char/i2c.c"
114            or next;
115    } else { 
116      open INPUT, "$kernel_root/$file"
117           or next;
118    }
119    open OUTPUT, ">$package_root/$temp"
120           or die "Can't open `$package_root/$temp'";
121    while (<INPUT>) {
122      s@(\s*#\s*include\s*)<linux/i2c.h>@\1<linux/i2c-old.h>@;
123      print OUTPUT;
124    }
125    close INPUT;
126    close OUTPUT;
127    print_diff $package_root,$kernel_root,$file,$temp;
128  }
129  print_diff "/dev",$kernel_root,"drivers/char/i2c.c","null";
130  gen_drivers_char_Makefile $package_root, $kernel_root;
131}
132
133# This generates diffs for kernel file Documentation/Configure.help. This
134# file contains the help texts that can be displayed during `make *config'
135# for the kernel.
136# The new texts are put at the end of the file, or just before the
137# lm_sensors texts.
138# Of course, care is taken old lines are removed.
139# $_[0]: i2c package root (like /tmp/i2c)
140# $_[1]: Linux kernel tree (like /usr/src/linux)
141sub gen_Documentation_Configure_help
142{
143  my ($package_root,$kernel_root) = @_;
144  my $kernel_file = "Documentation/Configure.help";
145  my $package_file = $temp;
146  my $printed = 0;
147
148  open INPUT,"$kernel_root/$kernel_file"
149        or die "Can't open `$kernel_root/$kernel_file'";
150  open OUTPUT,">$package_root/$package_file"
151        or die "Can't open $package_root/$package_file";
152  MAIN: while(<INPUT>) {
153    if (m@^I2C support$@ or m@^I2C bit-banging interfaces@ or
154           m@^Philips style parallel port adapter@ or
155           m@^ELV adapter@ or m@^Velleman K9000 adapter@ or
156           m@^I2C PCF 8584 interfaces@ or m@^Elektor ISA card@ or
157           m@^I2C device interface@ or
158           m@^I2C /proc interface \(required for hardware sensors\)@) {
159      $_ = <INPUT>;
160      $_ = <INPUT>;
161      $_ = <INPUT> while not m@^\S@ and not eof(INPUT);
162      redo MAIN;
163    }
164    if (not $printed and (eof(INPUT) or m@I2C mainboard interfaces@ or
165                          m@A couple of things I keep forgetting@ or
166                          m@Bus Mouse Support@)) {
167      print OUTPUT <<'EOF';
168I2C support
169CONFIG_I2C
170  I2C (pronounce: I-square-C) is a slow serial bus protocol used in
171  many micro controller applications and developed by Philips.  SMBus,
172  or System Management Bus is a subset of the I2C protocol.  More
173  information is contained in the directory <file:Documentation/i2c/>,
174  especially in the file called "summary" there.
175
176  Both I2C and SMBus are supported here. You will need this for
177  hardware sensors support, and also for Video For Linux support.
178  Specifically, if you want to use a BT848 based frame grabber/overlay
179  boards under Linux, say Y here and also to "I2C bit-banging
180  interfaces", below.
181
182  If you want I2C support, you should say Y here and also to the
183  specific driver for your bus adapter(s) below.  If you say Y to
184  "/proc file system" below, you will then get a /proc interface which
185  is documented in <file:Documentation/i2c/proc-interface>.
186
187  This I2C support is also available as a module.  If you want to
188  compile it as a module, say M here and read
189  <file:Documentation/modules.txt>.
190  The module will be called i2c-core.o.
191
192I2C bit-banging interfaces
193CONFIG_I2C_ALGOBIT
194  This allows you to use a range of I2C adapters called bit-banging
195  adapters.  Say Y if you own an I2C adapter belonging to this class
196  and then say Y to the specific driver for you adapter below.
197
198  This support is also available as a module.  If you want to compile
199  it as a module, say M here and read
200  <file:Documentation/modules.txt>.
201  The module will be called i2c-algo-bit.o.
202
203Philips style parallel port adapter
204CONFIG_I2C_PHILIPSPAR
205  This supports parallel-port I2C adapters made by Philips.  Say Y if
206  you own such an adapter.
207
208  This driver is also available as a module.  If you want to compile
209  it as a module, say M here and read
210  <file:Documentation/modules.txt>.
211  The module will be called i2c-philips-par.o.
212
213  Note that if you want support for different parallel port devices,
214  life will be much easier if you compile them all as modules.
215
216ELV adapter
217CONFIG_I2C_ELV
218  This supports parallel-port I2C adapters called ELV.  Say Y if you
219  own such an adapter.
220
221  This driver is also available as a module.  If you want to compile
222  it as a module, say M here and read
223  <file:Documentation/modules.txt>.
224  The module will be called i2c-elv.o.
225
226Velleman K9000 adapter
227CONFIG_I2C_VELLEMAN
228  This supports the Velleman K9000 parallel-port I2C adapter.  Say Y
229  if you own such an adapter.
230
231  This driver is also available as a module.  If you want to compile
232  it as a module, say M here and read
233  <file:Documentation/modules.txt>.
234  The module will be called i2c-velleman.o.
235
236Basic I2C on Parallel Port adapter
237CONFIG_I2C_PPORT
238  This supports directly connecting I2C devices to the parallel port.
239  See <file:Documentation/i2c/i2c-pport> for more information.
240
241  This driver is also available as a module.  If you want to compile
242  it as a module, say M here and read
243  <file:Documentation/modules.txt>.
244  The module will be called i2c-pport.o.
245
246I2C PCF 8584 interfaces
247CONFIG_I2C_ALGOPCF
248  This allows you to use a range of I2C adapters called PCF adapters.
249  Say Y if you own an I2C adapter belonging to this class and then say
250  Y to the specific driver for you adapter below.
251
252  This support is also available as a module.  If you want to compile
253  it as a module, say M here and read
254  <file:Documentation/modules.txt>.
255  The module will be called i2c-algo-pcf.o.
256
257Elektor ISA card
258CONFIG_I2C_ELEKTOR
259  This supports the PCF8584 ISA bus I2C adapter.  Say Y if you own
260  such an adapter.
261
262  This driver is also available as a module.  If you want to compile
263  it as a module, say M here and read
264  <file:Documentation/modules.txt>.
265  The module will be called i2c-elektor.o.
266
267PCF on the EPP Parallel Port
268CONFIG_I2C_PCFEPP
269  This supports the PCF8584 connected to the parallel port.
270
271  This driver is also available as a module.  If you want to compile
272  it as a module, say M here and read
273  <file:Documentation/modules.txt>.
274  The module will be called i2c-pcf-epp.o.
275
276Motorola 8xx I2C algorithm
277CONFIG_I2C_ALGO8XX
278  This is the algorithm that allows you to use Motorola 8xx I2C adapters.
279
280  This driver is also available as a module.  If you want to compile
281  it as a module, say M here and read
282  <file:Documentation/modules.txt>.
283  The module will be called i2c-algo-8xx.o.
284
285Motorola 8xx I2C interface
286CONFIG_I2C_RPXLITE
287  This supports the Motorola 8xx I2C device.
288
289  This driver is also available as a module.  If you want to compile
290  it as a module, say M here and read
291  <file:Documentation/modules.txt>.
292  The module will be called i2c-rpx.o.
293
294IBM 405 I2C algorithm
295CONFIG_I2C_IBM_OCP_ALGO
296  This is the algorithm that allows you to use IBM 405 I2C adapters.
297
298  This driver is also available as a module.  If you want to compile
299  it as a module, say M here and read
300  <file:Documentation/modules.txt>.
301  The module will be called i2c-algo-ibm_ocp.o.
302
303IBM 405 I2C interface
304CONFIG_I2C_IBM_OCP_ADAP
305  This supports the IBM 405 I2C device.
306
307  This driver is also available as a module.  If you want to compile
308  it as a module, say M here and read
309  <file:Documentation/modules.txt>.
310  The module will be called i2c-adap-ibm_ocp.o.
311
312StrongARM SA-1110 interface
313CONFIG_I2C_FRODO
314  This supports the StrongARM SA-1110 Development Board.
315
316  This driver is also available as a module.  If you want to compile
317  it as a module, say M here and read
318  <file:Documentation/modules.txt>.
319  The module will be called i2c-frodo.o.
320
321I2C device interface
322CONFIG_I2C_CHARDEV
323  Say Y here to use i2c-* device files, usually found in the /dev
324  directory on your system.  They make it possible to have user-space
325  programs use the I2C bus.  Information on how to do this is
326  contained in the file <file:Documentation/i2c/dev-interface>.
327
328  This code is also available as a module.  If you want to compile
329  it as a module, say M here and read
330  <file:Documentation/modules.txt>.
331  The module will be called i2c-dev.o.
332
333I2C /proc interface (required for hardware sensors)
334CONFIG_I2C_PROC
335  This provides support for i2c device entries in the /proc filesystem.
336  The entries will be found in /proc/sys/dev/sensors.
337
338  This code is also available as a module. If you want to compile
339  it as a module, say M here and read <file:Documentation/modules.txt>.
340  The module will be called i2c-proc.o.
341
342EOF
343      $printed = 1;
344    }
345    print OUTPUT;
346  }
347  close INPUT;
348  close OUTPUT;
349  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
350}
351
352# This generates diffs for the main Linux Makefile.
353# Three lines which add drivers/i2c/i2.a to the DRIVERS list are put just
354# before the place where the architecture Makefile is included.
355# Of course, care is taken old lines are removed.
356# $_[0]: i2c package root (like /tmp/i2c)
357# $_[1]: Linux kernel tree (like /usr/src/linux)
358sub gen_Makefile
359{
360  my ($package_root,$kernel_root) = @_;
361  my $kernel_file = "Makefile";
362  my $package_file = $temp;
363  my $printed = 0;
364  my $new_style = 0;
365
366  open INPUT,"$kernel_root/$kernel_file"
367        or die "Can't open `$kernel_root/$kernel_file'";
368  open OUTPUT,">$package_root/$package_file"
369        or die "Can't open $package_root/$package_file";
370  MAIN: while(<INPUT>) {
371    if (m@^DRIVERS :=@) {
372       $new_style = 1;
373    }
374    if (m@DRIVERS-\$\(CONFIG_I2C\)@) {
375      $_ = <INPUT>;
376      redo MAIN;
377    } elsif (m@CONFIG_I2C@) {
378      $_ = <INPUT> while not m@endif@;
379      $_ = <INPUT>;
380      $_ = <INPUT> if m@^$@;
381      redo MAIN;
382    }
383    if (not $printed and m@DRIVERS-\$\(CONFIG_PHONE\)@) {
384      if ($new_style) {
385        print OUTPUT << 'EOF';
386DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.a
387EOF
388      } else {
389        print OUTPUT << 'EOF';
390DRIVERS-$(CONFIG_I2C) += drivers/i2c/i2c.o
391EOF
392      }
393      $printed = 1;
394    } elsif (not $printed and 
395        (m@include arch/\$\(ARCH\)/Makefile@ or m@CONFIG_SENSORS@ or
396         m@CONFIG_PHONE@ )) {
397      print OUTPUT <<'EOF';
398ifeq ($(CONFIG_I2C),y)
399DRIVERS := $(DRIVERS) drivers/i2c/i2c.a
400endif
401
402EOF
403      $printed = 1;
404    }
405    print OUTPUT;
406  }
407  close INPUT;
408  close OUTPUT;
409  die "Automatic patch generation for main `Makefile' failed.\n".
410      "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0;
411  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
412}
413
414# This generates diffs for drivers/Makefile
415# First, `i2c' is added to the ALL_SUB_DIRS list. Next, a couple of lines
416# to add i2c to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before
417# Rules.make is included.
418# Of course, care is taken old lines are removed.
419# $_[0]: i2c package root (like /tmp/i2c)
420# $_[1]: Linux kernel tree (like /usr/src/linux)
421sub gen_drivers_Makefile
422{
423  my ($package_root,$kernel_root) = @_;
424  my $kernel_file = "drivers/Makefile";
425  my $package_file = $temp;
426  my $i2c_present;
427  my $printed = 0;
428  my $added = 0;
429  my $new_style = 0;
430
431  open INPUT,"$kernel_root/$kernel_file"
432        or die "Can't open `$kernel_root/$kernel_file'";
433  open OUTPUT,">$package_root/$package_file"
434        or die "Can't open $package_root/$package_file";
435  MAIN: while(<INPUT>) {
436    if (m@^mod-subdirs\s*:=@) {
437       $new_style = 1;
438    }
439    if ((! $new_style and m@^ALL_SUB_DIRS\s*:=@) or m@^mod-subdirs\s*:=@ ) {
440      $added = 1;
441      $i2c_present = 0;
442      while (m@\\$@) {
443        $i2c_present = 1 if m@i2c@;
444        print OUTPUT;
445        $_ = <INPUT>;
446      }
447      $i2c_present = 1 if m@i2c@;
448      s@$@ i2c@ if (not $i2c_present);
449      print OUTPUT;
450      $_ = <INPUT>;
451      redo MAIN;
452    } 
453    if (m@^ifeq.*CONFIG_I2C@) {
454      $_ = <INPUT> while not m@^endif@;
455      $_ = <INPUT>;
456      $_ = <INPUT> if m@^$@;
457      redo MAIN;
458    } 
459    if (m@^subdir.*CONFIG_I2C@) {
460      $_ = <INPUT>;
461      redo MAIN;
462    }
463# 2.5 kernels
464#   if (m@^obj.*CONFIG_I2C@) {
465#   }
466    if (not $printed and
467        (m@^include \$\(TOPDIR\)/Rules.make$@ or
468         m@^ifeq \(\$\(CONFIG_ACPI\),y\)$@ or
469         m@^ifeq \(\$\(CONFIG_SENSORS\),y\)@) or
470         m@^subdir-\$\(CONFIG_ACPI\)@) {
471      if ($new_style) {
472        print OUTPUT <<'EOF';
473subdir-$(CONFIG_I2C)            += i2c
474EOF
475      } else {
476        print OUTPUT <<'EOF';
477ifeq ($(CONFIG_I2C),y)
478SUB_DIRS += i2c
479MOD_SUB_DIRS += i2c
480else
481  ifeq ($(CONFIG_I2C),m)
482  MOD_SUB_DIRS += i2c
483  endif
484endif
485
486EOF
487      }
488      $printed = 1;
489    }
490    print OUTPUT;
491  }
492  close INPUT;
493  close OUTPUT;
494  die "Automatic patch generation for `drivers/Makefile' failed.\n".
495      "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0 or $added == 0;
496  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
497}
498
499# This generates diffs for drivers/char/Makefile
500# It changes all occurences of `i2c.o' to `i2c-old.o'.
501# $_[0]: i2c package root (like /tmp/i2c)
502# $_[1]: Linux kernel tree (like /usr/src/linux)
503sub gen_drivers_char_Makefile
504{
505  my ($package_root,$kernel_root) = @_;
506  my $kernel_file = "drivers/char/Makefile";
507  my $package_file = $temp;
508  open INPUT,"$kernel_root/$kernel_file"
509        or die "Can't open `$kernel_root/$kernel_file'";
510  open OUTPUT,">$package_root/$package_file"
511        or die "Can't open $package_root/$package_file";
512  while(<INPUT>) {
513    s@i2c\.o@i2c-old\.o@;
514    print OUTPUT;
515  }
516  close INPUT;
517  close OUTPUT;
518  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
519}
520
521# This generates diffs for drivers/i2c/Makefile
522# for either 'old style' or 'new style'.
523# Don't bother putting in 'old style' support for new architectures
524# like 8xx, IBM405, or StrongARM since they aren't supported
525# in old kernels anyway.
526sub gen_drivers_i2c_Makefile
527{
528  my ($package_root,$kernel_root) = @_;
529  my $kernel_file = "drivers/i2c/Makefile";
530  my $package_file = $temp;
531  my $use_new_format = 0;
532  if (-e "$kernel_root/$kernel_file") {
533    `grep -q -s 'i2c\.o' "$kernel_root/$kernel_file"`;
534     $use_new_format = ! $?;
535  }
536
537  open OUTPUT,">$package_root/$package_file"
538        or die "Can't open $package_root/$package_file";
539  if ($use_new_format) {
540    print OUTPUT <<'EOF';
541#
542# Makefile for the kernel i2c bus driver.
543#
544
545O_TARGET := i2c.o
546
547export-objs     := i2c-core.o i2c-algo-bit.o i2c-algo-pcf.o \
548                   i2c-algo-8xx.o i2c-proc.o i2c-algo-ibm_ocp.o
549
550obj-$(CONFIG_I2C)               += i2c-core.o
551obj-$(CONFIG_I2C_CHARDEV)       += i2c-dev.o
552obj-$(CONFIG_I2C_ALGOBIT)       += i2c-algo-bit.o
553obj-$(CONFIG_I2C_PHILIPSPAR)    += i2c-philips-par.o
554obj-$(CONFIG_I2C_ELV)           += i2c-elv.o
555obj-$(CONFIG_I2C_VELLEMAN)      += i2c-velleman.o
556obj-$(CONFIG_I2C_PPORT)         += i2c-pport.o
557obj-$(CONFIG_I2C_ALGOPCF)       += i2c-algo-pcf.o
558obj-$(CONFIG_I2C_ELEKTOR)       += i2c-elektor.o
559obj-$(CONFIG_I2C_PCFEPP)        += i2c-pcf-epp.o
560obj-$(CONFIG_I2C_PROC)          += i2c-proc.o
561obj-$(CONFIG_I2C_ALGO8XX)       += i2c-algo-8xx.o
562obj-$(CONFIG_I2C_RPXLITE)       += i2c-rpx.o
563obj-$(CONFIG_I2C_IBM_OCP_ALGO)  += i2c-algo-ibm_ocp.o
564obj-$(CONFIG_I2C_IBM_OCP_ADAP)  += i2c-adap-ibm_ocp.o
565obj-$(CONFIG_I2C_FRODO)         += i2c-frodo.o
566
567# This is needed for automatic patch generation: sensors code starts here
568# This is needed for automatic patch generation: sensors code ends here
569
570include $(TOPDIR)/Rules.make
571
572EOF
573  } else {
574    print OUTPUT <<'EOF';
575#
576# Makefile for the kernel i2c bus driver.
577#
578
579SUB_DIRS     :=
580MOD_SUB_DIRS := $(SUB_DIRS)
581ALL_SUB_DIRS := $(SUB_DIRS)
582MOD_LIST_NAME := I2C_MODULES
583
584L_TARGET := i2c.a
585MX_OBJS := 
586M_OBJS  :=
587LX_OBJS :=
588L_OBJS  :=
589
590# -----
591# i2c core components
592# -----
593
594ifeq ($(CONFIG_I2C),y)
595  LX_OBJS += i2c-core.o
596else
597  ifeq ($(CONFIG_I2C),m)
598    MX_OBJS += i2c-core.o
599  endif
600endif
601
602ifeq ($(CONFIG_I2C_CHARDEV),y)
603  L_OBJS += i2c-dev.o
604else
605  ifeq ($(CONFIG_I2C_CHARDEV),m)
606    M_OBJS += i2c-dev.o
607  endif
608endif
609
610ifeq ($(CONFIG_I2C_PROC),y)
611  LX_OBJS += i2c-proc.o
612else
613  ifeq ($(CONFIG_I2C_PROC),m)
614    MX_OBJS += i2c-proc.o
615  endif
616endif
617
618# -----
619# Bit banging adapters...
620# -----
621
622ifeq ($(CONFIG_I2C_ALGOBIT),y)
623  LX_OBJS += i2c-algo-bit.o
624else
625  ifeq ($(CONFIG_I2C_ALGOBIT),m)
626    MX_OBJS += i2c-algo-bit.o
627  endif
628endif
629
630ifeq ($(CONFIG_I2C_PHILIPSPAR),y)
631  L_OBJS += i2c-philips-par.o
632else
633  ifeq ($(CONFIG_I2C_PHILIPSPAR),m)
634    M_OBJS += i2c-philips-par.o
635  endif
636endif
637
638ifeq ($(CONFIG_I2C_ELV),y)
639  L_OBJS += i2c-elv.o
640else
641  ifeq ($(CONFIG_I2C_ELV),m)
642    M_OBJS += i2c-elv.o
643  endif
644endif
645
646ifeq ($(CONFIG_I2C_VELLEMAN),y)
647  L_OBJS += i2c-velleman.o
648else
649  ifeq ($(CONFIG_I2C_VELLEMAN),m)
650    M_OBJS += i2c-velleman.o
651  endif
652endif
653
654
655
656# -----
657# PCF components
658# -----
659
660ifeq ($(CONFIG_I2C_ALGOPCF),y)
661  LX_OBJS += i2c-algo-pcf.o
662else
663  ifeq ($(CONFIG_I2C_ALGOPCF),m)
664    MX_OBJS += i2c-algo-pcf.o
665  endif
666endif
667
668ifeq ($(CONFIG_I2C_ELEKTOR),y)
669  L_OBJS += i2c-elektor.o
670else
671  ifeq ($(CONFIG_I2C_ELEKTOR),m)
672    M_OBJS += i2c-elektor.o
673  endif
674endif
675
676# This is needed for automatic patch generation: sensors code starts here
677# This is needed for automatic patch generation: sensors code ends here
678
679include $(TOPDIR)/Rules.make
680
681EOF
682  }
683  close OUTPUT;
684  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
685}
686
687# This generates diffs for drivers/char/Config.in
688# It adds a line just before CONFIG_APM or main_menu_option lines to include
689# the I2C Config.in.
690# Of course, care is taken old lines are removed.
691# $_[0]: i2c package root (like /tmp/i2c)
692# $_[1]: Linux kernel tree (like /usr/src/linux)
693sub gen_drivers_char_Config_in
694{
695  my ($package_root,$kernel_root) = @_;
696  my $kernel_file = "drivers/char/Config.in";
697  my $package_file = $temp;
698  my $ready = 0;
699  my $printed = 0;
700
701  open INPUT,"$kernel_root/$kernel_file"
702        or die "Can't open `$kernel_root/$kernel_file'";
703  open OUTPUT,">$package_root/$package_file"
704        or die "Can't open $package_root/$package_file";
705  MAIN: while(<INPUT>) {
706    if (m@i2c@) {
707      $_ = <INPUT>;
708      $_ = <INPUT> if (m@^$@);
709      redo MAIN;
710    }
711    if ($ready and not $printed and 
712        (m@^mainmenu_option@ or m@CONFIG_APM@ or m@CONFIG_ALPHA_BOOK1@ or
713         m@source drivers/sensors/Config.in@)) {
714      $printed = 1;
715      print OUTPUT <<'EOF';
716source drivers/i2c/Config.in
717
718EOF
719    }
720    $ready = 1 if (m@^mainmenu_option@);
721    print OUTPUT;
722  }
723  close INPUT;
724  close OUTPUT;
725  die "Automatic patch generation for `drivers/char/Config.in' failed.\n".
726      "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0;
727  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
728}
729 
730# Generate the diffs for the list of MAINTAINERS
731# $_[0]: i2c package root (like /tmp/i2c)
732# $_[1]: Linux kernel tree (like /usr/src/linux)
733sub gen_MAINTAINERS
734{
735  my ($package_root,$kernel_root) = @_;
736  my $kernel_file = "MAINTAINERS";
737  my $package_file = $temp;
738  my $done = 0;
739
740  open INPUT,"$kernel_root/$kernel_file"
741        or die "Can't open `$kernel_root/$kernel_file'";
742  open OUTPUT,">$package_root/$package_file"
743        or die "Can't open $package_root/$package_file";
744  MAIN: while(<INPUT>) {
745    if (m@I2C DRIVERS@) {
746       $_=<INPUT> while not m@^$@;
747       $_=<INPUT>;
748       redo MAIN;
749    }
750    if (not $done and (m@i386 BOOT CODE@ or m@IBM MCA SCSI SUBSYSTEM DRIVER@)) {
751      print OUTPUT <<'EOF';
752I2C DRIVERS
753P:      Simon Vogl
754M:      simon@tk.uni-linz.ac.at
755P:      Frodo Looijaard
756M:      frodol@dds.nl
757L:      linux-i2c@pelican.tk.uni-linz.ac.at
758W:      http://www.tk.uni-linz.ac.at/~simon/private/i2c
759S:      Maintained
760
761EOF
762      $done = 1;
763    }
764    print OUTPUT;
765  }
766  close INPUT;
767  close OUTPUT;
768  die "Automatic patch generation for `MAINTAINERS' failed.\n".
769      "See our home page http://www.lm-sensors.nu for assistance!" if $done == 0;
770  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
771}
772
773# Main function
774sub main
775{
776  my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file);
777  my ($diff_command,$dummy,$data0,$data1,$sedscript,@sensors_subs);
778
779  # --> Read the command-line
780  $package_root = $ARGV[0];
781  die "Package root `$package_root' is not found\n" 
782        unless -d "$package_root/mkpatch";
783  $kernel_root = $ARGV[1];
784  die "Kernel root `$kernel_root' is not found\n" 
785        unless -f "$kernel_root/Rules.make";
786
787  patch_old_i2c $package_root, $kernel_root;
788         
789
790  # --> Read FILES
791  open INPUT, "$package_root/mkpatch/FILES" 
792        or die "Can't open `$package_root/mkpatch/FILES'";
793  while (<INPUT>) {
794    ($data0,$data1) = /(\S+)\s+(\S+)/;
795    $files{$data0} = $data1;
796  } 
797  close INPUT;
798
799  # --> Read INCLUDES
800  open INPUT, "$package_root/mkpatch/INCLUDES" 
801        or die "Can't open `$package_root/mkpatch/INCLUDES'";
802  while (<INPUT>) {
803    ($data0,$data1) = /(\S+)\s+(\S+)/;
804    $includes{$data0} = $data1;
805    $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; ';
806  } 
807  close INPUT;
808
809  # --> Start generating
810  foreach $package_file (sort keys %files) {
811    $kernel_file = $files{$package_file};
812    @sensors_subs = find_sensors_code "$kernel_root","$kernel_file";
813    open INPUT, "$package_root/$package_file"
814         or die "Can't open `$package_root/$package_file'";
815    open OUTPUT, ">$package_root/$temp"
816         or die "Can't open `$package_root/$temp'";
817    while (<INPUT>) {
818      eval $sedscript;
819      if (m@sensors code starts here@) {
820        print OUTPUT;
821        while (<INPUT>) {
822           last if m@sensors code ends here@;
823        }
824        print OUTPUT $sensors_subs[0];
825        shift @sensors_subs
826      }
827      print OUTPUT;
828    }
829    close INPUT;
830    close OUTPUT;
831    print_diff "$package_root","$kernel_root","$kernel_file","$temp";
832  }
833
834#  gen_Makefile $package_root, $kernel_root;
835#  gen_drivers_Makefile $package_root, $kernel_root;
836#  gen_drivers_i2c_Makefile $package_root, $kernel_root;
837#  gen_drivers_char_Config_in $package_root, $kernel_root;
838   gen_Documentation_Configure_help $package_root, $kernel_root;
839#  gen_MAINTAINERS $package_root, $kernel_root;
840}
841
842main;
843
Note: See TracBrowser for help on using the browser.