File: mkpatch.pl

package info (click to toggle)
lm-sensors 1%3A2.10.8-2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 5,320 kB
  • ctags: 10,818
  • sloc: ansic: 63,999; perl: 8,169; sh: 1,820; makefile: 406; lex: 371; yacc: 312; python: 11
file content (1353 lines) | stat: -rwxr-xr-x 49,131 bytes parent folder | download
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
#!/usr/bin/perl -w

#    mkpatch - Create patches against the Linux kernel
#    Copyright (C) 1999  Frodo Looijaard <frodol@dds.nl>
#    Copyright (C) 2005-2007  Jean Delvare <khali@linux-fr.org>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

use strict;

use vars qw($temp);
$temp = "mkpatch/.temp";

# Generate a diff between the old kernel file and the new lm_sensors file. We
# arrange the headers to tell us the old tree was under directory
# `linux-old', and the new tree under `linux'.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
# $_[2]: Name of the kernel file
# $_[3]: Name of the patched file
sub print_diff
{
  my ($package_root,$kernel_root,$kernel_file,$package_file) = @_;
  my ($diff_command,$package_mtime,$kernel_mtime);

  $diff_command = "diff -u";
  if ( -e "$kernel_root/$kernel_file") {
    $diff_command .= " $kernel_root/$kernel_file";
    $kernel_mtime = (stat("$kernel_root/$kernel_file"))[9];
  } else {
    $diff_command .= " /dev/null";
    $kernel_mtime = 0;
  }
  if ( -e "$package_root/$package_file") {
    $diff_command .= " $package_root/$package_file";
    $package_mtime = (stat("$package_root/$package_file"))[9];
  } else {
    $diff_command .= " /dev/null";
    $package_mtime = 0;
  }
  open INPUT, "$diff_command|" or die "Can't execute `$diff_command'";
  if (<INPUT>) {
    <INPUT>;
    print "--- linux-old/$kernel_file\t".gmtime($kernel_mtime)."\n".
          "+++ linux/$kernel_file\t".gmtime($package_mtime)."\n";

    print while <INPUT>;
  }
  close INPUT;
}

# This generates diffs for kernel file Documentation/Configure.help. This
# file contains the help texts that can be displayed during `make *config'
# for the kernel.
# The new texts are put at the end of the file, or just before the
# lm_sensors texts.
# Of course, care is taken old lines are removed.
# $_[0]: i2c package root (like /tmp/i2c)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_Documentation_Configure_help
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "Documentation/Configure.help";
  my $package_file = $temp;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if (m@I2C mainboard interfaces@ or
           m@Acer Labs ALI 1535@ or
           m@Acer Labs ALI 1533 and 1543C@ or
           m@Acer Labs ALI 1563@ or
           m@AMD 756/766/768/8111@ or
           m@SMBus multiplexing on the Tyan S4882@ or
           m@AMD 8111 SMBus 2.0@ or
           m@Apple Hydra Mac I/O@ or
           m@Intel I801@ or
           m@Intel I810/I815 based Mainboard@ or
           m@Intel 82371AB PIIX4\(E\)@ or
           m@Nvidia Nforce2@ or
           m@Silicon Integrated Systems Corp. SiS5595 based Mainboard@ or
           m@VIA Technologies, Inc. VT82C586B@ or
           m@VIA Technologies, Inc. VT82C596, 596B, 686A/B, 8233@ or
           m@3DFX Banshee / Voodoo3@ or
           m@DEC Tsunami 21272@ or
           m@Pseudo ISA adapter \(for hardware sensors modules\)@ or
           m@Analog Devices ADM1021 and compatibles@ or
           m@Analog Devices ADM1024@ or
           m@Analog Devices ADM1025@ or
           m@Analog Devices ADM1026@ or
           m@Analog Devices ADM1030, ADM1031@ or
           m@Analog Devices ADM9240 and compatibles@ or
           m@Asus ASB100@ or
           m@Dallas DS1621 and DS1625@ or
           m@Fintek F71805F@ or
           m@Fujitsu-Siemens Hermes@ or
           m@Fujitsu-Siemens Poseidon@ or
           m@Fujitsu-Siemens Scylla@ or
           m@Genesys Logic GL518SM@ or
           m@Genesys Logic GL520SM@ or
           m@HP Maxilife@ or
           m@Intel Xeon Thermal Sensor@ or
           m@ITE 8705, 8712, Sis950@ or
           m@Maxim MAX1619@ or
           m@Maxim MAX6650, MAX6651@ or
           m@Myson MTP008@ or
           m@National Semiconductor LM63@ or
           m@National Semiconductor LM75 and compatibles@ or
           m@National Semiconductor LM78@ or
           m@National Semiconductor LM80@ or
           m@National Semiconductor LM83@ or
           m@National Semiconductor LM85@ or
           m@National Semiconductor LM87@ or
           m@National Semiconductor LM90@ or
           m@National Semiconductor LM92@ or
           m@National Semiconductor LM93@ or
           m@National Semiconductor PC8736x@ or
           m@Silicon Integrated Systems Corp. SiS5595 Sensor@ or
           m@Texas Instruments THMC50 / Analog Devices ADM1022@ or
           m@Via VT82C686A/B@ or
           m@Winbond W83781D, W83782D, W83783S@ or
           m@Winbond W83792D@ or
           m@Winbond W83627HF, W83627THF@ or
           m@Winbond W83627EHF/EHG@ or
           m@Winbond W83L785TS-S@ or
           m@EEprom \(DIMM\) reader@) {
      $_ = <INPUT>;
      $_ = <INPUT>;
      $_ = <INPUT> while not m@^\S@ and not eof(INPUT);
      redo MAIN;
    }
    if (eof(INPUT)) {
      print OUTPUT <<'EOF'
I2C mainboard interfaces
CONFIG_I2C_MAINBOARD
  Many modern mainboards have some kind of I2C interface integrated. This
  is often in the form of a SMBus, or System Management Bus, which is
  basically the same as I2C but which uses only a subset of the I2C
  protocol.

  You will also want the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Acer Labs ALI 1535
CONFIG_I2C_ALI1535
  If you say yes to this option, support will be included for the Acer
  Labs ALI 1535 mainboard I2C interface. This can also be
  built as a module.

Acer Labs ALI 1533 and 1543C
CONFIG_I2C_ALI15X3
  If you say yes to this option, support will be included for the Acer
  Labs ALI 1533 and 1543C mainboard I2C interfaces. This can also be
  built as a module which can be inserted and removed while the kernel
  is running.

Acer Labs ALI 1563
CONFIG_I2C_ALI1563
  If you say yes to this option, support will be included for the Acer
  Labs ALI M1563 mainboard SMBus interface. This can also be built as a
  module.

AMD 756/766/768/8111 and nVidia nForce
CONFIG_I2C_AMD756
  If you say yes to this option, support will be included for the AMD
  756/766/768/8111 and nVidia nForce mainboard I2C interfaces. This can
  also be built as a module which can be inserted and removed while the
  kernel is running.

SMBus multiplexing on the Tyan S4882
CONFIG_I2C_AMD756_S4882
  Enabling this option will add specific SMBus support for the Tyan
  S4882 motherboard. On this 4-CPU board, the SMBus is multiplexed
  over 8 different channels, where the various memory module EEPROMs
  and temperature sensors live. Saying yes here will give you access
  to these in addition to the trunk.

AMD 8111 SMBus 2.0
CONFIG_I2C_AMD8111
  If you say yes to this option, support will be included for the AMD
  8111 mainboard SMBus 2.0 interface. This can also be
  built as a module which can be inserted and removed while the kernel
  is running.

Apple Hydra Mac I/O
CONFIG_I2C_HYDRA
  If you say yes to this option, support will be included for the
  Hydra mainboard I2C interface. This can also be built as a module
  which can be inserted and removed while the kernel is running.

Intel I801
CONFIG_I2C_I801
  If you say yes to this option, support will be included for the
  Intel I801 mainboard I2C interfaces. "I810" mainboard sensor chips are
  generally located on the I801's I2C bus. This can also be
  built as a module which can be inserted and removed while the kernel
  is running.

Intel I810/I815 based Mainboard
CONFIG_I2C_I810
  If you say yes to this option, support will be included for the
  Intel I810/I810E/I815/I845G mainboard I2C interfaces. The I2C busses
  of these chips are generally used only for video devices. For "810"
  mainboard sensor chips, use the I801 I2C driver instead.
  
  This can also be built as a module which can be inserted and removed
  while the kernel is running.

Intel 82371AB PIIX4(E), ServerWorks OSB4, CSB5, CSB6, HT-1000
CONFIG_I2C_PIIX4
  If you say yes to this option, support will be included for the
  Intel PIIX4, PIIX4E, 443MX, Serverworks OSB4, CSB5, CSB6 and
  HT-1000, ATI IXP200, IXP300, IXP400, SB600, SB700 and SB800, and
  SMSC Victory66 mainboard SMBus interfaces.
  
  This can also be built as a module which can be inserted and removed
  while the kernel is running.

Nvidia Nforce2/3/4 based Mainboard
CONFIG_I2C_NFORCE2
  If you say yes to this option, support will be included for the
  Nvidia Nforce2, Nforce3 and Nforce4 families of mainboard SMBus
  interfaces.
  
  This can also be built as a module which can be inserted and removed
  while the kernel is running.

Silicon Integrated Systems Corp. SiS5595 based Mainboard
CONFIG_I2C_SIS5595
  If you say yes to this option, support will be included for the
  SiS5595 mainboard I2C interfaces. For integrated sensors on the
  Sis5595, use CONFIG_SENSORS_SIS5595. This can also be
  built as a module which can be inserted and removed while the kernel
  is running.

Silicon Integrated Systems Corp. SiS630/730 based Mainboard
CONFIG_I2C_SIS630
  If you say yes to this option, support will be included for the SiS 630
  and 730 mainboard I2C interfaces. This can also be built as a module
  which can be inserted and removed while the kernel is running.

Silicon Integrated Systems Corp. SiS645/961,645DX/961,735 based Mainboard
CONFIG_I2C_SIS645
  If you say yes to this option, support will be included for the SiS 645/961,
  645DX/961 and 735 mainboard I2C interfaces. This can also be built as a module
  which can be inserted and removed while the kernel is running.

VIA Technologies, Inc. VT82C586B
CONFIG_I2C_VIA
  If you say yes to this option, support will be included for the VIA
  Technologies I2C adapter found on some motherboards. This can also
  be built as a module which can be inserted and removed while the
  kernel is running.

VIA Technologies, Inc. VT82C596/82C686/82xx and CX700/VX800/VX820
CONFIG_I2C_VIAPRO
  If you say yes to this option, support will be included for the VIA
  Technologies I2C adapter on these chips. For integrated sensors on the
  Via 686A/B, use CONFIG_SENSORS_VIA686A. This can also be
  be built as a module which can be inserted and removed while the
  kernel is running.

3DFX Banshee / Voodoo3
CONFIG_I2C_VOODOO3
  If you say yes to this option, support will be included for the
  3DFX Banshee and Voodoo3 I2C interfaces. The I2C busses on the these
  chips are generally used only for video devices.
  This can also be
  built as a module which can be inserted and removed while the kernel
  is running.

DEC Tsunami 21272
CONFIG_I2C_TSUNAMI
  If you say yes to this option, support will be included for the DEC
  Tsunami chipset I2C adapter. Requires the Alpha architecture;
  do not enable otherwise. This can also be built as a module which
  can be inserted and removed while the kernel is running.

Pseudo ISA adapter (for hardware sensors modules)
CONFIG_I2C_ISA
  This provides support for accessing some hardware sensor chips over
  the ISA bus rather than the I2C or SMBus. If you want to do this,
  say yes here. This feature can also be built as a module which can
  be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM1021 and compatibles
CONFIG_SENSORS_ADM1021
  If you say yes here you get support for Analog Devices ADM1021
  and ADM1023 sensor chips and clones: Maxim MAX1617 and MAX1617A,
  Genesys Logic GL523SM, National Semi LM84, TI THMC10 and Onsemi
  MC1066. This can also be built as a module which can be inserted
  and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM1024
CONFIG_SENSORS_ADM1024
  If you say yes here you get support for Analog Devices ADM1024 sensor
  chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM1025
CONFIG_SENSORS_ADM1025
  If you say yes here you get support for Analog Devices ADM1025 sensor
  chips.  This can also be built as a module which can be inserted and
  removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM1026
CONFIG_SENSORS_ADM1026
  If you say yes here you get support for Analog Devices ADM1026 sensor
  chips.  This can also be built as a module which can be inserted and
  removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM1030, ADM1031
CONFIG_SENSORS_ADM1031
  If you say yes here you get support for Analog Devices ADM1030 and
  ADM1031 sensor chips.  This can also be built as a module which can
  be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Analog Devices ADM9240 and compatibles
CONFIG_SENSORS_ADM9240
  If you say yes here you get support for Analog Devices ADM9240
  sensor chips and clones: the Dallas Semiconductor DS1780 and
  the National Semiconductor LM81. This can also be built as a
  module which can be inserted and removed while the kernel is
  running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Asus ASB100
CONFIG_SENSORS_ASB100
  If you say yes here you get support for the Asus ASB100 (aka
  "Bach") sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Dallas DS1621 and DS1625
CONFIG_SENSORS_DS1621
  If you say yes here you get support for the Dallas DS1621 and DS1625x
  sensor chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Fintek F71805F
CONFIG_SENSORS_F71805F
  If you say yes here you get support for the hardware monitoring
  features of the Fintek F71805F/FG Super-I/O chip.  This can also be
  built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Fujitsu-Siemens Hermes
CONFIG_SENSORS_FSCHER
  If you say yes here you get support for the Fujitsu-Siemens Hermes
  sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Fujitsu-Siemens Poseidon
CONFIG_SENSORS_FSCPOS
  If you say yes here you get support for the Fujitsu-Siemens Poseidon
  sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Fujitsu-Siemens Scylla
CONFIG_SENSORS_FSCSCY
  If you say yes here you get support for the Fujitsu-Siemens Scylla
  sensor chip.  This can also be built as a module. This driver may/should
  also work with the following Fujitsu-Siemens chips: "Poseidon",
  "Poseidon II" and "Hydra". You may have to force loading of the module
  for motherboards in these cases. Be careful - those motherboards have
  not been tested with this driver.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Genesys Logic GL518SM
CONFIG_SENSORS_GL518SM
  If you say yes here you get support for Genesys Logic GL518SM sensor
  chips.  This can also be built as a module which can be inserted and
  removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Genesys Logic GL520SM
CONFIG_SENSORS_GL520SM
  If you say yes here you get support for Genesys Logic GL518SM sensor
  chips.  This can also be built as a module which can be inserted and
  removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

HP Maxilife
CONFIG_SENSORS_MAXILIFE
  If you say yes here you get support for the HP Maxilife
  sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Intel Xeon Thermal Sensor
CONFIG_SENSORS_XEONTEMP
  If you say yes here you get support for the Intel Xeon processor
  built-in thermal sensor. This can also be built as a module which
  can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

ITE 8705, 8712, Sis950
CONFIG_SENSORS_IT87
  If you say yes here you get support for the ITE 8705 and 8712 and
  SiS950 sensor chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Maxim MAX1619
CONFIG_SENSORS_MAX1619
  If you say yes here you get support for the Maxim MAX1619 sensor
  chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Maxim MAX6650, MAX6651
CONFIG_SENSORS_MAX6650
  If you say yes here you get support for the Maxim MAX6650 and
  MAX6651 sensor chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Myson MTP008
CONFIG_SENSORS_MTP008
  If you say yes here you get support for the Myson MTP008
  sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM63
CONFIG_SENSORS_LM63
  If you say yes here you get support for National Semiconductor LM63
  sensor chips.  This can also be built as a module which can be inserted
  and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM75 and compatibles
CONFIG_SENSORS_LM75
  If you say yes here you get support for National Semiconductor LM75
  sensor chips and clones: Dallas Semiconductor DS75 and DS1775 (in
  9-bit precision mode), and TelCom (now Microchip) TCN75. This can
  also be built as a module which can be inserted and removed while
  the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM78
CONFIG_SENSORS_LM78
  If you say yes here you get support for National Semiconductor LM78
  sensor chips family: the LM78-J and LM79. Many clone chips will
  also work at least somewhat with this driver. This can also be built
  as a module which can be inserted and removed while the kernel is
  running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM80
CONFIG_SENSORS_LM80
  If you say yes here you get support for National Semiconductor LM80
  sensor chips. This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM83 and compatibles
CONFIG_SENSORS_LM83
  If you say yes here you get support for the National Semiconductor
  LM82 and LM83 sensor chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM85
CONFIG_SENSORS_LM85
  If you say yes here you get support for National Semiconductor LM85
  sensor chips and compatibles.  Compatible chips include the Analog
  Devices ADM1027 and ADT7463 and SMSC EMC6D100 and EMC6D101.  This
  can also be built as a module which can be inserted and removed
  while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM87
CONFIG_SENSORS_LM87
  If you say yes here you get support for National Semiconductor LM87
  sensor chips. This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM90
CONFIG_SENSORS_LM90
  If you say yes here you get support for the National Semiconductor
  LM90, LM89 and LM99, Analog Devices ADM1032 and ADT7461, and Maxim
  MAX6657 and MAX6658 sensor chips.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM92
CONFIG_SENSORS_LM92
  If you say yes here you get support for National Semiconductor LM92
  sensor chips. This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor LM93
CONFIG_SENSORS_LM93
  If you say yes here you get support for National Semiconductor LM93
  sensor chips.  This can also be built as a module which can be inserted
  and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

National Semiconductor PC8736x Sensors
CONFIG_SENSORS_PC87360
  If you say yes here you get support for the integrated hardware
  monitoring in the National Semicoductor PC87360, PC87363, PC87364,
  PC87365 and PC87366 Super I/O chips. This can also be built as a
  module which can be inserted and removed while the kernel is
  running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Philips PCF8574
CONFIG_SENSORS_PCF8574
  If you say yes here you get support for the Philips PCF8574
  I2C 8-bit Parallel I/O device.
  This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Philips PCF8591
CONFIG_SENSORS_PCF8591
  If you say yes here you get support for the Philips PCF8591
  I2C Quad D/A + Single A/D I/O device.
  This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Silicon Integrated Systems Corp. SiS5595 Sensor
CONFIG_SENSORS_SIS5595
  If you say yes here you get support for the integrated sensors in
  SiS5595 South Bridges. This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

SMSC47M1xx Super I/O Fan Support
CONFIG_SENSORS_SMSC47M1
  If you say yes here you get support for the integrated fan
  monitoring and control in the SMSC 47M1xx Super I/O chips.
  This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Texas Instruments THMC50 / Analog Devices ADM1022
CONFIG_SENSORS_THMC50
  If you say yes here you get support for Texas Instruments THMC50
  sensor chips and clones: the Analog Devices ADM1022.
  This can also be built as a module which
  can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Via VT82C686A/B
CONFIG_SENSORS_VIA686A
  If you say yes here you get support for the integrated sensors in
  Via 686A/B South Bridges. This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Via VT1211 Sensors
CONFIG_SENSORS_VT1211
  If you say yes here you get support for the integrated sensors in
  the Via VT1211 Super I/O device. This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Via VT8231 Sensors
CONFIG_SENSORS_VT8231
  If you say yes here you get support for the integrated sensors in
  the Via VT8231 device. This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Winbond W83781D, W83782D, W83783S, W83627HF, AS99127F
CONFIG_SENSORS_W83781D
  If you say yes here you get support for the Winbond W8378x series
  of sensor chips: the W83781D, W83782D, W83783S and W83627HF,
  and the similar Asus AS99127F. This can also be built as a module
  which can be inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Winbond W83792D
CONFIG_SENSORS_W83792D
  If you say yes here you get support for the Winbond W83792D
  sensor chips.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Winbond W83627HF, W83627THF, W83637HF, W83687THF, W83697HF
CONFIG_SENSORS_W83627HF
  If you say yes here you get support for the Winbond W836x7 series
  of sensor chips: the W83627HF, W83627THF, W83637HF, W83687THF and
  W83697HF. This can also be built as a module which can be inserted
  and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Winbond W83627EHF/EHG
CONFIG_SENSORS_W83627EHF
  If you say yes here you get support for the Winbond W83627EHF/EHG
  sensor chips. This can also be built as a module which can be
  inserted and removed while the kernel is running.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

Winbond W83L785TS-S
CONFIG_SENSORS_W83L785TS
  If you say yes here you get support for the Winbond W83L785TS-S
  sensor chip.  This can also be built as a module.

  You will also need the latest user-space utilities: you can find
  them in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

EEprom (DIMM) reader
CONFIG_SENSORS_EEPROM
  If you say yes here you get read-only access to the EEPROM data
  available on modern memory DIMMs, and which could theoretically
  also be available on other devices. This can also be built as a
  module which can be inserted and removed while the kernel is
  running.

  You will also need the latest user-space utilities: you can find them
  in the lm_sensors package, which you can download at
  http://www.lm-sensors.org/

EOF
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}


# This generates diffs for the main Linux Makefile.
# Three lines which add drivers/sensors/sensors.a to the DRIVERS list are
# put just before the place where the architecture Makefile is included.
# Of course, care is taken old lines are removed.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_Makefile
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "Makefile";
  my $package_file = $temp;
  my $type = 0;
  my $pr1 = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  `grep -q -s 'i2c\.o' "$kernel_root/$kernel_file"`;
  $type = 2 if ! $?;
  MAIN: while(<INPUT>) {
    $type = 1 if !$type and (m@^DRIVERS-\$@);
    if (m@DRIVERS-\$\(CONFIG_SENSORS\)@) {
      $_ = <INPUT>;
      redo MAIN;
    } elsif (m@CONFIG_SENSORS@) {
      $_ = <INPUT> while not m@endif@;
      $_ = <INPUT>;
      $_ = <INPUT> if m@^$@;
      redo MAIN;
    }
    if ($type == 1 and m@^DRIVERS \+= \$\(DRIVERS-y\)@) {
      print OUTPUT <<'EOF';
DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensors.a
EOF
      $pr1 = 1;
    }
    if ($type == 2 and m@^DRIVERS .*= \$\(DRIVERS-y\)@) {
      print OUTPUT <<'EOF';
DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensor.o
EOF
      $pr1 = 1;
    }
    if ($type == 0 and m@include arch/\$\(ARCH\)/Makefile@) {
      print OUTPUT <<'EOF';
ifeq ($(CONFIG_SENSORS),y)
DRIVERS := $(DRIVERS) drivers/sensors/sensors.a
endif

EOF
      $pr1 = 1;
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for main `Makefile' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $pr1 == 0;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# This generates diffs for drivers/Makefile
# First, `sensors' is added to the ALL_SUB_DIRS list. Next, a couple of lines
# to add sensors to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before
# Rules.make is included.
# Of course, care is taken old lines are removed.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_drivers_Makefile
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "drivers/Makefile";
  my $package_file = $temp;
  my $sensors_present;
  my $pr1 = 0;
  my $pr2 = 0;
  my $new_style = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if (m@^mod-subdirs\s*:=@) {
      $new_style = 1;
    }
    if ((! $new_style and m@^ALL_SUB_DIRS\s*:=@) or m@^mod-subdirs\s*:=@) {
      $pr1 = 1;
      $sensors_present = 0;
      while (m@\\$@) {
        $sensors_present = 1 if m@sensors@;
        print OUTPUT;
        $_ = <INPUT>;
      }
      $sensors_present = 1 if m@sensors@;
      s@$@ sensors@ if (not $sensors_present);
      print OUTPUT;
      $_ = <INPUT>;
      redo MAIN;
    }
    if (m@^ifeq.*CONFIG_SENSORS@) {
      $_ = <INPUT> while not m@^endif@;
      $_ = <INPUT>;
      $_ = <INPUT> if m@^$@;
      redo MAIN;
    }
    if (m@^subdir.*CONFIG_SENSORS@) {
      $_ = <INPUT>;
      redo MAIN;
    }
    if (!$pr2 and (m@^include \$\(TOPDIR\)/Rules.make$@ or m@^subdir-\$\(CONFIG_ACPI@)) {
      $pr2 = 1;
      if ($new_style) {
      print OUTPUT <<'EOF';
subdir-$(CONFIG_SENSORS) 	+= sensors
EOF
      } else {
      print OUTPUT <<'EOF';
ifeq ($(CONFIG_SENSORS),y)
SUB_DIRS += sensors
MOD_SUB_DIRS += sensors
else
  ifeq ($(CONFIG_SENSORS),m)
  MOD_SUB_DIRS += sensors
  endif
endif

EOF
      }
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `drivers/Makefile' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $pr1 == 0 or $pr2 == 0;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# This generates diffs for drivers/char/Config.in
# It adds a line just before CONFIG_APM or main_menu_option lines to include
# the sensors Config.in.
# Of course, care is taken old lines are removed.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_drivers_char_Config_in
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "drivers/char/Config.in";
  my $package_file = $temp;
  my $pr1 = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if (m@source drivers/i2c/Config.in@) {
      $pr1 = 1;
      print OUTPUT;
      print OUTPUT "\nsource drivers/sensors/Config.in\n";
      $_ = <INPUT>;
      redo MAIN;
    }
    if (m@sensors@) {
      $_ = <INPUT>;
      $_ = <INPUT> if m@^$@;
      redo MAIN;
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `drivers/char/Config.in' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $pr1 == 0;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# This generates diffs for drivers/i2c/Config.in
# Several adapter drivers that are included in the lm_sensors package are
# added at the first and onlu sensors marker.
# Of course, care is taken old lines are removed.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_drivers_i2c_Config_in
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "drivers/i2c/Config.in";
  my $package_file = "$temp";
  my $pr1 = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  while(<INPUT>) {
    if (m@sensors code starts here@) {
      $pr1++;
      print OUTPUT;
      while (<INPUT>) {
        last if m@sensors code ends here@;
      }
      print OUTPUT << 'EOF';
  bool 'I2C mainboard interfaces' CONFIG_I2C_MAINBOARD
  if [ "$CONFIG_I2C_MAINBOARD" = "y" ]; then
    dep_tristate '  Acer Labs ALI 1535' CONFIG_I2C_ALI1535 $CONFIG_I2C
    dep_tristate '  Acer Labs ALI 1533 and 1543C' CONFIG_I2C_ALI15X3 $CONFIG_I2C
    dep_tristate '  Acer Labs ALI 1563' CONFIG_I2C_ALI1563 $CONFIG_I2C
    dep_tristate '  Apple Hydra Mac I/O' CONFIG_I2C_HYDRA $CONFIG_I2C_ALGOBIT
    dep_tristate '  AMD 756/766/768/8111 and nVidia nForce' CONFIG_I2C_AMD756 $CONFIG_I2C
    if [ "$CONFIG_I2C_AMD756" != "n" ]; then
      dep_tristate '    SMBus multiplexing on the Tyan S4882' CONFIG_I2C_AMD756_S4882 $CONFIG_I2C_AMD756
    fi
    dep_tristate '  AMD 8111 SMBus 2.0' CONFIG_I2C_AMD8111 $CONFIG_I2C
    if [ "$CONFIG_ALPHA" = "y" ]; then
      dep_tristate '  DEC Tsunami I2C interface' CONFIG_I2C_TSUNAMI $CONFIG_I2C_ALGOBIT
    fi
    dep_tristate '  Intel 82801 (ICH) and ESB' CONFIG_I2C_I801 $CONFIG_I2C
    dep_tristate '  Intel i810AA/AB/E and i815' CONFIG_I2C_I810 $CONFIG_I2C_ALGOBIT
    dep_tristate '  Intel 82371AB PIIX4(E), 443MX, ServerWorks OSB4/CSB5, SMSC Victory66' CONFIG_I2C_PIIX4 $CONFIG_I2C
    dep_tristate '  Nvidia Nforce2/3/4' CONFIG_I2C_NFORCE2 $CONFIG_I2C
    dep_tristate '  SiS 5595' CONFIG_I2C_SIS5595 $CONFIG_I2C
    dep_tristate '  SiS 630/730' CONFIG_I2C_SIS630 $CONFIG_I2C
    dep_tristate '  SiS 645/961,645DX/961,735' CONFIG_I2C_SIS645 $CONFIG_I2C $CONFIG_HOTPLUG
    dep_tristate '  Savage 4' CONFIG_I2C_SAVAGE4 $CONFIG_I2C_ALGOBIT
    dep_tristate '  VIA Technologies, Inc. VT82C586B' CONFIG_I2C_VIA $CONFIG_I2C_ALGOBIT
    dep_tristate '  VIA Technologies, Inc. VT82C596/82C686/82xx and CX700/VX800/VX820' CONFIG_I2C_VIAPRO $CONFIG_I2C
    dep_tristate '  Voodoo3 I2C interface' CONFIG_I2C_VOODOO3 $CONFIG_I2C_ALGOBIT
    dep_tristate '  Pseudo ISA adapter (for some hardware sensors)' CONFIG_I2C_ISA $CONFIG_I2C
  fi

EOF
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `drivers/i2c/Config.in' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $pr1 != 1;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

sub gen_drivers_sensors_Makefile
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "drivers/sensors/Makefile";
  my $package_file = $temp;

  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  print OUTPUT <<'EOF';
#
# Makefile for the kernel hardware sensors drivers.
#

MOD_LIST_NAME := SENSORS_MODULES
O_TARGET := sensor.o

obj-$(CONFIG_SENSORS_ADM1021)	+= adm1021.o
obj-$(CONFIG_SENSORS_ADM1024)	+= adm1024.o
obj-$(CONFIG_SENSORS_ADM1025)	+= adm1025.o
obj-$(CONFIG_SENSORS_ADM1026)	+= adm1026.o
obj-$(CONFIG_SENSORS_ADM1031)	+= adm1031.o
obj-$(CONFIG_SENSORS_ADM9240)	+= adm9240.o
obj-$(CONFIG_SENSORS_ASB100)	+= asb100.o
obj-$(CONFIG_SENSORS_BT869)	+= bt869.o
obj-$(CONFIG_SENSORS_DDCMON)	+= ddcmon.o
obj-$(CONFIG_SENSORS_DS1621)	+= ds1621.o
obj-$(CONFIG_SENSORS_EEPROM)	+= eeprom.o
obj-$(CONFIG_SENSORS_F71805F)	+= f71805f.o
obj-$(CONFIG_SENSORS_FSCHER)	+= fscher.o
obj-$(CONFIG_SENSORS_FSCPOS)	+= fscpos.o
obj-$(CONFIG_SENSORS_FSCSCY)	+= fscscy.o
obj-$(CONFIG_SENSORS_GL518SM)	+= gl518sm.o
obj-$(CONFIG_SENSORS_GL520SM)	+= gl520sm.o
obj-$(CONFIG_SENSORS_IT87)	+= it87.o
obj-$(CONFIG_SENSORS_LM63)	+= lm63.o
obj-$(CONFIG_SENSORS_LM75)	+= lm75.o
obj-$(CONFIG_SENSORS_LM78)	+= lm78.o
obj-$(CONFIG_SENSORS_LM80)	+= lm80.o
obj-$(CONFIG_SENSORS_LM83)	+= lm83.o
obj-$(CONFIG_SENSORS_LM85)	+= lm85.o
obj-$(CONFIG_SENSORS_LM87)	+= lm87.o
obj-$(CONFIG_SENSORS_LM90)	+= lm90.o
obj-$(CONFIG_SENSORS_LM92)	+= lm92.o
obj-$(CONFIG_SENSORS_LM93)	+= lm93.o
obj-$(CONFIG_SENSORS_MAX1619)	+= max1619.o
obj-$(CONFIG_SENSORS_MAX6650)	+= max6650.o
obj-$(CONFIG_SENSORS_MAXILIFE)	+= maxilife.o
obj-$(CONFIG_SENSORS_MTP008)	+= mtp008.o
obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
obj-$(CONFIG_SENSORS_PCF8574)	+= pcf8574.o
obj-$(CONFIG_SENSORS_PCF8591)	+= pcf8591.o
obj-$(CONFIG_SENSORS_SIS5595)	+= sis5595.o
obj-$(CONFIG_SENSORS_SMSC47M1)	+= smsc47m1.o
obj-$(CONFIG_SENSORS_THMC50)	+= thmc50.o
obj-$(CONFIG_SENSORS_VIA686A)	+= via686a.o
obj-$(CONFIG_SENSORS_VT1211)	+= vt1211.o
obj-$(CONFIG_SENSORS_VT8231)	+= vt8231.o
obj-$(CONFIG_SENSORS_W83781D)	+= w83781d.o
obj-$(CONFIG_SENSORS_W83792D)	+= w83792d.o
obj-$(CONFIG_SENSORS_W83627HF)	+= w83627hf.o
obj-$(CONFIG_SENSORS_W83627EHF)	+= w83627ehf.o
obj-$(CONFIG_SENSORS_W83L785TS)	+= w83l785ts.o
obj-$(CONFIG_SENSORS_XEONTEMP)	+= xeontemp.o

include $(TOPDIR)/Rules.make

EOF
  close OUTPUT;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# This generates diffs for drivers/i2c/Makefile.
# Lines to add correct files to M_OBJS and/or L_OBJS are added just before
# Rules.make is included
# Of course, care is taken old lines are removed.
# $_[0]: sensors package root (like /tmp/sensors)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_drivers_i2c_Makefile
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "drivers/i2c/Makefile";
  my $package_file = $temp;
  my $pr1 = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  while(<INPUT>) {
    if (m@sensors code starts here@) {
      $pr1 ++;
      print OUTPUT;
      while (<INPUT>) {
        last if m@sensors code ends here@;
      }
      print OUTPUT <<'EOF';
export-objs	+= i2c-amd756.o

obj-$(CONFIG_I2C_ALI1535)		+= i2c-ali1535.o
obj-$(CONFIG_I2C_ALI15X3)		+= i2c-ali15x3.o
obj-$(CONFIG_I2C_ALI1563)		+= i2c-ali1563.o
obj-$(CONFIG_I2C_AMD756)		+= i2c-amd756.o
obj-$(CONFIG_I2C_AMD756_S4882)		+= i2c-amd756-s4882.o
obj-$(CONFIG_I2C_AMD8111)		+= i2c-amd8111.o
obj-$(CONFIG_I2C_HYDRA)			+= i2c-hydra.o
obj-$(CONFIG_I2C_I801)			+= i2c-i801.o
obj-$(CONFIG_I2C_I810)			+= i2c-i810.o
obj-$(CONFIG_I2C_ISA)			+= i2c-isa.o
obj-$(CONFIG_I2C_NFORCE2)		+= i2c-nforce2.o
obj-$(CONFIG_I2C_PIIX4)			+= i2c-piix4.o
obj-$(CONFIG_I2C_SIS5595)		+= i2c-sis5595.o
obj-$(CONFIG_I2C_SIS630)		+= i2c-sis630.o
obj-$(CONFIG_I2C_SIS645)		+= i2c-sis645.o
obj-$(CONFIG_I2C_SAVAGE4)		+= i2c-savage4.o
obj-$(CONFIG_I2C_TSUNAMI)		+= i2c-tsunami.o
obj-$(CONFIG_I2C_VIA)			+= i2c-via.o
obj-$(CONFIG_I2C_VIAPRO)		+= i2c-viapro.o
obj-$(CONFIG_I2C_VOODOO3)		+= i2c-voodoo3.o
EOF
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `drivers/i2c/Makefile' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $pr1 != 1;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# Generate the diffs for the list of MAINTAINERS
# $_[0]: i2c package root (like /tmp/i2c)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_MAINTAINERS
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "MAINTAINERS";
  my $package_file = $temp;
  my $done = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if (m@SENSORS DRIVERS@) {
       $_=<INPUT> while not m@^$@;
       $_=<INPUT>;
       redo MAIN;
    }
    if (not $done and (m@SGI VISUAL WORKSTATION 320 AND 540@)) {
      print OUTPUT <<'EOF';
SENSORS DRIVERS
L:      lm-sensors@lm-sensors.org
W:      http://www.lm-sensors.org/
S:      Maintained

EOF
      $done = 1;
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `MAINTAINERS' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $done == 0;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}

# Generate the diffs for dmi_scan.c and i386_ksyms.c
# $_[0]: i2c package root (like /tmp/i2c)
# $_[1]: Linux kernel tree (like /usr/src/linux)
sub gen_dmi_scan
{
  my ($package_root,$kernel_root) = @_;
  my $kernel_file = "arch/i386/kernel/dmi_scan.c";
  my $package_file = $temp;
  my $done = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if ($done == 0 && m/^\s*int is_sony_vaio_laptop;\s*$/) {
      print OUTPUT <<'EOF';
int is_unsafe_smbus;
EOF
      $done++;
    }
    if ($done == 1 && m/^\s*\* Check for a Sony Vaio system\s*$/) {
      print OUTPUT <<'EOF';
 * Don't access SMBus on IBM systems which get corrupted eeproms
 */

static __init int disable_smbus(struct dmi_blacklist *d)
{
	if (is_unsafe_smbus == 0) {
		is_unsafe_smbus = 1;
		printk(KERN_INFO "%s machine detected. Disabling SMBus accesses.\n", d->ident);
	}
	return 0;
}

/*
EOF
      $done++;
    }
    if ($done == 2 && m/^\s*\{ sony_vaio_laptop, "Sony Vaio", \{ \/\* This is a Sony Vaio laptop \*\/\s*$/) {
      print OUTPUT <<'EOF';
	{ disable_smbus, "IBM", {
			MATCH(DMI_SYS_VENDOR, "IBM"),
			NO_MATCH, NO_MATCH, NO_MATCH
			} },
EOF
      $done++;
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `$kernel_file' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $done != 3;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;

  $kernel_file = "arch/i386/kernel/i386_ksyms.c";
  $done = 0;

  open INPUT,"$kernel_root/$kernel_file"
        or die "Can't open `$kernel_root/$kernel_file'";
  open OUTPUT,">$package_root/$package_file"
        or die "Can't open $package_root/$package_file";
  MAIN: while(<INPUT>) {
    if ($done == 0 && m/^\s*extern int is_sony_vaio_laptop;\s*$/) {
      print OUTPUT <<'EOF';
extern int is_unsafe_smbus;
EXPORT_SYMBOL(is_unsafe_smbus);

EOF
      $done++;
    }
    print OUTPUT;
  }
  close INPUT;
  close OUTPUT;
  die "Automatic patch generation for `$kernel_file' failed.\n".
      "See our home page http://www.lm-sensors.org/ for assistance!" if $done != 1;
  print_diff $package_root,$kernel_root,$kernel_file,$package_file;
}


sub usage
{
  print "Usage: $0 package_root kernel_root\n";
  exit 1;
}

# Main function
sub main
{
  my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file);
  my ($diff_command,$dummy,$data0,$data1,$sedscript,$version_string);

  # --> Read the command-line
  $package_root = $ARGV[0];
  usage() unless defined $package_root;
  die "Package root `$package_root' is not found\n"
        unless -d "$package_root/mkpatch";
  $kernel_root = $ARGV[1];
  usage() unless defined $kernel_root;
  die "Kernel root `$kernel_root' is not found\n"
        unless -f "$kernel_root/Rules.make";

  # --> Read FILES
  open INPUT, "$package_root/mkpatch/FILES"
        or die "Can't open `$package_root/mkpatch/FILES'";
  while (<INPUT>) {
    ($data0,$data1) = /(\S+)\s+(\S+)/;
    $files{$data0} = $data1;
  }
  close INPUT;

  # --> Read INCLUDES
  open INPUT, "$package_root/mkpatch/INCLUDES"
        or die "Can't open `$package_root/mkpatch/INCLUDES'";
  while (<INPUT>) {
    ($data0,$data1) = /(\S+)\s+(\S+)/;
    $includes{$data0} = $data1;
    $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),$1'."$data1".'$2, ; ';
  }
  close INPUT;

  die "First apply the i2c patches to `$kernel_root'!"
       if ! -d "$kernel_root/drivers/i2c";

  # --> Read "version.h"
  open INPUT, "$package_root/version.h"
        or die "Can't open `$package_root/version.h'";
  $version_string .= $_ while <INPUT>;
  close INPUT;

  # --> Start generating
  foreach $package_file (sort keys %files) {
    open INPUT,"$package_root/$package_file"
          or die "Can't open `$package_root/$package_file'";
    open OUTPUT,">$package_root/$temp"
          or die "Can't open `$package_root/$temp'";
    while (<INPUT>) {
      eval $sedscript;
      if (m@#\s*include\s*"version.h"@) {
        print OUTPUT $version_string;
      } else {
        print OUTPUT;
      }
    }
    close INPUT;
    close OUTPUT;

    $kernel_file = $files{$package_file};
    print_diff $package_root,$kernel_root,$kernel_file,$temp;
  }

  gen_Makefile $package_root, $kernel_root;
  gen_drivers_Makefile $package_root, $kernel_root;
  gen_drivers_sensors_Makefile $package_root, $kernel_root;
  gen_drivers_char_Config_in $package_root, $kernel_root;
  gen_drivers_i2c_Config_in $package_root, $kernel_root;
  gen_drivers_i2c_Makefile $package_root, $kernel_root;
  gen_Documentation_Configure_help $package_root, $kernel_root;
  gen_MAINTAINERS $package_root, $kernel_root;
  gen_dmi_scan $package_root, $kernel_root;

  # Clear temporary file
  unlink("$package_root/$temp");
}

main;