root/lm-sensors/trunk/mkpatch/mkpatch.pl @ 1424

Revision 1424, 44.7 KB (checked in by mds, 11 years ago)

add i2c-savage4, lm92, pcf8574, pcf8591, smsc47m1, vt1211

  • 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# Generate a diff between the old kernel file and the new lm_sensors file. We
26# arrange the headers to tell us the old tree was under directory
27# `linux-old', and the new tree under `linux'.
28# $_[0]: sensors package root (like /tmp/sensors)
29# $_[1]: Linux kernel tree (like /usr/src/linux)
30# $_[2]: Name of the kernel file
31# $_[3]: Name of the patched file
32sub print_diff
33{
34  my ($package_root,$kernel_root,$kernel_file,$package_file) = @_;
35  my ($diff_command,$dummy);
36
37  $diff_command = "diff -u2";
38  if ( -e "$kernel_root/$kernel_file") {
39    $diff_command .= " $kernel_root/$kernel_file ";
40  } else {
41    $diff_command .= " /dev/null ";
42  }
43  if ( -e "$package_root/$package_file") {
44    $diff_command .= " $package_root/$package_file ";
45  } else {
46    $diff_command .= " /dev/null";
47  }
48  open INPUT, "$diff_command|" or die "Can't execute `$diff_command'";
49  $dummy = <INPUT>;
50  $dummy = <INPUT>;
51  print "--- linux-old/$kernel_file\t".`date`;
52  print "+++ linux/$kernel_file\t".`date`;
53   
54  while (<INPUT>) {
55    print;
56  }
57  close INPUT;
58}
59
60# This generates diffs for kernel file Documentation/Configure.help. This
61# file contains the help texts that can be displayed during `make *config'
62# for the kernel.
63# The new texts are put at the end of the file, or just before the
64# lm_sensors texts.
65# Of course, care is taken old lines are removed.
66# $_[0]: i2c package root (like /tmp/i2c)
67# $_[1]: Linux kernel tree (like /usr/src/linux)
68sub gen_Documentation_Configure_help
69{
70  my ($package_root,$kernel_root) = @_;
71  my $kernel_file = "Documentation/Configure.help";
72  my $package_file = $temp;
73
74  open INPUT,"$kernel_root/$kernel_file"
75        or die "Can't open `$kernel_root/$kernel_file'";
76  open OUTPUT,">$package_root/$package_file"
77        or die "Can't open $package_root/$package_file";
78  MAIN: while(<INPUT>) {
79    if (m@I2C mainboard interfaces@ or
80           m@Acer Labs ALI 1535@ or
81           m@Acer Labs ALI 1533 and 1543C@ or
82           m@AMD 756/766@ or
83           m@Apple Hydra Mac I/O@ or
84           m@Intel I801@ or
85           m@Intel I810/I815 based Mainboard@ or
86           m@Intel 82371AB PIIX4\(E\)@ or
87           m@Silicon Integrated Systems Corp. SiS5595 based Mainboard@ or
88           m@VIA Technologies, Inc. VT82C586B@ or
89           m@VIA Technologies, Inc. VT82C596, 596B, 686A/B, 8233@ or
90           m@3DFX Banshee / Voodoo3@ or
91           m@DEC Tsunami 21272@ or
92           m@Pseudo ISA adapter \(for hardware sensors modules\)@ or
93           m@Analog Devices ADM1021 and compatibles@ or
94           m@Analog Devices ADM1024@ or
95           m@Analog Devices ADM1025@ or
96           m@Analog Devices ADM9240 and compatibles@ or
97           m@Dallas DS1621 and DS1625@ or
98           m@Fujitsu-Siemens Poseidon@ or
99           m@Fujitsu-Siemens Scylla@ or
100           m@Genesys Logic GL518SM@ or
101           m@Genesys Logic GL520SM@ or
102           m@HP Maxilife@ or
103           m@ITE 8705, 8712, Sis950@ or
104           m@Myson MTP008@ or
105           m@National Semiconductors LM75 and compatibles@ or
106           m@National Semiconductors LM78@ or
107           m@National Semiconductors LM80@ or
108           m@National Semiconductors LM87@ or
109           m@Silicon Integrated Systems Corp. SiS5595 Sensor@ or
110           m@Texas Instruments THMC50 / Analog Devices ADM1022@ or
111           m@Via VT82C686A/B@ or
112           m@Winbond W83781D, W83782D, W83783S, W83627HF, AS99127F@ or
113           m@EEprom \(DIMM\) reader@) {
114      $_ = <INPUT>;
115      $_ = <INPUT>;
116      $_ = <INPUT> while not m@^\S@ and not eof(INPUT);
117      redo MAIN;
118    }
119    if (eof(INPUT)) {
120      print OUTPUT <<'EOF'
121I2C mainboard interfaces
122CONFIG_I2C_MAINBOARD
123  Many modern mainboards have some kind of I2C interface integrated. This
124  is often in the form of a SMBus, or System Management Bus, which is
125  basically the same as I2C but which uses only a subset of the I2C
126  protocol.
127
128  You will also want the latest user-space utilties: you can find them
129  in the lm_sensors package, which you can download at
130  http://www.lm-sensors.nu
131
132Acer Labs ALI 1535
133CONFIG_I2C_ALI1535
134  If you say yes to this option, support will be included for the Acer
135  Labs ALI 1535 mainboard I2C interface. This can also be
136  built as a module.
137
138Acer Labs ALI 1533 and 1543C
139CONFIG_I2C_ALI15X3
140  If you say yes to this option, support will be included for the Acer
141  Labs ALI 1533 and 1543C mainboard I2C interfaces. This can also be
142  built as a module which can be inserted and removed while the kernel
143  is running.
144
145AMD 756/766/768
146CONFIG_I2C_AMD756
147  If you say yes to this option, support will be included for the AMD
148  756/766/768 mainboard I2C interfaces. This can also be
149  built as a module which can be inserted and removed while the kernel
150  is running.
151
152Apple Hydra Mac I/O
153CONFIG_I2C_HYDRA
154  If you say yes to this option, support will be included for the
155  Hydra mainboard I2C interface. This can also be built as a module
156  which can be inserted and removed while the kernel is running.
157
158Intel I801
159CONFIG_I2C_I801
160  If you say yes to this option, support will be included for the
161  Intel I801 mainboard I2C interfaces. "I810" mainboard sensor chips are
162  generally located on the I801's I2C bus. This can also be
163  built as a module which can be inserted and removed while the kernel
164  is running.
165
166Intel I810/I815 based Mainboard
167CONFIG_I2C_I810
168  If you say yes to this option, support will be included for the
169  Intel I810/I815 mainboard I2C interfaces. The I2C busses these chips
170  are generally used only for video devices. For "810" mainboard sensor
171  chips, use the I801 I2C driver instead. This can also be
172  built as a module which can be inserted and removed while the kernel
173  is running.
174
175Intel 82371AB PIIX4(E) / ServerWorks OSB4 and CSB5
176CONFIG_I2C_PIIX4
177  If you say yes to this option, support will be included for the
178  Intel PIIX4, PIIX4E, and 443MX, Serverworks OSB4/CSB5,
179  and SMSC Victory66 mainboard
180  I2C interfaces. This can also be
181  built as a module which can be inserted and removed while the kernel
182  is running.
183
184Silicon Integrated Systems Corp. SiS5595 based Mainboard
185CONFIG_I2C_SIS5595
186  If you say yes to this option, support will be included for the
187  SiS5595 mainboard I2C interfaces. For integrated sensors on the
188  Sis5595, use CONFIG_SENSORS_SIS5595. This can also be
189  built as a module which can be inserted and removed while the kernel
190  is running.
191
192VIA Technologies, Inc. VT82C586B
193CONFIG_I2C_VIA
194  If you say yes to this option, support will be included for the VIA
195  Technologies I2C adapter found on some motherboards. This can also
196  be built as a module which can be inserted and removed while the
197  kernel is running.
198
199VIA Technologies, Inc. VT82C596, 596B, 686A/B, 8233
200CONFIG_I2C_VIAPRO
201  If you say yes to this option, support will be included for the VIA
202  Technologies I2C adapter on these chips. For integrated sensors on the
203  Via 686A/B, use CONFIG_SENSORS_VIA686A. This can also be
204  be built as a module which can be inserted and removed while the
205  kernel is running.
206
2073DFX Banshee / Voodoo3
208CONFIG_I2C_VOODOO3
209  If you say yes to this option, support will be included for the
210  3DFX Banshee and Voodoo3 I2C interfaces. The I2C busses on the these
211  chips are generally used only for video devices.
212  This can also be
213  built as a module which can be inserted and removed while the kernel
214  is running.
215
216DEC Tsunami 21272
217CONFIG_I2C_TSUNAMI
218  If you say yes to this option, support will be included for the DEC
219  Tsunami chipset I2C adapter. Requires the Alpha architecture;
220  do not enable otherwise. This can also be built as a module which
221  can be inserted and removed while the kernel is running.
222
223Pseudo ISA adapter (for hardware sensors modules)
224CONFIG_I2C_ISA
225  This provides support for accessing some hardware sensor chips over
226  the ISA bus rather than the I2C or SMBus. If you want to do this,
227  say yes here. This feature can also be built as a module which can
228  be inserted and removed while the kernel is running.
229
230  You will also need the latest user-space utilties: you can find them
231  in the lm_sensors package, which you can download at
232  http://www.lm-sensors.nu
233
234Analog Devices ADM1021 and compatibles
235CONFIG_SENSORS_ADM1021
236  If you say yes here you get support for Analog Devices ADM1021
237  and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
238  Genesys Logic GL523SM, National Semi LM84, TI THMC10,
239  and the XEON processor built-in sensor. This can also
240  be built as a module which can be inserted and removed while the
241  kernel is running.
242
243  You will also need the latest user-space utilties: you can find them
244  in the lm_sensors package, which you can download at
245  http://www.lm-sensors.nu
246
247Analog Devices ADM1024
248CONFIG_SENSORS_ADM1024
249  If you say yes here you get support for Analog Devices ADM1024 sensor
250  chips.  This can also be built as a module.
251
252  You will also need the latest user-space utilties: you can find them
253  in the lm_sensors package, which you can download at
254  http://www.lm-sensors.nu
255
256Analog Devices ADM1025
257CONFIG_SENSORS_ADM1025
258  If you say yes here you get support for Analog Devices ADM1025 sensor
259  chips.  This can also be built as a module which can be inserted and
260  removed while the kernel is running.
261
262  You will also need the latest user-space utilties: you can find them
263  in the lm_sensors package, which you can download at
264  http://www.lm-sensors.nu
265
266Analog Devices ADM9240 and compatibles
267CONFIG_SENSORS_ADM9240
268  If you say yes here you get support for Analog Devices ADM9240
269  sensor chips and clones: the Dallas Semiconductor DS1780 and
270  the National Semiconductor LM81. This can also be built as a
271  module which can be inserted and removed while the kernel is
272  running.
273
274  You will also need the latest user-space utilties: you can find them
275  in the lm_sensors package, which you can download at
276  http://www.lm-sensors.nu
277
278Dallas DS1621 and DS1625
279CONFIG_SENSORS_DS1621
280  If you say yes here you get support for the Dallas DS1621 and DS1625x
281  sensor chips.  This can also be built as a module.
282
283  You will also need the latest user-space utilties: you can find them
284  in the lm_sensors package, which you can download at
285  http://www.lm-sensors.nu
286
287Fujitsu-Siemens Poseidon
288CONFIG_SENSORS_FSCPOS
289  If you say yes here you get support for the Fujitsu-Siemens Poseidon
290  sensor chip.  This can also be built as a module.
291
292  You will also need the latest user-space utilties: you can find them
293  in the lm_sensors package, which you can download at
294  http://www.lm-sensors.nu
295
296Fujitsu-Siemens Scylla
297CONFIG_SENSORS_FSCSCY
298  If you say yes here you get support for the Fujitsu-Siemens Scylla
299  sensor chip.  This can also be built as a module. This driver may/should
300  also work with the following Fujitsu-Siemens chips: "Poseidon",
301  "Poseidon II" and "Hydra". You may have to force loading of the module
302  for motherboards in these cases. Be careful - those motherboards have
303  not been tested with this driver.
304
305  You will also need the latest user-space utilties: you can find them
306  in the lm_sensors package, which you can download at
307  http://www.lm-sensors.nu
308
309Genesys Logic GL518SM
310CONFIG_SENSORS_GL518SM
311  If you say yes here you get support for Genesys Logic GL518SM sensor
312  chips.  This can also be built as a module which can be inserted and
313  removed while the kernel is running.
314
315  You will also need the latest user-space utilties: you can find them
316  in the lm_sensors package, which you can download at
317  http://www.lm-sensors.nu
318
319Genesys Logic GL520SM
320CONFIG_SENSORS_GL520SM
321  If you say yes here you get support for Genesys Logic GL518SM sensor
322  chips.  This can also be built as a module which can be inserted and
323  removed while the kernel is running.
324
325  You will also need the latest user-space utilties: you can find them
326  in the lm_sensors package, which you can download at
327  http://www.lm-sensors.nu
328
329HP Maxilife
330CONFIG_SENSORS_MAXILIFE
331  If you say yes here you get support for the HP Maxilife
332  sensor chip.  This can also be built as a module.
333
334  You will also need the latest user-space utilties: you can find them
335  in the lm_sensors package, which you can download at
336  http://www.lm-sensors.nu
337
338ITE 8705, 8712, Sis950
339CONFIG_SENSORS_IT87
340  If you say yes here you get support for the ITE 8705 and 8712 and
341  SiS950 sensor chips.  This can also be built as a module.
342
343  You will also need the latest user-space utilties: you can find them
344  in the lm_sensors package, which you can download at
345  http://www.lm-sensors.nu
346
347Myson MTP008
348CONFIG_SENSORS_MTP008
349  If you say yes here you get support for the Myson MTP008
350  sensor chip.  This can also be built as a module.
351
352  You will also need the latest user-space utilties: you can find them
353  in the lm_sensors package, which you can download at
354  http://www.lm-sensors.nu
355
356National Semiconductor LM75 and compatibles
357CONFIG_SENSORS_LM75
358  If you say yes here you get support for National Semiconductor LM75
359  sensor chips and clones: Dallas Semi DS75 and DS1775, TelCon
360  TCN75, and National Semi LM77. This can also be built as a module which
361  can be inserted and removed while the kernel is running.
362
363  You will also need the latest user-space utilties: you can find them
364  in the lm_sensors package, which you can download at
365  http://www.lm-sensors.nu
366
367National Semiconductor LM78
368CONFIG_SENSORS_LM78
369  If you say yes here you get support for National Semiconductor LM78
370  sensor chips family: the LM78-J and LM79. Many clone chips will
371  also work at least somewhat with this driver. This can also be built
372  as a module which can be inserted and removed while the kernel is
373  running.
374
375  You will also need the latest user-space utilties: you can find them
376  in the lm_sensors package, which you can download at
377  http://www.lm-sensors.nu
378
379National Semiconductor LM80
380CONFIG_SENSORS_LM80
381  If you say yes here you get support for National Semiconductor LM80
382  sensor chips. This can also be built as a module which can be
383  inserted and removed while the kernel is running.
384
385  You will also need the latest user-space utilties: you can find them
386  in the lm_sensors package, which you can download at
387  http://www.lm-sensors.nu
388
389National Semiconductor LM87
390CONFIG_SENSORS_LM87
391  If you say yes here you get support for National Semiconductor LM87
392  sensor chips. This can also be built as a module which can be
393  inserted and removed while the kernel is running.
394
395  You will also need the latest user-space utilties: you can find them
396  in the lm_sensors package, which you can download at
397  http://www.lm-sensors.nu
398
399National Semiconductor LM92
400CONFIG_SENSORS_LM92
401  If you say yes here you get support for National Semiconductor LM92
402  sensor chips. This can also be built as a module which can be
403  inserted and removed while the kernel is running.
404
405  You will also need the latest user-space utilties: you can find them
406  in the lm_sensors package, which you can download at
407  http://www.lm-sensors.nu
408
409Philips PCF8574
410CONFIG_SENSORS_PCF8574
411  If you say yes here you get support for the Philips PCF8574
412  I2C 8-bit Parallel I/O device.
413  This can also be built as a module which can be
414  inserted and removed while the kernel is running.
415
416  You will also need the latest user-space utilties: you can find them
417  in the lm_sensors package, which you can download at
418  http://www.lm-sensors.nu
419
420Philips PCF8591
421CONFIG_SENSORS_PCF8591
422  If you say yes here you get support for the Philips PCF8591
423  I2C Quad D/A + Single A/D I/O device.
424  This can also be built as a module which can be
425  inserted and removed while the kernel is running.
426
427  You will also need the latest user-space utilties: you can find them
428  in the lm_sensors package, which you can download at
429  http://www.lm-sensors.nu
430
431Silicon Integrated Systems Corp. SiS5595 Sensor
432CONFIG_SENSORS_SIS5595
433  If you say yes here you get support for the integrated sensors in
434  SiS5595 South Bridges. This can also be built as a module
435  which can be inserted and removed while the kernel is running.
436
437  You will also need the latest user-space utilties: you can find them
438  in the lm_sensors package, which you can download at
439  http://www.lm-sensors.nu
440
441SMSC47M1xx Super I/O Fan Support
442CONFIG_SENSORS_SMSC47M1
443  If you say yes here you get support for the integrated fan
444  monitoring and control in the SMSC 47M1xx Super I/O chips.
445  This can also be built as a module
446  which can be inserted and removed while the kernel is running.
447
448  You will also need the latest user-space utilties: you can find them
449  in the lm_sensors package, which you can download at
450  http://www.lm-sensors.nu
451
452Texas Instruments THMC50 / Analog Devices ADM1022
453CONFIG_SENSORS_THMC50
454  If you say yes here you get support for Texas Instruments THMC50
455  sensor chips and clones: the Analog Devices ADM1022.
456  This can also be built as a module which
457  can be inserted and removed while the kernel is running.
458
459  You will also need the latest user-space utilties: you can find them
460  in the lm_sensors package, which you can download at
461  http://www.lm-sensors.nu
462
463Via VT82C686A/B
464CONFIG_SENSORS_VIA686A
465  If you say yes here you get support for the integrated sensors in
466  Via 686A/B South Bridges. This can also be built as a module
467  which can be inserted and removed while the kernel is running.
468
469  You will also need the latest user-space utilties: you can find them
470  in the lm_sensors package, which you can download at
471  http://www.lm-sensors.nu
472
473Via VT1211 Sensors
474CONFIG_SENSORS_VT1211
475  If you say yes here you get support for the integrated sensors in
476  the Via VT1211 Super I/O device. This can also be built as a module
477  which can be inserted and removed while the kernel is running.
478
479  You will also need the latest user-space utilties: you can find them
480  in the lm_sensors package, which you can download at
481  http://www.lm-sensors.nu
482
483Winbond W83781D, W83782D, W83783S, W83627HF, AS99127F
484CONFIG_SENSORS_W83781D
485  If you say yes here you get support for the Winbond W8378x series
486  of sensor chips: the W83781D, W83782D, W83783S and W83682HF,
487  and the similar Asus AS99127F. This
488  can also be built as a module which can be inserted and removed
489  while the kernel is running.
490
491  You will also need the latest user-space utilties: you can find them
492  in the lm_sensors package, which you can download at
493  http://www.lm-sensors.nu
494
495EEprom (DIMM) reader
496CONFIG_SENSORS_EEPROM
497  If you say yes here you get read-only access to the EEPROM data
498  available on modern memory DIMMs, and which could theoretically
499  also be available on other devices. This can also be built as a
500  module which can be inserted and removed while the kernel is
501  running.
502
503  You will also need the latest user-space utilties: you can find them
504  in the lm_sensors package, which you can download at
505  http://www.lm-sensors.nu
506
507EOF
508    }
509    print OUTPUT;
510  }
511  close INPUT;
512  close OUTPUT;
513  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
514}
515
516
517# This generates diffs for the main Linux Makefile.
518# Three lines which add drivers/sensors/sensors.a to the DRIVERS list are
519# put just before the place where the architecture Makefile is included.
520# Of course, care is taken old lines are removed.
521# $_[0]: sensors package root (like /tmp/sensors)
522# $_[1]: Linux kernel tree (like /usr/src/linux)
523sub gen_Makefile
524{
525  my ($package_root,$kernel_root) = @_;
526  my $kernel_file = "Makefile";
527  my $package_file = $temp;
528  my $type = 0;
529  my $pr1 = 0;
530
531  open INPUT,"$kernel_root/$kernel_file"
532        or die "Can't open `$kernel_root/$kernel_file'";
533  open OUTPUT,">$package_root/$package_file"
534        or die "Can't open $package_root/$package_file";
535  `grep -q -s 'i2c\.o' "$kernel_root/$kernel_file"`;
536  $type = 2 if ! $?;
537  MAIN: while(<INPUT>) {
538    $type = 1 if !$type and (m@^DRIVERS-\$@);
539    if (m@DRIVERS-\$\(CONFIG_SENSORS\)@) {
540      $_ = <INPUT>;
541      redo MAIN;
542    } elsif (m@CONFIG_SENSORS@) {
543      $_ = <INPUT> while not m@endif@;
544      $_ = <INPUT>;
545      $_ = <INPUT> if m@^$@;
546      redo MAIN;
547    }
548    if ($type == 1 and m@^DRIVERS \+= \$\(DRIVERS-y\)@) {
549      print OUTPUT <<'EOF';
550DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensors.a
551EOF
552      $pr1 = 1;
553    }
554    if ($type == 2 and m@^DRIVERS .*= \$\(DRIVERS-y\)@) {
555      print OUTPUT <<'EOF';
556DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensor.o
557EOF
558      $pr1 = 1;
559    }
560    if ($type == 0 and m@include arch/\$\(ARCH\)/Makefile@) {
561      print OUTPUT <<'EOF';
562ifeq ($(CONFIG_SENSORS),y)
563DRIVERS := $(DRIVERS) drivers/sensors/sensors.a
564endif
565
566EOF
567      $pr1 = 1;
568    }
569    print OUTPUT;
570  }
571  close INPUT;
572  close OUTPUT;
573  die "Automatic patch generation for `Makefile' failed.\n".
574      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 == 0;
575  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
576}
577
578# This generates diffs for drivers/Makefile
579# First, `sensors' is added to the ALL_SUB_DIRS list. Next, a couple of lines
580# to add sensors to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before
581# Rules.make is included.
582# Of course, care is taken old lines are removed.
583# $_[0]: sensors package root (like /tmp/sensors)
584# $_[1]: Linux kernel tree (like /usr/src/linux)
585sub gen_drivers_Makefile
586{
587  my ($package_root,$kernel_root) = @_;
588  my $kernel_file = "drivers/Makefile";
589  my $package_file = $temp;
590  my $sensors_present;
591  my $pr1 = 0;
592  my $pr2 = 0;
593  my $new_style = 0;
594
595  open INPUT,"$kernel_root/$kernel_file"
596        or die "Can't open `$kernel_root/$kernel_file'";
597  open OUTPUT,">$package_root/$package_file"
598        or die "Can't open $package_root/$package_file";
599  MAIN: while(<INPUT>) {
600    if (m@^mod-subdirs\s*:=@) {
601      $new_style = 1;
602    }
603    if ((! $new_style and m@^ALL_SUB_DIRS\s*:=@) or m@^mod-subdirs\s*:=@) {
604      $pr1 = 1;
605      $sensors_present = 0;
606      while (m@\\$@) {
607        $sensors_present = 1 if m@sensors@;
608        print OUTPUT;
609        $_ = <INPUT>;
610      }
611      $sensors_present = 1 if m@sensors@;
612      s@$@ sensors@ if (not $sensors_present);
613      print OUTPUT;
614      $_ = <INPUT>;
615      redo MAIN;
616    } 
617    if (m@^ifeq.*CONFIG_SENSORS@) {
618      $_ = <INPUT> while not m@^endif@;
619      $_ = <INPUT>;
620      $_ = <INPUT> if m@^$@;
621      redo MAIN;
622    } 
623    if (m@^subdir.*CONFIG_SENSORS@) {
624      $_ = <INPUT>;
625      redo MAIN;
626    }
627    if (!$pr2 and (m@^include \$\(TOPDIR\)/Rules.make$@ or m@^subdir-\$\(CONFIG_ACPI@)) {
628      $pr2 = 1;
629      if ($new_style) {
630      print OUTPUT <<'EOF';
631subdir-$(CONFIG_SENSORS)        += sensors
632EOF
633      } else {
634      print OUTPUT <<'EOF';
635ifeq ($(CONFIG_SENSORS),y)
636SUB_DIRS += sensors
637MOD_SUB_DIRS += sensors
638else
639  ifeq ($(CONFIG_SENSORS),m)
640  MOD_SUB_DIRS += sensors
641  endif
642endif
643
644EOF
645      }
646    }
647    print OUTPUT;
648  }
649  close INPUT;
650  close OUTPUT;
651  die "Automatic patch generation for `drivers/Makefile' failed.\n".
652      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 == 0 or $pr2 == 0;
653  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
654}
655
656# This generates diffs for drivers/char/Config.in
657# It adds a line just before CONFIG_APM or main_menu_option lines to include
658# the sensors Config.in.
659# Of course, care is taken old lines are removed.
660# $_[0]: sensors package root (like /tmp/sensors)
661# $_[1]: Linux kernel tree (like /usr/src/linux)
662sub gen_drivers_char_Config_in
663{
664  my ($package_root,$kernel_root) = @_;
665  my $kernel_file = "drivers/char/Config.in";
666  my $package_file = $temp;
667  my $pr1 = 0;
668
669  open INPUT,"$kernel_root/$kernel_file"
670        or die "Can't open `$kernel_root/$kernel_file'";
671  open OUTPUT,">$package_root/$package_file"
672        or die "Can't open $package_root/$package_file";
673  MAIN: while(<INPUT>) {
674    if (m@source drivers/i2c/Config.in@) {
675      $pr1 = 1;
676      print OUTPUT;
677      print OUTPUT "\nsource drivers/sensors/Config.in\n";
678      $_ = <INPUT>;
679      redo MAIN;
680    }
681    if (m@sensors@) {
682      $_ = <INPUT>;
683      $_ = <INPUT> if m@^$@;
684      redo MAIN;
685    }
686    print OUTPUT;
687  }
688  close INPUT;
689  close OUTPUT;
690  die "Automatic patch generation for `drivers/Makefile' failed.\n".
691      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 == 0;
692  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
693}
694 
695
696# This generates diffs for drivers/char/mem.c They are a bit intricate.
697# Lines are generated at the beginning to declare sensors_init_all
698# At the bottom, a call to sensors_init_all is added when the
699# new lm_sensors stuff is configured in.
700# Of course, care is taken old lines are removed.
701# $_[0]: sensors package root (like /tmp/sensors)
702# $_[1]: Linux kernel tree (like /usr/src/linux)
703sub gen_drivers_char_mem_c
704{
705  my ($package_root,$kernel_root) = @_;
706  my $kernel_file = "drivers/char/mem.c";
707  my $package_file = $temp;
708  my $right_place = 0;
709  my $done = 0;
710  my $atstart = 1;
711  my $pr1 = 0;
712  my $pr2 = 0;
713
714  open INPUT,"$kernel_root/$kernel_file"
715        or die "Can't open `$kernel_root/$kernel_file'";
716  open OUTPUT,">$package_root/$package_file"
717        or die "Can't open $package_root/$package_file";
718  MAIN: while(<INPUT>) {
719    if ($atstart and m@#ifdef@) {
720      $pr1 = 1;
721      print OUTPUT << 'EOF';
722#ifdef CONFIG_SENSORS
723extern void sensors_init_all(void);
724#endif
725EOF
726      $atstart = 0;
727    }
728    if (not $right_place and m@CONFIG_SENSORS@) {
729      $_ = <INPUT> while not m@#endif@;
730      $_ = <INPUT>;
731      redo MAIN;
732    }
733    $right_place = 1 if (m@lp_m68k_init\(\);@);
734    if ($right_place and not $done and
735        m@CONFIG_SENSORS@) {
736      $_ = <INPUT> while not m@#endif@;
737      $_ = <INPUT>;
738      $_ = <INPUT> if m@^$@;
739      redo MAIN;
740    }
741    if ($right_place and not $done and m@return 0;@) {
742      $pr2 = 1;
743      print OUTPUT <<'EOF';
744#ifdef CONFIG_SENSORS
745        sensors_init_all();
746#endif
747
748EOF
749      $done = 1;
750    }
751    print OUTPUT;
752  }
753  close INPUT;
754  close OUTPUT;
755  die "Automatic patch generation for `drivers/char/mem.c' failed.\n".
756      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 == 0 or $pr2 == 0;
757  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
758}
759
760
761# This generates diffs for drivers/i2c/Config.in
762# Several adapter drivers that are included in the lm_sensors package are
763# added at the first and onlu sensors marker.
764# Of course, care is taken old lines are removed.
765# $_[0]: sensors package root (like /tmp/sensors)
766# $_[1]: Linux kernel tree (like /usr/src/linux)
767sub gen_drivers_i2c_Config_in
768{
769  my ($package_root,$kernel_root) = @_;
770  my $kernel_file = "drivers/i2c/Config.in";
771  my $package_file = "$temp";
772  my $pr1 = 0;
773
774  open INPUT,"$kernel_root/$kernel_file"
775        or die "Can't open `$kernel_root/$kernel_file'";
776  open OUTPUT,">$package_root/$package_file"
777        or die "Can't open $package_root/$package_file";
778  while(<INPUT>) {
779    if (m@sensors code starts here@) {
780      $pr1++;
781      print OUTPUT;
782      while (<INPUT>) {
783        last if m@sensors code ends here@;
784      }
785      print OUTPUT << 'EOF';
786  bool 'I2C mainboard interfaces' CONFIG_I2C_MAINBOARD
787  if [ "$CONFIG_I2C_MAINBOARD" = "y" ]; then
788    tristate '  Acer Labs ALI 1535' CONFIG_I2C_ALI1535
789    tristate '  Acer Labs ALI 1533 and 1543C' CONFIG_I2C_ALI15X3
790    dep_tristate '  Apple Hydra Mac I/O' CONFIG_I2C_HYDRA $CONFIG_I2C_ALGOBIT
791    tristate '  AMD 756/766/768' CONFIG_I2C_AMD756
792    dep_tristate '  DEC Tsunami I2C interface' CONFIG_I2C_TSUNAMI $CONFIG_I2C_ALGOBIT
793    tristate '  Intel 82801AA, AB, BA, DB' CONFIG_I2C_I801
794    dep_tristate '  Intel i810AA/AB/E and i815' CONFIG_I2C_I810 $CONFIG_I2C_ALGOBIT
795    tristate '  Intel 82371AB PIIX4(E), 443MX, ServerWorks OSB4/CSB5, SMSC Victory66' CONFIG_I2C_PIIX4
796    tristate '  SiS 5595' CONFIG_I2C_SIS5595
797    dep_tristate '  Savage 4' CONFIG_I2C_SAVAGE4 $CONFIG_I2C_ALGOBIT
798    dep_tristate '  VIA Technologies, Inc. VT82C586B' CONFIG_I2C_VIA $CONFIG_I2C_ALGOBIT
799    tristate '  VIA Technologies, Inc. VT596A/B, 686A/B, 8231, 8233, 8233A' CONFIG_I2C_VIAPRO
800    dep_tristate '  Voodoo3 I2C interface' CONFIG_I2C_VOODOO3 $CONFIG_I2C_ALGOBIT
801    tristate '  Pseudo ISA adapter (for some hardware sensors)' CONFIG_I2C_ISA
802  fi
803
804EOF
805    }
806    print OUTPUT;
807  }
808  close INPUT;
809  close OUTPUT;
810  die "Automatic patch generation for `drivers/i2c/Config.in' failed.\n".
811      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 != 1;
812  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
813}
814
815sub gen_drivers_sensors_Makefile
816{
817  my ($package_root,$kernel_root) = @_;
818  my $kernel_file = "drivers/sensors/Makefile";
819  my $package_file = $temp;
820  my $use_new_format;
821  `grep -q -s 'i2c\.o' "$kernel_root/drivers/i2c/Makefile"`;
822  $use_new_format = ! $?;
823
824  open OUTPUT,">$package_root/$package_file"
825        or die "Can't open $package_root/$package_file";
826  if ($use_new_format) {
827    print OUTPUT <<'EOF';
828#
829# Makefile for the kernel hardware sensors drivers.
830#
831
832MOD_LIST_NAME := SENSORS_MODULES
833O_TARGET := sensor.o
834
835export-objs     := sensors.o
836
837obj-$(CONFIG_SENSORS)           += sensors.o
838obj-$(CONFIG_SENSORS_ADM1021)   += adm1021.o
839obj-$(CONFIG_SENSORS_ADM1024)   += adm1024.o
840obj-$(CONFIG_SENSORS_ADM1025)   += adm1025.o
841obj-$(CONFIG_SENSORS_ADM9240)   += adm9240.o
842obj-$(CONFIG_SENSORS_BT869)     += bt869.o
843obj-$(CONFIG_SENSORS_DDCMON)    += ddcmon.o
844obj-$(CONFIG_SENSORS_DS1621)    += ds1621.o
845obj-$(CONFIG_SENSORS_EEPROM)    += eeprom.o
846obj-$(CONFIG_SENSORS_FSCPOS)    += fscpos.o
847obj-$(CONFIG_SENSORS_FSCSCY)    += fscscy.o
848obj-$(CONFIG_SENSORS_GL518SM)   += gl518sm.o
849obj-$(CONFIG_SENSORS_GL520SM)   += gl520sm.o
850obj-$(CONFIG_SENSORS_IT87)      += it87.o
851obj-$(CONFIG_SENSORS_LM75)      += lm75.o
852obj-$(CONFIG_SENSORS_LM78)      += lm78.o
853obj-$(CONFIG_SENSORS_LM80)      += lm80.o
854obj-$(CONFIG_SENSORS_LM87)      += lm87.o
855obj-$(CONFIG_SENSORS_LM92)      += lm92.o
856obj-$(CONFIG_SENSORS_MAXILIFE)  += maxilife.o
857obj-$(CONFIG_SENSORS_MTP008)    += mtp008.o
858obj-$(CONFIG_SENSORS_PCF8574)   += pcf8574.o
859obj-$(CONFIG_SENSORS_PCF8591)   += pcf8591.o
860obj-$(CONFIG_SENSORS_SIS5595)   += sis5595.o
861obj-$(CONFIG_SENSORS_SMSC47M1)  += smsc47m1.o
862obj-$(CONFIG_SENSORS_THMC50)    += thmc50.o
863obj-$(CONFIG_SENSORS_VIA686A)   += via686a.o
864obj-$(CONFIG_SENSORS_VT1211)    += vt1211.o
865obj-$(CONFIG_SENSORS_W83781D)   += w83781d.o
866
867include $(TOPDIR)/Rules.make
868
869EOF
870  } else {
871    print OUTPUT <<'EOF';
872#
873# Makefile for the kernel hardware sensors drivers.
874#
875
876SUB_DIRS     :=
877MOD_SUB_DIRS := $(SUB_DIRS)
878ALL_SUB_DIRS := $(SUB_DIRS)
879MOD_LIST_NAME := SENSORS_MODULES
880
881L_TARGET := sensors.a
882MX_OBJS := 
883M_OBJS  :=
884LX_OBJS :=
885L_OBJS  :=
886
887# -----
888# i2c core components
889# -----
890
891ifeq ($(CONFIG_SENSORS),y)
892  LX_OBJS += sensors.o
893else
894  ifeq ($(CONFIG_SENSORS),m)
895    MX_OBJS += sensors.o
896  endif
897endif
898
899ifeq ($(CONFIG_SENSORS_ADM1021),y)
900  L_OBJS += adm1021.o
901else
902  ifeq ($(CONFIG_SENSORS_ADM1021),m)
903    M_OBJS += adm1021.o
904  endif
905endif
906
907ifeq ($(CONFIG_SENSORS_ADM1024),y)
908  L_OBJS += adm1024.o
909else
910  ifeq ($(CONFIG_SENSORS_ADM1024),m)
911    M_OBJS += adm1024.o
912  endif
913endif
914
915ifeq ($(CONFIG_SENSORS_ADM1025),y)
916  L_OBJS += adm1025.o
917else
918  ifeq ($(CONFIG_SENSORS_ADM1025),m)
919    M_OBJS += adm1025.o
920  endif
921endif
922
923ifeq ($(CONFIG_SENSORS_ADM9240),y)
924  L_OBJS += adm9240.o
925else
926  ifeq ($(CONFIG_SENSORS_ADM9240),m)
927    M_OBJS += adm9240.o
928  endif
929endif
930
931ifeq ($(CONFIG_SENSORS_DDCMON),y)
932  L_OBJS += ddcmon.o
933else
934  ifeq ($(CONFIG_SENSORS_DDCMON),m)
935    M_OBJS += ddcmon.o
936  endif
937endif
938
939ifeq ($(CONFIG_SENSORS_DS1621),y)
940  L_OBJS += ds1621.o
941else
942  ifeq ($(CONFIG_SENSORS_DS1621),m)
943    M_OBJS += ds1621.o
944  endif
945endif
946
947ifeq ($(CONFIG_SENSORS_EEPROM),y)
948  L_OBJS += eeprom.o
949else
950  ifeq ($(CONFIG_SENSORS_EEPROM),m)
951    M_OBJS += eeprom.o
952  endif
953endif
954
955ifeq ($(CONFIG_SENSORS_FSCPOS),y)
956  L_OBJS += fscpos.o
957else
958  ifeq ($(CONFIG_SENSORS_FSCPOS),m)
959    M_OBJS += fscpos.o
960  endif
961endif
962
963ifeq ($(CONFIG_SENSORS_FSCSCY),y)
964  L_OBJS += fscscy.o
965else
966  ifeq ($(CONFIG_SENSORS_FSCSCY),m)
967    M_OBJS += fscscy.o
968  endif
969endif
970
971ifeq ($(CONFIG_SENSORS_GL518SM),y)
972  L_OBJS += gl518sm.o
973else
974  ifeq ($(CONFIG_SENSORS_GL518SM),m)
975    M_OBJS += gl518sm.o
976  endif
977endif
978
979ifeq ($(CONFIG_SENSORS_GL520SM),y)
980  L_OBJS += gl520sm.o
981else
982  ifeq ($(CONFIG_SENSORS_GL520SM),m)
983    M_OBJS += gl520sm.o
984  endif
985endif
986
987ifeq ($(CONFIG_SENSORS_IT87),y)
988  L_OBJS += it87.o
989else
990  ifeq ($(CONFIG_SENSORS_IT87),m)
991    M_OBJS += it87.o
992  endif
993endif
994
995ifeq ($(CONFIG_SENSORS_LM75),y)
996  L_OBJS += lm75.o
997else
998  ifeq ($(CONFIG_SENSORS_LM75),m)
999    M_OBJS += lm75.o
1000  endif
1001endif
1002
1003ifeq ($(CONFIG_SENSORS_LM78),y)
1004  L_OBJS += lm78.o
1005else
1006  ifeq ($(CONFIG_SENSORS_LM78),m)
1007    M_OBJS += lm78.o
1008  endif
1009endif
1010
1011ifeq ($(CONFIG_SENSORS_LM80),y)
1012  L_OBJS += lm80.o
1013else
1014  ifeq ($(CONFIG_SENSORS_LM80),m)
1015    M_OBJS += lm80.o
1016  endif
1017endif
1018
1019ifeq ($(CONFIG_SENSORS_LM87),y)
1020  L_OBJS += lm87.o
1021else
1022  ifeq ($(CONFIG_SENSORS_LM87),m)
1023    M_OBJS += lm87.o
1024  endif
1025endif
1026
1027ifeq ($(CONFIG_SENSORS_LM92),y)
1028  L_OBJS += lm92.o
1029else
1030  ifeq ($(CONFIG_SENSORS_LM92),m)
1031    M_OBJS += lm92.o
1032  endif
1033endif
1034
1035ifeq ($(CONFIG_SENSORS_MATORB),y)
1036  L_OBJS += matorb.o
1037else
1038  ifeq ($(CONFIG_SENSORS_MATORB),m)
1039    M_OBJS += matorb.o
1040  endif
1041endif
1042
1043ifeq ($(CONFIG_SENSORS_MAXILIFE),y)
1044  L_OBJS += maxilife.o
1045else
1046  ifeq ($(CONFIG_SENSORS_MAXILIFE),m)
1047    M_OBJS += maxilife.o
1048  endif
1049endif
1050
1051ifeq ($(CONFIG_SENSORS_MTP008),y)
1052  L_OBJS += mtp008.o
1053else
1054  ifeq ($(CONFIG_SENSORS_MTP008),m)
1055    M_OBJS += mtp008.o
1056  endif
1057endif
1058
1059ifeq ($(CONFIG_SENSORS_PCF8574),y)
1060  L_OBJS += pcf8574.o
1061else
1062  ifeq ($(CONFIG_SENSORS_PCF8574),m)
1063    M_OBJS += pcf8574.o
1064  endif
1065endif
1066
1067ifeq ($(CONFIG_SENSORS_PCF8591),y)
1068  L_OBJS += pcf8591.o
1069else
1070  ifeq ($(CONFIG_SENSORS_PCF8591),m)
1071    M_OBJS += pcf8591.o
1072  endif
1073endif
1074
1075ifeq ($(CONFIG_SENSORS_SIS5595),y)
1076  L_OBJS += sis5595.o
1077else
1078  ifeq ($(CONFIG_SENSORS_SIS5595),m)
1079    M_OBJS += sis5595.o
1080  endif
1081endif
1082
1083ifeq ($(CONFIG_SENSORS_SMSC47M1),y)
1084  L_OBJS += smsc47m1.o
1085else
1086  ifeq ($(CONFIG_SENSORS_SMSC47M1),m)
1087    M_OBJS += smsc47m1.o
1088  endif
1089endif
1090
1091ifeq ($(CONFIG_SENSORS_THMC50),y)
1092  L_OBJS += thmc50.o
1093else
1094  ifeq ($(CONFIG_SENSORS_THMC50),m)
1095    M_OBJS += thmc50.o
1096  endif
1097endif
1098
1099ifeq ($(CONFIG_SENSORS_VIA686A),y)
1100  L_OBJS += via686a.o
1101else
1102  ifeq ($(CONFIG_SENSORS_VIA686A),m)
1103    M_OBJS += via686a.o
1104  endif
1105endif
1106
1107ifeq ($(CONFIG_SENSORS_VT1211),y)
1108  L_OBJS += vt1211.o
1109else
1110  ifeq ($(CONFIG_SENSORS_VT1211),m)
1111    M_OBJS += vt1211.o
1112  endif
1113endif
1114
1115ifeq ($(CONFIG_SENSORS_W83781D),y)
1116  L_OBJS += w83781d.o
1117else
1118  ifeq ($(CONFIG_SENSORS_W83781D),m)
1119    M_OBJS += w83781d.o
1120  endif
1121endif
1122
1123include $(TOPDIR)/Rules.make
1124EOF
1125  } 
1126  close OUTPUT;
1127  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
1128}
1129
1130# This generates diffs for drivers/i2c/Makefile.
1131# Lines to add correct files to M_OBJS and/or L_OBJS are added just before
1132# Rules.make is included
1133# Of course, care is taken old lines are removed.
1134# $_[0]: sensors package root (like /tmp/sensors)
1135# $_[1]: Linux kernel tree (like /usr/src/linux)
1136sub gen_drivers_i2c_Makefile
1137{
1138  my ($package_root,$kernel_root) = @_;
1139  my $kernel_file = "drivers/i2c/Makefile";
1140  my $package_file = $temp;
1141  my $pr1 = 0;
1142  my $new_format = 0;
1143
1144  open INPUT,"$kernel_root/$kernel_file"
1145        or die "Can't open `$kernel_root/$kernel_file'";
1146  open OUTPUT,">$package_root/$package_file"
1147        or die "Can't open $package_root/$package_file";
1148  while(<INPUT>) {
1149    $new_format = 1 if m@i2c\.o@;
1150    if (m@sensors code starts here@) {
1151      $pr1 ++;
1152      print OUTPUT;
1153      while (<INPUT>) {
1154        last if m@sensors code ends here@;
1155      }
1156      if ($new_format) {
1157        print OUTPUT << 'EOF';
1158obj-$(CONFIG_I2C_ALI1535)               += i2c-ali1535.o
1159obj-$(CONFIG_I2C_ALI15X3)               += i2c-ali15x3.o
1160obj-$(CONFIG_I2C_AMD756)                += i2c-amd756.o
1161obj-$(CONFIG_I2C_HYDRA)                 += i2c-hydra.o
1162obj-$(CONFIG_I2C_I801)                  += i2c-i801.o
1163obj-$(CONFIG_I2C_I810)                  += i2c-i810.o
1164obj-$(CONFIG_I2C_ISA)                   += i2c-isa.o
1165obj-$(CONFIG_I2C_PIIX4)                 += i2c-piix4.o
1166obj-$(CONFIG_I2C_SIS5595)               += i2c-sis5595.o
1167obj-$(CONFIG_I2C_SAVAGE4)               += i2c-savage4.o
1168obj-$(CONFIG_I2C_TSUNAMI)               += i2c-tsunami.o
1169obj-$(CONFIG_I2C_VIA)                   += i2c-via.o
1170obj-$(CONFIG_I2C_VIAPRO)                += i2c-viapro.o
1171obj-$(CONFIG_I2C_VOODOO3)               += i2c-voodoo3.o
1172EOF
1173      } else {
1174        print OUTPUT << 'EOF';
1175ifeq ($(CONFIG_I2C_ALI1535),y)
1176  L_OBJS += i2c-ali1535.o
1177else 
1178  ifeq ($(CONFIG_I2C_ALI1535),m)
1179    M_OBJS += i2c-ali1535.o
1180  endif
1181endif
1182
1183ifeq ($(CONFIG_I2C_ALI15X3),y)
1184  L_OBJS += i2c-ali15x3.o
1185else 
1186  ifeq ($(CONFIG_I2C_ALI15X3),m)
1187    M_OBJS += i2c-ali15x3.o
1188  endif
1189endif
1190
1191ifeq ($(CONFIG_I2C_AMD756),y)
1192  L_OBJS += i2c-amd756.o
1193else 
1194  ifeq ($(CONFIG_I2C_AMD756),m)
1195    M_OBJS += i2c-amd756.o
1196  endif
1197endif
1198
1199ifeq ($(CONFIG_I2C_HYDRA),y)
1200  L_OBJS += i2c-hydra.o
1201else 
1202  ifeq ($(CONFIG_I2C_HYDRA),m)
1203    M_OBJS += i2c-hydra.o
1204  endif
1205endif
1206
1207ifeq ($(CONFIG_I2C_I801),y)
1208  L_OBJS += i2c-i801.o
1209else 
1210  ifeq ($(CONFIG_I2C_I801),m)
1211    M_OBJS += i2c-i801.o
1212  endif
1213endif
1214
1215ifeq ($(CONFIG_I2C_I810),y)
1216  L_OBJS += i2c-i810.o
1217else 
1218  ifeq ($(CONFIG_I2C_I810),m)
1219    M_OBJS += i2c-i810.o
1220  endif
1221endif
1222
1223ifeq ($(CONFIG_I2C_ISA),y)
1224  L_OBJS += i2c-isa.o
1225else 
1226  ifeq ($(CONFIG_I2C_ISA),m)
1227    M_OBJS += i2c-isa.o
1228  endif
1229endif
1230
1231ifeq ($(CONFIG_I2C_PIIX4),y)
1232  L_OBJS += i2c-piix4.o
1233else 
1234  ifeq ($(CONFIG_I2C_PIIX4),m)
1235    M_OBJS += i2c-piix4.o
1236  endif
1237endif
1238
1239ifeq ($(CONFIG_I2C_SIS5595),y)
1240  L_OBJS += i2c-sis5595.o
1241else 
1242  ifeq ($(CONFIG_I2C_SIS5595),m)
1243    M_OBJS += i2c-sis5595.o
1244  endif
1245endif
1246
1247ifeq ($(CONFIG_I2C_SAVAGE4),y)
1248  L_OBJS += i2c-savage4.o
1249else 
1250  ifeq ($(CONFIG_I2C_SAVAGE4),m)
1251    M_OBJS += i2c-savage4.o
1252  endif
1253endif
1254
1255ifeq ($(CONFIG_I2C_TSUNAMI),y)
1256  L_OBJS += i2c-tsunami.o
1257else 
1258  ifeq ($(CONFIG_I2C_TSUNAMI),m)
1259    M_OBJS += i2c-tsunami.o
1260  endif
1261endif
1262
1263ifeq ($(CONFIG_I2C_VIA),y)
1264  L_OBJS += i2c-via.o
1265else 
1266  ifeq ($(CONFIG_I2C_VIA),m)
1267    M_OBJS += i2c-via.o
1268  endif
1269endif
1270
1271ifeq ($(CONFIG_I2C_VIAPRO),y)
1272  L_OBJS += i2c-viapro.o
1273else 
1274  ifeq ($(CONFIG_I2C_VIAPRO),m)
1275    M_OBJS += i2c-viapro.o
1276  endif
1277endif
1278
1279ifeq ($(CONFIG_I2C_VOODOO3),y)
1280  L_OBJS += i2c-voodoo3.o
1281else 
1282  ifeq ($(CONFIG_I2C_VOODOO3),m)
1283    M_OBJS += i2c-voodoo3.o
1284  endif
1285endif
1286
1287EOF
1288      }
1289    }
1290    print OUTPUT;
1291  }
1292  close INPUT;
1293  close OUTPUT;
1294  die "Automatic patch generation for `drivers/i2c/Makefile' failed.\n".
1295      "See our home page http://www.lm-sensors.nu for assistance!" if $pr1 != 1;
1296  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
1297}
1298
1299# This generates diffs for drivers/i2c/i2c-core.c
1300# Lines are generated at the beginning to declare several *_init functions.
1301# At the bottom, calls to them are added when the sensors stuff is configured
1302# in.
1303# $_[0]: sensors package root (like /tmp/sensors)
1304# $_[1]: Linux kernel tree (like /usr/src/linux)
1305sub gen_drivers_i2c_i2c_core_c
1306{
1307  my ($package_root,$kernel_root) = @_;
1308  my $kernel_file = "drivers/i2c/i2c-core.c";
1309  my $package_file = $temp;
1310  my $patch_nr = 1;
1311
1312  open INPUT,"$kernel_root/$kernel_file"
1313        or die "Can't open `$kernel_root/$kernel_file'";
1314  open OUTPUT,">$package_root/$package_file"
1315        or die "Can't open $package_root/$package_file";
1316  while(<INPUT>) {
1317    if (m@sensors code starts here@) {
1318      print OUTPUT;
1319      while (<INPUT>) {
1320        last if m@sensors code ends here@;
1321      }
1322      if ($patch_nr == 1) {
1323        print OUTPUT << 'EOF';
1324#ifdef CONFIG_I2C_ALI1535
1325        extern int i2c_ali1535_init(void);
1326#endif
1327#ifdef CONFIG_I2C_ALI15X3
1328        extern int i2c_ali15x3_init(void);
1329#endif
1330#ifdef CONFIG_I2C_AMD756
1331        extern int i2c_amd756_init(void);
1332#endif
1333#ifdef CONFIG_I2C_HYDRA
1334        extern int i2c_hydra_init(void);
1335#endif
1336#ifdef CONFIG_I2C_I801
1337        extern int i2c_i801_init(void);
1338#endif
1339#ifdef CONFIG_I2C_I810
1340        extern int i2c_i810_init(void);
1341#endif
1342#ifdef CONFIG_I2C_ISA
1343        extern int i2c_isa_init(void);
1344#endif
1345#ifdef CONFIG_I2C_PIIX4
1346        extern int i2c_piix4_init(void);
1347#endif
1348#ifdef CONFIG_I2C_SIS5595
1349        extern int i2c_sis5595_init(void);
1350#endif
1351#ifdef CONFIG_I2C_SAVAGE4
1352        extern int i2c_savage4_init(void);
1353#endif
1354#ifdef CONFIG_I2C_TSUNAMI
1355        extern int i2c_tsunami_init(void);
1356#endif
1357#ifdef CONFIG_I2C_VIA
1358        extern int i2c_via_init(void);
1359#endif
1360#ifdef CONFIG_I2C_VIAPRO
1361        extern int i2c_vt596_init(void);
1362#endif
1363#ifdef CONFIG_I2C_VOODOO3
1364        extern int i2c_voodoo3_init(void);
1365#endif
1366EOF
1367      } elsif ($patch_nr == 2) {
1368      print OUTPUT << 'EOF';
1369#ifdef CONFIG_I2C_ALI1535
1370        i2c_ali1535_init();
1371#endif
1372#ifdef CONFIG_I2C_ALI15X3
1373        i2c_ali15x3_init();
1374#endif
1375#ifdef CONFIG_I2C_AMD756
1376        i2c_amd756_init();
1377#endif
1378#ifdef CONFIG_I2C_HYDRA
1379        i2c_hydra_init();
1380#endif
1381#ifdef CONFIG_I2C_I801
1382        i2c_i801_init();
1383#endif
1384#ifdef CONFIG_I2C_I810
1385        i2c_i810_init();
1386#endif
1387#ifdef CONFIG_I2C_PIIX4
1388        i2c_piix4_init();
1389#endif
1390#ifdef CONFIG_I2C_SIS5595
1391        i2c_sis5595_init();
1392#endif
1393#ifdef CONFIG_I2C_SAVAGE4
1394        i2c_savage4_init();
1395#endif
1396#ifdef CONFIG_I2C_TSUNAMI
1397        i2c_tsunami_init();
1398#endif
1399#ifdef CONFIG_I2C_VIA
1400        i2c_via_init();
1401#endif
1402#ifdef CONFIG_I2C_VIAPRO
1403        i2c_vt596_init();
1404#endif
1405#ifdef CONFIG_I2C_VOODOO3
1406        i2c_voodoo3_init();
1407#endif
1408#ifdef CONFIG_I2C_ISA
1409        i2c_isa_init();
1410#endif
1411EOF
1412      }
1413      $patch_nr ++;
1414    }
1415    print OUTPUT;
1416  }
1417  close INPUT;
1418  close OUTPUT;
1419  die "Automatic patch generation for `drivers/i2c/i2c-core.c' failed.\n".
1420      "See our home page http://www.lm-sensors.nu for assistance!" if $patch_nr != 3;
1421  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
1422}
1423
1424# Generate the diffs for the list of MAINTAINERS
1425# $_[0]: i2c package root (like /tmp/i2c)
1426# $_[1]: Linux kernel tree (like /usr/src/linux)
1427sub gen_MAINTAINERS
1428{
1429  my ($package_root,$kernel_root) = @_;
1430  my $kernel_file = "MAINTAINERS";
1431  my $package_file = $temp;
1432  my $done = 0;
1433
1434  open INPUT,"$kernel_root/$kernel_file"
1435        or die "Can't open `$kernel_root/$kernel_file'";
1436  open OUTPUT,">$package_root/$package_file"
1437        or die "Can't open $package_root/$package_file";
1438  MAIN: while(<INPUT>) {
1439    if (m@SENSORS DRIVERS@) {
1440       $_=<INPUT> while not m@^$@;
1441       $_=<INPUT>;
1442       redo MAIN;
1443    }
1444    if (not $done and (m@SGI VISUAL WORKSTATION 320 AND 540@)) {
1445      print OUTPUT <<'EOF';
1446SENSORS DRIVERS
1447P:      Frodo Looijaard
1448M:      frodol@dds.nl
1449P:      Philip Edelbrock
1450M:      phil@netroedge.com
1451L:      sensors@stimpy.netroedge.com
1452W:      http://www.lm-sensors.nu/
1453S:      Maintained
1454
1455EOF
1456      $done = 1;
1457    }
1458    print OUTPUT;
1459  }
1460  close INPUT;
1461  close OUTPUT;
1462  die "Automatic patch generation for `MAINTAINERS' failed.\n".
1463      "See our home page http://www.lm-sensors.nu for assistance!" if $done == 0;
1464  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
1465}
1466
1467
1468# Main function
1469sub main
1470{
1471  my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file);
1472  my ($diff_command,$dummy,$data0,$data1,$sedscript,$version_string);
1473
1474  # --> Read the command-lineo
1475  $package_root = $ARGV[0];
1476  die "Package root `$package_root' is not found\n" 
1477        unless -d "$package_root/mkpatch";
1478  $kernel_root = $ARGV[1];
1479  die "Kernel root `$kernel_root' is not found\n" 
1480        unless -f "$kernel_root/Rules.make";
1481
1482  # --> Read FILES
1483  open INPUT, "$package_root/mkpatch/FILES" 
1484        or die "Can't open `$package_root/mkpatch/FILES'";
1485  while (<INPUT>) {
1486    ($data0,$data1) = /(\S+)\s+(\S+)/;
1487    $files{$data0} = $data1;
1488  } 
1489  close INPUT;
1490
1491  # --> Read INCLUDES
1492  open INPUT, "$package_root/mkpatch/INCLUDES" 
1493        or die "Can't open `$package_root/mkpatch/INCLUDES'";
1494  while (<INPUT>) {
1495    ($data0,$data1) = /(\S+)\s+(\S+)/;
1496    $includes{$data0} = $data1;
1497    $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; ';
1498  } 
1499  close INPUT;
1500
1501  die "First apply the i2c patches to `$kernel_root'!" 
1502       if ! -d "$kernel_root/drivers/i2c";
1503
1504  # --> Read "version.h"
1505  open INPUT, "$package_root/version.h"
1506        or die "Can't open `$package_root/version.h'";
1507  $version_string .= $_ while <INPUT>;
1508  close INPUT;
1509 
1510  # --> Start generating
1511  foreach $package_file (sort keys %files) {
1512    open INPUT,"$package_root/$package_file" 
1513          or die "Can't open `$package_root/$package_file'";
1514    open OUTPUT,">$package_root/$temp"
1515          or die "Can't open `$package_root/$temp'";
1516    while (<INPUT>) {
1517      eval $sedscript;
1518      if (m@#\s*include\s*"version.h"@) {
1519        print OUTPUT $version_string;
1520      } else {
1521        print OUTPUT;
1522      }
1523    }
1524    close INPUT;
1525    close OUTPUT;
1526
1527    $kernel_file = $files{$package_file};
1528    print_diff $package_root,$kernel_root,$kernel_file,$temp;
1529  }
1530
1531  gen_Makefile $package_root, $kernel_root;
1532  gen_drivers_Makefile $package_root, $kernel_root;
1533  gen_drivers_sensors_Makefile $package_root, $kernel_root;
1534  gen_drivers_char_Config_in $package_root, $kernel_root;
1535  gen_drivers_char_mem_c $package_root, $kernel_root;
1536  gen_drivers_i2c_Config_in $package_root, $kernel_root;
1537  gen_drivers_i2c_Makefile $package_root, $kernel_root;
1538  gen_drivers_i2c_i2c_core_c $package_root, $kernel_root;
1539  gen_Documentation_Configure_help $package_root, $kernel_root;
1540  gen_MAINTAINERS $package_root, $kernel_root;
1541}
1542
1543main;
1544
Note: See TracBrowser for help on using the browser.