| 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 | |
|---|
| 20 | use strict; |
|---|
| 21 | |
|---|
| 22 | use vars qw($temp); |
|---|
| 23 | $temp = "mkpatch/.temp"; |
|---|
| 24 | |
|---|
| 25 | # Generate a diff between the old kernel file and the new I2C 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 |
|---|
| 32 | sub 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) |
|---|
| 68 | sub 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 1533 and 1543C@ or |
|---|
| 81 | m@Apple Hydra Mac I/O@ or |
|---|
| 82 | m@Intel 82371AB PIIX4\(E\)@ or |
|---|
| 83 | m@VIA Technologies, Inc. VT82C586B@ or |
|---|
| 84 | m@Pseudo ISA adapter \(for hardware sensors modules\)@ or |
|---|
| 85 | m@Analog Devices ADM1021 and compatibles@ or |
|---|
| 86 | m@Analog Devices ADM9240 and compatibles@ or |
|---|
| 87 | m@Genesys Logic GL518SM@ or |
|---|
| 88 | m@National Semiconductors LM75@ or |
|---|
| 89 | m@National Semiconductors LM78@ or |
|---|
| 90 | m@National Semiconductors LM80@ or |
|---|
| 91 | m@Silicon Integrated Systems Corp. SiS5595@ or |
|---|
| 92 | m@Winbond W83781D, W83782D and W83783S@ or |
|---|
| 93 | m@EEprom \(DIMM\) reader@ or |
|---|
| 94 | m@Linear Technologies LTC1710@) { |
|---|
| 95 | $_ = <INPUT>; |
|---|
| 96 | $_ = <INPUT>; |
|---|
| 97 | $_ = <INPUT> while not m@^\S@ and not eof(INPUT); |
|---|
| 98 | redo MAIN; |
|---|
| 99 | } |
|---|
| 100 | if (eof(INPUT)) { |
|---|
| 101 | print OUTPUT <<'EOF' |
|---|
| 102 | I2C mainboard interfaces |
|---|
| 103 | CONFIG_I2C_MAINBOARD |
|---|
| 104 | Many modern mainboards have some kind of I2C interface integrated. This |
|---|
| 105 | is often in the form of a SMBus, or System Management Bus, which is |
|---|
| 106 | basically the same as I2C but which uses only a subset of the I2C |
|---|
| 107 | protocol. |
|---|
| 108 | |
|---|
| 109 | You will also want the latest user-space utilties: you can find them |
|---|
| 110 | in the lm_sensors package, which you can download at |
|---|
| 111 | http://www.lm-sensors.nu |
|---|
| 112 | |
|---|
| 113 | Acer Labs ALI 1533 and 1543C |
|---|
| 114 | CONFIG_I2C_ALI15X3 |
|---|
| 115 | If you say yes to this option, support will be included for the Acer |
|---|
| 116 | Labs ALI 1533 and 1543C mainboard I2C interfaces. This can also be |
|---|
| 117 | built as a module which can be inserted and removed while the kernel |
|---|
| 118 | is running. |
|---|
| 119 | |
|---|
| 120 | Apple Hydra Mac I/O |
|---|
| 121 | CONFIG_I2C_HYDRA |
|---|
| 122 | If you say yes to this option, support will be included for the |
|---|
| 123 | Hydra mainboard I2C interface. This can also be built as a module |
|---|
| 124 | which can be inserted and removed while the kernel is running. |
|---|
| 125 | |
|---|
| 126 | Intel 82371AB PIIX4(E) |
|---|
| 127 | CONFIG_I2C_PIIX4 |
|---|
| 128 | If you say yes to this option, support will be included for the |
|---|
| 129 | Intel PIIX4 and PIIX4E mainboard I2C interfaces. This can also be |
|---|
| 130 | built as a module which can be inserted and removed while the kernel |
|---|
| 131 | is running. |
|---|
| 132 | |
|---|
| 133 | VIA Technologies, Inc. VT82C586B |
|---|
| 134 | CONFIG_I2C_VIA |
|---|
| 135 | If you say yes to this option, support will be included for the VIA |
|---|
| 136 | Technologies I2C adapter found on some motherboards. This can also |
|---|
| 137 | be built as a module which can be inserted and removed while the |
|---|
| 138 | kernel is running. |
|---|
| 139 | |
|---|
| 140 | Pseudo ISA adapter (for hardware sensors modules) |
|---|
| 141 | CONFIG_I2C_ISA |
|---|
| 142 | This provides support for accessing some hardware sensor chips over |
|---|
| 143 | the ISA bus rather than the I2C or SMBus. If you want to do this, |
|---|
| 144 | say yes here. This feature can also be built as a module which can |
|---|
| 145 | be inserted and removed while the kernel is running. |
|---|
| 146 | |
|---|
| 147 | You will also need the latest user-space utilties: you can find them |
|---|
| 148 | in the lm_sensors package, which you can download at |
|---|
| 149 | http://www.lm-sensors.nu |
|---|
| 150 | |
|---|
| 151 | Analog Devices ADM1021 and compatibles |
|---|
| 152 | CONFIG_SENSORS_ADM1021 |
|---|
| 153 | If you say yes here you get support for Analog Devices ADM1021 |
|---|
| 154 | sensor chips and clones: the Maxim MAX1617 and MAX1617A, the |
|---|
| 155 | TI THMC10 and the XEON processor built-in sensor. This can also |
|---|
| 156 | be built as a module which can be inserted and removed while the |
|---|
| 157 | kernel is running. |
|---|
| 158 | |
|---|
| 159 | You will also need the latest user-space utilties: you can find them |
|---|
| 160 | in the lm_sensors package, which you can download at |
|---|
| 161 | http://www.lm-sensors.nu |
|---|
| 162 | |
|---|
| 163 | Analog Devices ADM9240 and compatibles |
|---|
| 164 | CONFIG_SENSORS_ADM9240 |
|---|
| 165 | If you say yes here you get support for Analog Devices ADM9240 |
|---|
| 166 | sensor chips and clones: the Dallas Semiconductors DS1780 and |
|---|
| 167 | the National Semiconductors LM81. This can also be built as a |
|---|
| 168 | module which can be inserted and removed while the kernel is |
|---|
| 169 | running. |
|---|
| 170 | |
|---|
| 171 | You will also need the latest user-space utilties: you can find them |
|---|
| 172 | in the lm_sensors package, which you can download at |
|---|
| 173 | http://www.lm-sensors.nu |
|---|
| 174 | |
|---|
| 175 | Genesys Logic GL518SM |
|---|
| 176 | CONFIG_SENSORS_GL518SM |
|---|
| 177 | If you say yes here you get support for Genesys Logic GL518SM sensor |
|---|
| 178 | chips. This can also be built as a module which can be inserted and |
|---|
| 179 | removed while the kernel is running. |
|---|
| 180 | |
|---|
| 181 | You will also need the latest user-space utilties: you can find them |
|---|
| 182 | in the lm_sensors package, which you can download at |
|---|
| 183 | http://www.lm-sensors.nu |
|---|
| 184 | |
|---|
| 185 | National Semiconductors LM75 |
|---|
| 186 | CONFIG_SENSORS_LM75 |
|---|
| 187 | If you say yes here you get support for National Semiconductor LM75 |
|---|
| 188 | sensor chips. This can also be built as a module which can be |
|---|
| 189 | inserted and removed while the kernel is running. |
|---|
| 190 | |
|---|
| 191 | You will also need the latest user-space utilties: you can find them |
|---|
| 192 | in the lm_sensors package, which you can download at |
|---|
| 193 | http://www.lm-sensors.nu |
|---|
| 194 | |
|---|
| 195 | National Semiconductors LM78 |
|---|
| 196 | CONFIG_SENSORS_LM78 |
|---|
| 197 | If you say yes here you get support for National Semiconductor LM78 |
|---|
| 198 | sensor chips family: the LM78-J and LM79. Many clone chips will |
|---|
| 199 | also work at least somewhat with this driver. This can also be built |
|---|
| 200 | as a module which can be inserted and removed while the kernel is |
|---|
| 201 | running. |
|---|
| 202 | |
|---|
| 203 | You will also need the latest user-space utilties: you can find them |
|---|
| 204 | in the lm_sensors package, which you can download at |
|---|
| 205 | http://www.lm-sensors.nu |
|---|
| 206 | |
|---|
| 207 | National Semiconductors LM80 |
|---|
| 208 | CONFIG_SENSORS_LM80 |
|---|
| 209 | If you say yes here you get support for National Semiconductor LM80 |
|---|
| 210 | sensor chips. This can also be built as a module which can be |
|---|
| 211 | inserted and removed while the kernel is running. |
|---|
| 212 | |
|---|
| 213 | You will also need the latest user-space utilties: you can find them |
|---|
| 214 | in the lm_sensors package, which you can download at |
|---|
| 215 | http://www.lm-sensors.nu |
|---|
| 216 | |
|---|
| 217 | Silicon Integrated Systems Corp. SiS5595 |
|---|
| 218 | CONFIG_SENSORS_SIS5595 |
|---|
| 219 | If you say yes here you get support for Silicon Integrated Systems |
|---|
| 220 | Corp. SiS5595 sensor chips. This can also be built as a module |
|---|
| 221 | which can be inserted and removed while the kernel is running. |
|---|
| 222 | |
|---|
| 223 | You will also need the latest user-space utilties: you can find them |
|---|
| 224 | in the lm_sensors package, which you can download at |
|---|
| 225 | http://www.lm-sensors.nu |
|---|
| 226 | |
|---|
| 227 | Winbond W83781D, W83782D and W83783S |
|---|
| 228 | CONFIG_SENSORS_W83781D |
|---|
| 229 | If you say yes here you get support for the Winbond W8378x series |
|---|
| 230 | of sensor chips: the W83781D, W83782D, W83783S and W83682HF. This |
|---|
| 231 | can also be built as a module which can be inserted and removed |
|---|
| 232 | while the kernel is running. |
|---|
| 233 | |
|---|
| 234 | You will also need the latest user-space utilties: you can find them |
|---|
| 235 | in the lm_sensors package, which you can download at |
|---|
| 236 | http://www.lm-sensors.nu |
|---|
| 237 | |
|---|
| 238 | EEprom (DIMM) reader |
|---|
| 239 | CONFIG_SENSORS_EEPROM |
|---|
| 240 | If you say yes here you get read-only access to the EEPROM data |
|---|
| 241 | available on modern memory DIMMs, and which could theoretically |
|---|
| 242 | also be available on other devices. This can also be built as a |
|---|
| 243 | module which can be inserted and removed while the kernel is |
|---|
| 244 | running. |
|---|
| 245 | |
|---|
| 246 | You will also need the latest user-space utilties: you can find them |
|---|
| 247 | in the lm_sensors package, which you can download at |
|---|
| 248 | http://www.lm-sensors.nu |
|---|
| 249 | |
|---|
| 250 | Linear Technologies LTC1710 |
|---|
| 251 | CONFIG_SENSORS_LTC1710 |
|---|
| 252 | If you say yes here you get support for Linear Technologies LTC1710 |
|---|
| 253 | sensor chips. This can also be built as a module which can be |
|---|
| 254 | inserted and removed while the kernel is running. |
|---|
| 255 | |
|---|
| 256 | You will also need the latest user-space utilties: you can find them |
|---|
| 257 | in the lm_sensors package, which you can download at |
|---|
| 258 | http://www.lm-sensors.nu |
|---|
| 259 | |
|---|
| 260 | EOF |
|---|
| 261 | } |
|---|
| 262 | print OUTPUT; |
|---|
| 263 | } |
|---|
| 264 | close INPUT; |
|---|
| 265 | close OUTPUT; |
|---|
| 266 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 267 | } |
|---|
| 268 | |
|---|
| 269 | |
|---|
| 270 | # This generates diffs for the main Linux Makefile. |
|---|
| 271 | # Three lines which add drivers/sensors/sensors.a to the DRIVERS list are |
|---|
| 272 | # put just before the place where the architecture Makefile is included. |
|---|
| 273 | # Of course, care is taken old lines are removed. |
|---|
| 274 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 275 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 276 | sub gen_Makefile |
|---|
| 277 | { |
|---|
| 278 | my ($package_root,$kernel_root) = @_; |
|---|
| 279 | my $kernel_file = "Makefile"; |
|---|
| 280 | my $package_file = $temp; |
|---|
| 281 | my $type = 0; |
|---|
| 282 | my $pr1 = 0; |
|---|
| 283 | |
|---|
| 284 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 285 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 286 | open OUTPUT,">$package_root/$package_file" |
|---|
| 287 | or die "Can't open $package_root/$package_file"; |
|---|
| 288 | `grep -q -s 'i2c\.o' "$kernel_root/$kernel_file"`; |
|---|
| 289 | $type = 2 if ! $?; |
|---|
| 290 | MAIN: while(<INPUT>) { |
|---|
| 291 | $type = 1 if !$type and (m@^DRIVERS-\$@); |
|---|
| 292 | if (m@DRIVERS-\$\(CONFIG_SENSORS\)@) { |
|---|
| 293 | $_ = <INPUT>; |
|---|
| 294 | redo MAIN; |
|---|
| 295 | } elsif (m@CONFIG_SENSORS@) { |
|---|
| 296 | $_ = <INPUT> while not m@endif@; |
|---|
| 297 | $_ = <INPUT>; |
|---|
| 298 | $_ = <INPUT> if m@^$@; |
|---|
| 299 | redo MAIN; |
|---|
| 300 | } |
|---|
| 301 | if ($type == 1 and m@^DRIVERS \+= \$\(DRIVERS-y\)@) { |
|---|
| 302 | print OUTPUT <<'EOF'; |
|---|
| 303 | DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensors.a |
|---|
| 304 | EOF |
|---|
| 305 | $pr1 = 1; |
|---|
| 306 | } |
|---|
| 307 | if ($type == 2 and m@^DRIVERS \+= \$\(DRIVERS-y\)@) { |
|---|
| 308 | print OUTPUT <<'EOF'; |
|---|
| 309 | DRIVERS-$(CONFIG_SENSORS) += drivers/sensors/sensors.o |
|---|
| 310 | EOF |
|---|
| 311 | $pr1 = 1; |
|---|
| 312 | } |
|---|
| 313 | if ($type == 0 and m@include arch/\$\(ARCH\)/Makefile@) { |
|---|
| 314 | print OUTPUT <<'EOF'; |
|---|
| 315 | ifeq ($(CONFIG_SENSORS),y) |
|---|
| 316 | DRIVERS := $(DRIVERS) drivers/sensors/sensors.a |
|---|
| 317 | endif |
|---|
| 318 | |
|---|
| 319 | EOF |
|---|
| 320 | $pr1 = 1; |
|---|
| 321 | } |
|---|
| 322 | print OUTPUT; |
|---|
| 323 | } |
|---|
| 324 | close INPUT; |
|---|
| 325 | close OUTPUT; |
|---|
| 326 | die "Automatic patch generation for `Makefile' failed.\n". |
|---|
| 327 | "Contact the authors please!" if $pr1 == 0; |
|---|
| 328 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 329 | } |
|---|
| 330 | |
|---|
| 331 | # This generates diffs for drivers/Makefile |
|---|
| 332 | # First, `sensors' is added to the ALL_SUB_DIRS list. Next, a couple of lines |
|---|
| 333 | # to add sensors to the SUB_DIRS and/or MOD_SUB_DIRS lists is put right before |
|---|
| 334 | # Rules.make is included. |
|---|
| 335 | # Of course, care is taken old lines are removed. |
|---|
| 336 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 337 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 338 | sub gen_drivers_Makefile |
|---|
| 339 | { |
|---|
| 340 | my ($package_root,$kernel_root) = @_; |
|---|
| 341 | my $kernel_file = "drivers/Makefile"; |
|---|
| 342 | my $package_file = $temp; |
|---|
| 343 | my $sensors_present; |
|---|
| 344 | my $pr1 = 0; |
|---|
| 345 | my $pr2 = 0; |
|---|
| 346 | |
|---|
| 347 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 348 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 349 | open OUTPUT,">$package_root/$package_file" |
|---|
| 350 | or die "Can't open $package_root/$package_file"; |
|---|
| 351 | MAIN: while(<INPUT>) { |
|---|
| 352 | if (m@^ALL_SUB_DIRS\s*:=@) { |
|---|
| 353 | $pr1 = 1; |
|---|
| 354 | $sensors_present = 0; |
|---|
| 355 | while (m@\\$@) { |
|---|
| 356 | $sensors_present = 1 if m@sensors@; |
|---|
| 357 | print OUTPUT; |
|---|
| 358 | $_ = <INPUT>; |
|---|
| 359 | } |
|---|
| 360 | $sensors_present = 1 if m@sensors@; |
|---|
| 361 | s@$@ sensors@ if (not $sensors_present); |
|---|
| 362 | print OUTPUT; |
|---|
| 363 | $_ = <INPUT>; |
|---|
| 364 | redo MAIN; |
|---|
| 365 | } |
|---|
| 366 | if (m@CONFIG_SENSORS@) { |
|---|
| 367 | $_ = <INPUT> while not m@^endif@; |
|---|
| 368 | $_ = <INPUT>; |
|---|
| 369 | $_ = <INPUT> if m@^$@; |
|---|
| 370 | redo MAIN; |
|---|
| 371 | } |
|---|
| 372 | if (m@^include \$\(TOPDIR\)/Rules.make$@) { |
|---|
| 373 | $pr2 = 1; |
|---|
| 374 | print OUTPUT <<'EOF'; |
|---|
| 375 | ifeq ($(CONFIG_SENSORS),y) |
|---|
| 376 | SUB_DIRS += sensors |
|---|
| 377 | MOD_SUB_DIRS += sensors |
|---|
| 378 | else |
|---|
| 379 | ifeq ($(CONFIG_SENSORS),m) |
|---|
| 380 | MOD_SUB_DIRS += sensors |
|---|
| 381 | endif |
|---|
| 382 | endif |
|---|
| 383 | |
|---|
| 384 | EOF |
|---|
| 385 | } |
|---|
| 386 | print OUTPUT; |
|---|
| 387 | } |
|---|
| 388 | close INPUT; |
|---|
| 389 | close OUTPUT; |
|---|
| 390 | die "Automatic patch generation for `drivers/Makefile' failed.\n". |
|---|
| 391 | "Contact the authors please!" if $pr1 == 0 or $pr2 == 0; |
|---|
| 392 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 393 | } |
|---|
| 394 | |
|---|
| 395 | # This generates diffs for drivers/char/Config.in |
|---|
| 396 | # It adds a line just before CONFIG_APM or main_menu_option lines to include |
|---|
| 397 | # the sensors Config.in. |
|---|
| 398 | # Of course, care is taken old lines are removed. |
|---|
| 399 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 400 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 401 | sub gen_drivers_char_Config_in |
|---|
| 402 | { |
|---|
| 403 | my ($package_root,$kernel_root) = @_; |
|---|
| 404 | my $kernel_file = "drivers/char/Config.in"; |
|---|
| 405 | my $package_file = $temp; |
|---|
| 406 | my $pr1 = 0; |
|---|
| 407 | |
|---|
| 408 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 409 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 410 | open OUTPUT,">$package_root/$package_file" |
|---|
| 411 | or die "Can't open $package_root/$package_file"; |
|---|
| 412 | MAIN: while(<INPUT>) { |
|---|
| 413 | if (m@source drivers/i2c/Config.in@) { |
|---|
| 414 | $pr1 = 1; |
|---|
| 415 | print OUTPUT; |
|---|
| 416 | print OUTPUT "\nsource drivers/sensors/Config.in\n"; |
|---|
| 417 | $_ = <INPUT>; |
|---|
| 418 | redo MAIN; |
|---|
| 419 | } |
|---|
| 420 | if (m@sensors@) { |
|---|
| 421 | $_ = <INPUT>; |
|---|
| 422 | $_ = <INPUT> if m@^$@; |
|---|
| 423 | redo MAIN; |
|---|
| 424 | } |
|---|
| 425 | print OUTPUT; |
|---|
| 426 | } |
|---|
| 427 | close INPUT; |
|---|
| 428 | close OUTPUT; |
|---|
| 429 | die "Automatic patch generation for `drivers/Makefile' failed.\n". |
|---|
| 430 | "Contact the authors please!" if $pr1 == 0; |
|---|
| 431 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 432 | } |
|---|
| 433 | |
|---|
| 434 | |
|---|
| 435 | # This generates diffs for drivers/char/mem.c They are a bit intricate. |
|---|
| 436 | # Lines are generated at the beginning to declare sensors_init_all |
|---|
| 437 | # At the bottom, a call to sensors_init_all is added when the |
|---|
| 438 | # new lm_sensors stuff is configured in. |
|---|
| 439 | # Of course, care is taken old lines are removed. |
|---|
| 440 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 441 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 442 | sub gen_drivers_char_mem_c |
|---|
| 443 | { |
|---|
| 444 | my ($package_root,$kernel_root) = @_; |
|---|
| 445 | my $kernel_file = "drivers/char/mem.c"; |
|---|
| 446 | my $package_file = $temp; |
|---|
| 447 | my $right_place = 0; |
|---|
| 448 | my $done = 0; |
|---|
| 449 | my $atstart = 1; |
|---|
| 450 | my $pr1 = 0; |
|---|
| 451 | my $pr2 = 0; |
|---|
| 452 | |
|---|
| 453 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 454 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 455 | open OUTPUT,">$package_root/$package_file" |
|---|
| 456 | or die "Can't open $package_root/$package_file"; |
|---|
| 457 | MAIN: while(<INPUT>) { |
|---|
| 458 | if ($atstart and m@#ifdef@) { |
|---|
| 459 | $pr1 = 1; |
|---|
| 460 | print OUTPUT << 'EOF'; |
|---|
| 461 | #ifdef CONFIG_SENSORS |
|---|
| 462 | extern void sensors_init_all(void); |
|---|
| 463 | #endif |
|---|
| 464 | EOF |
|---|
| 465 | $atstart = 0; |
|---|
| 466 | } |
|---|
| 467 | if (not $right_place and m@CONFIG_SENSORS@) { |
|---|
| 468 | $_ = <INPUT> while not m@#endif@; |
|---|
| 469 | $_ = <INPUT>; |
|---|
| 470 | redo MAIN; |
|---|
| 471 | } |
|---|
| 472 | $right_place = 1 if (m@lp_init\(\);@); |
|---|
| 473 | if ($right_place and not $done and |
|---|
| 474 | m@CONFIG_SENSORS@) { |
|---|
| 475 | $_ = <INPUT> while not m@#endif@; |
|---|
| 476 | $_ = <INPUT>; |
|---|
| 477 | $_ = <INPUT> if m@^$@; |
|---|
| 478 | redo MAIN; |
|---|
| 479 | } |
|---|
| 480 | if ($right_place and not $done and m@return 0;@) { |
|---|
| 481 | $pr2 = 1; |
|---|
| 482 | print OUTPUT <<'EOF'; |
|---|
| 483 | #ifdef CONFIG_SENSORS |
|---|
| 484 | sensors_init_all(); |
|---|
| 485 | #endif |
|---|
| 486 | |
|---|
| 487 | EOF |
|---|
| 488 | $done = 1; |
|---|
| 489 | } |
|---|
| 490 | print OUTPUT; |
|---|
| 491 | } |
|---|
| 492 | close INPUT; |
|---|
| 493 | close OUTPUT; |
|---|
| 494 | die "Automatic patch generation for `drivers/char/mem.c' failed.\n". |
|---|
| 495 | "Contact the authors please!" if $pr1 == 0 or $pr2 == 0; |
|---|
| 496 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 497 | } |
|---|
| 498 | |
|---|
| 499 | |
|---|
| 500 | # This generates diffs for drivers/i2c/Config.in |
|---|
| 501 | # Several adapter drivers that are included in the lm_sensors package are |
|---|
| 502 | # added at the first and onlu sensors marker. |
|---|
| 503 | # Of course, care is taken old lines are removed. |
|---|
| 504 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 505 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 506 | sub gen_drivers_i2c_Config_in |
|---|
| 507 | { |
|---|
| 508 | my ($package_root,$kernel_root) = @_; |
|---|
| 509 | my $kernel_file = "drivers/i2c/Config.in"; |
|---|
| 510 | my $package_file = "$temp"; |
|---|
| 511 | my $pr1 = 0; |
|---|
| 512 | |
|---|
| 513 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 514 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 515 | open OUTPUT,">$package_root/$package_file" |
|---|
| 516 | or die "Can't open $package_root/$package_file"; |
|---|
| 517 | while(<INPUT>) { |
|---|
| 518 | if (m@sensors code starts here@) { |
|---|
| 519 | $pr1++; |
|---|
| 520 | print OUTPUT; |
|---|
| 521 | while (<INPUT>) { |
|---|
| 522 | last if m@sensors code ends here@; |
|---|
| 523 | } |
|---|
| 524 | print OUTPUT << 'EOF'; |
|---|
| 525 | bool 'I2C mainboard interfaces' CONFIG_I2C_MAINBOARD |
|---|
| 526 | if [ "$CONFIG_I2C_MAINBOARD" = "y" ]; then |
|---|
| 527 | tristate ' Acer Labs ALI 1533 and 1543C' CONFIG_I2C_ALI15X3 |
|---|
| 528 | dep_tristate ' Apple Hydra Mac I/O' CONFIG_I2C_HYDRA $CONFIG_I2C_ALGOBIT |
|---|
| 529 | tristate ' Intel 82371AB PIIX4(E)' CONFIG_I2C_PIIX4 |
|---|
| 530 | dep_tristate ' VIA Technologies, Inc. VT82C586B' CONFIG_I2C_VIA $CONFIG_I2C_ALGOBIT |
|---|
| 531 | tristate ' Pseudo ISA adapter (for hardware sensors modules)' CONFIG_I2C_ISA |
|---|
| 532 | fi |
|---|
| 533 | |
|---|
| 534 | EOF |
|---|
| 535 | } |
|---|
| 536 | print OUTPUT; |
|---|
| 537 | } |
|---|
| 538 | close INPUT; |
|---|
| 539 | close OUTPUT; |
|---|
| 540 | die "Automatic patch generation for `drivers/i2c/Config.in' failed.\n". |
|---|
| 541 | "Contact the authors please!" if $pr1 != 1; |
|---|
| 542 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 543 | } |
|---|
| 544 | |
|---|
| 545 | sub gen_drivers_sensors_Makefile |
|---|
| 546 | { |
|---|
| 547 | my ($package_root,$kernel_root) = @_; |
|---|
| 548 | my $kernel_file = "drivers/sensors/Makefile"; |
|---|
| 549 | my $package_file = $temp; |
|---|
| 550 | my $use_new_format; |
|---|
| 551 | `grep -q -s 'i2c\.o' "$kernel_root/drivers/i2c/Makefile"`; |
|---|
| 552 | $use_new_format = ! $?; |
|---|
| 553 | |
|---|
| 554 | open OUTPUT,">$package_root/$package_file" |
|---|
| 555 | or die "Can't open $package_root/$package_file"; |
|---|
| 556 | if ($use_new_format) { |
|---|
| 557 | print OUTPUT <<'EOF'; |
|---|
| 558 | # |
|---|
| 559 | # Makefile for the kernel hardware sensors drivers. |
|---|
| 560 | # |
|---|
| 561 | |
|---|
| 562 | MOD_LIST_NAME := SENSORS_MODULES |
|---|
| 563 | O_TARGET := sensors.o |
|---|
| 564 | |
|---|
| 565 | export-objs := sensors.o |
|---|
| 566 | |
|---|
| 567 | obj-$(CONFIG_SENSORS) += sensors.o |
|---|
| 568 | obj-$(CONFIG_SENSORS_ADM1021) += adm1021.o |
|---|
| 569 | obj-$(CONFIG_SENSORS_ADM9024) += adm9024.o |
|---|
| 570 | obj-$(CONFIG_SENSORS_EEPROM) += eeprom.o |
|---|
| 571 | obj-$(CONFIG_SENSORS_GL518SM) += gl518sm.o |
|---|
| 572 | obj-$(CONFIG_SENSORS_LM75) += lm75.o |
|---|
| 573 | obj-$(CONFIG_SENSORS_LM78) += lm78.o |
|---|
| 574 | obj-$(CONFIG_SENSORS_LM80) += lm80.o |
|---|
| 575 | obj-$(CONFIG_SENSORS_LTC1710) += ltc1710.o |
|---|
| 576 | obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o |
|---|
| 577 | obj-$(CONFIG_SENSORS_W83781D) += w83781d.o |
|---|
| 578 | |
|---|
| 579 | O_OBJS := $(filter-out $(export-objs), $(obj-y)) |
|---|
| 580 | OX_OBJS := $(filter $(export-objs), $(obj-y)) |
|---|
| 581 | M_OBJS := $(sort $(filter-out $(export-objs), $(obj-m))) |
|---|
| 582 | MX_OBJS := $(sort $(filter $(export-objs), $(obj-m))) |
|---|
| 583 | |
|---|
| 584 | include $(TOPDIR)/Rules.make |
|---|
| 585 | |
|---|
| 586 | EOF |
|---|
| 587 | } else { |
|---|
| 588 | print OUTPUT <<'EOF'; |
|---|
| 589 | # |
|---|
| 590 | # Makefile for the kernel hardware sensors drivers. |
|---|
| 591 | # |
|---|
| 592 | |
|---|
| 593 | SUB_DIRS := |
|---|
| 594 | MOD_SUB_DIRS := $(SUB_DIRS) |
|---|
| 595 | ALL_SUB_DIRS := $(SUB_DIRS) |
|---|
| 596 | MOD_LIST_NAME := SENSORS_MODULES |
|---|
| 597 | |
|---|
| 598 | L_TARGET := sensors.a |
|---|
| 599 | MX_OBJS := |
|---|
| 600 | M_OBJS := |
|---|
| 601 | LX_OBJS := |
|---|
| 602 | L_OBJS := |
|---|
| 603 | |
|---|
| 604 | # ----- |
|---|
| 605 | # i2c core components |
|---|
| 606 | # ----- |
|---|
| 607 | |
|---|
| 608 | ifeq ($(CONFIG_SENSORS),y) |
|---|
| 609 | LX_OBJS += sensors.o |
|---|
| 610 | else |
|---|
| 611 | ifeq ($(CONFIG_SENSORS),m) |
|---|
| 612 | MX_OBJS += sensors.o |
|---|
| 613 | endif |
|---|
| 614 | endif |
|---|
| 615 | |
|---|
| 616 | ifeq ($(CONFIG_SENSORS_ADM1021),y) |
|---|
| 617 | L_OBJS += adm1021.o |
|---|
| 618 | else |
|---|
| 619 | ifeq ($(CONFIG_SENSORS_ADM1021),m) |
|---|
| 620 | M_OBJS += adm1021.o |
|---|
| 621 | endif |
|---|
| 622 | endif |
|---|
| 623 | |
|---|
| 624 | ifeq ($(CONFIG_SENSORS_ADM9024),y) |
|---|
| 625 | L_OBJS += adm9240.o |
|---|
| 626 | else |
|---|
| 627 | ifeq ($(CONFIG_SENSORS_ADM9024),m) |
|---|
| 628 | M_OBJS += adm9240.o |
|---|
| 629 | endif |
|---|
| 630 | endif |
|---|
| 631 | |
|---|
| 632 | ifeq ($(CONFIG_SENSORS_EEPROM),y) |
|---|
| 633 | L_OBJS += eeprom.o |
|---|
| 634 | else |
|---|
| 635 | ifeq ($(CONFIG_SENSORS_EEPROM),m) |
|---|
| 636 | M_OBJS += eeprom.o |
|---|
| 637 | endif |
|---|
| 638 | endif |
|---|
| 639 | |
|---|
| 640 | ifeq ($(CONFIG_SENSORS_GL518SM),y) |
|---|
| 641 | L_OBJS += gl518sm.o |
|---|
| 642 | else |
|---|
| 643 | ifeq ($(CONFIG_SENSORS_GL518SM),m) |
|---|
| 644 | M_OBJS += gl518sm.o |
|---|
| 645 | endif |
|---|
| 646 | endif |
|---|
| 647 | |
|---|
| 648 | ifeq ($(CONFIG_SENSORS_LM75),y) |
|---|
| 649 | L_OBJS += lm75.o |
|---|
| 650 | else |
|---|
| 651 | ifeq ($(CONFIG_SENSORS_LM75),m) |
|---|
| 652 | M_OBJS += lm75.o |
|---|
| 653 | endif |
|---|
| 654 | endif |
|---|
| 655 | |
|---|
| 656 | ifeq ($(CONFIG_SENSORS_LM78),y) |
|---|
| 657 | L_OBJS += lm78.o |
|---|
| 658 | else |
|---|
| 659 | ifeq ($(CONFIG_SENSORS_LM78),m) |
|---|
| 660 | M_OBJS += lm78.o |
|---|
| 661 | endif |
|---|
| 662 | endif |
|---|
| 663 | |
|---|
| 664 | ifeq ($(CONFIG_SENSORS_LM80),y) |
|---|
| 665 | L_OBJS += lm80.o |
|---|
| 666 | else |
|---|
| 667 | ifeq ($(CONFIG_SENSORS_LM80),m) |
|---|
| 668 | M_OBJS += lm80.o |
|---|
| 669 | endif |
|---|
| 670 | endif |
|---|
| 671 | |
|---|
| 672 | ifeq ($(CONFIG_SENSORS_LTC1710),y) |
|---|
| 673 | L_OBJS += ltc1710.o |
|---|
| 674 | else |
|---|
| 675 | ifeq ($(CONFIG_SENSORS_LTC1710),m) |
|---|
| 676 | M_OBJS += ltc1710.o |
|---|
| 677 | endif |
|---|
| 678 | endif |
|---|
| 679 | |
|---|
| 680 | ifeq ($(CONFIG_SENSORS_SIS5595),y) |
|---|
| 681 | L_OBJS += sis5595.o |
|---|
| 682 | else |
|---|
| 683 | ifeq ($(CONFIG_SENSORS_SIS5595),m) |
|---|
| 684 | M_OBJS += sis5595.o |
|---|
| 685 | endif |
|---|
| 686 | endif |
|---|
| 687 | |
|---|
| 688 | ifeq ($(CONFIG_SENSORS_W83781D),y) |
|---|
| 689 | L_OBJS += w83781d.o |
|---|
| 690 | else |
|---|
| 691 | ifeq ($(CONFIG_SENSORS_W83781D),m) |
|---|
| 692 | M_OBJS += w83781d.o |
|---|
| 693 | endif |
|---|
| 694 | endif |
|---|
| 695 | |
|---|
| 696 | include $(TOPDIR)/Rules.make |
|---|
| 697 | EOF |
|---|
| 698 | } |
|---|
| 699 | close OUTPUT; |
|---|
| 700 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 701 | } |
|---|
| 702 | |
|---|
| 703 | # This generates diffs for drivers/i2c/Makefile. |
|---|
| 704 | # Lines to add correct files to M_OBJS and/or L_OBJS are added just before |
|---|
| 705 | # Rules.make is included |
|---|
| 706 | # Of course, care is taken old lines are removed. |
|---|
| 707 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 708 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 709 | sub gen_drivers_i2c_Makefile |
|---|
| 710 | { |
|---|
| 711 | my ($package_root,$kernel_root) = @_; |
|---|
| 712 | my $kernel_file = "drivers/i2c/Makefile"; |
|---|
| 713 | my $package_file = $temp; |
|---|
| 714 | my $pr1 = 0; |
|---|
| 715 | my $new_format = 0; |
|---|
| 716 | |
|---|
| 717 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 718 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 719 | open OUTPUT,">$package_root/$package_file" |
|---|
| 720 | or die "Can't open $package_root/$package_file"; |
|---|
| 721 | while(<INPUT>) { |
|---|
| 722 | $new_format = 1 if m@i2c\.o@; |
|---|
| 723 | if (m@sensors code starts here@) { |
|---|
| 724 | $pr1 ++; |
|---|
| 725 | print OUTPUT; |
|---|
| 726 | while (<INPUT>) { |
|---|
| 727 | last if m@sensors code ends here@; |
|---|
| 728 | } |
|---|
| 729 | if ($new_format) { |
|---|
| 730 | print OUTPUT << 'EOF'; |
|---|
| 731 | obj-$(CONFIG_I2C_ALI15X3) += i2c-ali15x3.o |
|---|
| 732 | obj-$(CONFIG_I2C_ALI15X3) += i2c-hydra.o |
|---|
| 733 | obj-$(CONFIG_I2C_ALI15X3) += i2c-piix4.o |
|---|
| 734 | obj-$(CONFIG_I2C_ALI15X3) += i2c-via.o |
|---|
| 735 | obj-$(CONFIG_I2C_ALI15X3) += i2c-isa.o |
|---|
| 736 | EOF |
|---|
| 737 | } else { |
|---|
| 738 | print OUTPUT << 'EOF'; |
|---|
| 739 | ifeq ($(CONFIG_I2C_ALI15X3),y) |
|---|
| 740 | L_OBJS += i2c-ali15x3.o |
|---|
| 741 | else |
|---|
| 742 | ifeq ($(CONFIG_I2C_ALI15X3),m) |
|---|
| 743 | M_OBJS += i2c-ali15x3.o |
|---|
| 744 | endif |
|---|
| 745 | endif |
|---|
| 746 | |
|---|
| 747 | ifeq ($(CONFIG_I2C_HYDRA),y) |
|---|
| 748 | L_OBJS += i2c-hydra.o |
|---|
| 749 | else |
|---|
| 750 | ifeq ($(CONFIG_I2C_HYDRA),m) |
|---|
| 751 | M_OBJS += i2c-hydra.o |
|---|
| 752 | endif |
|---|
| 753 | endif |
|---|
| 754 | |
|---|
| 755 | ifeq ($(CONFIG_I2C_PIIX4),y) |
|---|
| 756 | L_OBJS += i2c-piix4.o |
|---|
| 757 | else |
|---|
| 758 | ifeq ($(CONFIG_I2C_PIIX4),m) |
|---|
| 759 | M_OBJS += i2c-piix4.o |
|---|
| 760 | endif |
|---|
| 761 | endif |
|---|
| 762 | |
|---|
| 763 | ifeq ($(CONFIG_I2C_VIA),y) |
|---|
| 764 | L_OBJS += i2c-via.o |
|---|
| 765 | else |
|---|
| 766 | ifeq ($(CONFIG_I2C_VIA),m) |
|---|
| 767 | M_OBJS += i2c-via.o |
|---|
| 768 | endif |
|---|
| 769 | endif |
|---|
| 770 | |
|---|
| 771 | ifeq ($(CONFIG_I2C_ISA),y) |
|---|
| 772 | L_OBJS += i2c-isa.o |
|---|
| 773 | else |
|---|
| 774 | ifeq ($(CONFIG_I2C_ISA),m) |
|---|
| 775 | M_OBJS += i2c-isa.o |
|---|
| 776 | endif |
|---|
| 777 | endif |
|---|
| 778 | |
|---|
| 779 | EOF |
|---|
| 780 | } |
|---|
| 781 | } |
|---|
| 782 | print OUTPUT; |
|---|
| 783 | } |
|---|
| 784 | close INPUT; |
|---|
| 785 | close OUTPUT; |
|---|
| 786 | die "Automatic patch generation for `drivers/i2c/Makefile' failed.\n". |
|---|
| 787 | "Contact the authors please!" if $pr1 != 1; |
|---|
| 788 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 789 | } |
|---|
| 790 | |
|---|
| 791 | # This generates diffs for drivers/i2c/i2c-core.c |
|---|
| 792 | # Lines are generated at the beginning to declare several *_init functions. |
|---|
| 793 | # At the bottom, calls to them are added when the sensors stuff is configured |
|---|
| 794 | # in. |
|---|
| 795 | # $_[0]: sensors package root (like /tmp/sensors) |
|---|
| 796 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 797 | sub gen_drivers_i2c_i2c_core_c |
|---|
| 798 | { |
|---|
| 799 | my ($package_root,$kernel_root) = @_; |
|---|
| 800 | my $kernel_file = "drivers/i2c/i2c-core.c"; |
|---|
| 801 | my $package_file = $temp; |
|---|
| 802 | my $patch_nr = 1; |
|---|
| 803 | |
|---|
| 804 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 805 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 806 | open OUTPUT,">$package_root/$package_file" |
|---|
| 807 | or die "Can't open $package_root/$package_file"; |
|---|
| 808 | while(<INPUT>) { |
|---|
| 809 | if (m@sensors code starts here@) { |
|---|
| 810 | print OUTPUT; |
|---|
| 811 | while (<INPUT>) { |
|---|
| 812 | last if m@sensors code ends here@; |
|---|
| 813 | } |
|---|
| 814 | if ($patch_nr == 1) { |
|---|
| 815 | print OUTPUT << 'EOF'; |
|---|
| 816 | #ifdef CONFIG_I2C_ALI15X3 |
|---|
| 817 | extern int i2c_ali15x3_init(void); |
|---|
| 818 | #endif |
|---|
| 819 | #ifdef CONFIG_I2C_HYDRA |
|---|
| 820 | extern int i2c_hydra_init(void); |
|---|
| 821 | #endif |
|---|
| 822 | #ifdef CONFIG_I2C_PIIX4 |
|---|
| 823 | extern int i2c_piix4_init(void); |
|---|
| 824 | #endif |
|---|
| 825 | #ifdef CONFIG_I2C_VIA |
|---|
| 826 | extern int i2c_via_init(void); |
|---|
| 827 | #endif |
|---|
| 828 | #ifdef CONFIG_I2C_ISA |
|---|
| 829 | extern int i2c_isa_init(void); |
|---|
| 830 | #endif |
|---|
| 831 | EOF |
|---|
| 832 | } elsif ($patch_nr == 2) { |
|---|
| 833 | print OUTPUT << 'EOF'; |
|---|
| 834 | #ifdef CONFIG_I2C_ALI15X3 |
|---|
| 835 | i2c_ali15x3_init(); |
|---|
| 836 | #endif |
|---|
| 837 | #ifdef CONFIG_I2C_HYDRA |
|---|
| 838 | i2c_hydra_init(); |
|---|
| 839 | #endif |
|---|
| 840 | #ifdef CONFIG_I2C_PIIX4 |
|---|
| 841 | i2c_piix4_init(); |
|---|
| 842 | #endif |
|---|
| 843 | #ifdef CONFIG_I2C_VIA |
|---|
| 844 | i2c_via_init(); |
|---|
| 845 | #endif |
|---|
| 846 | #ifdef CONFIG_I2C_ISA |
|---|
| 847 | i2c_isa_init(); |
|---|
| 848 | #endif |
|---|
| 849 | EOF |
|---|
| 850 | } |
|---|
| 851 | $patch_nr ++; |
|---|
| 852 | } |
|---|
| 853 | print OUTPUT; |
|---|
| 854 | } |
|---|
| 855 | close INPUT; |
|---|
| 856 | close OUTPUT; |
|---|
| 857 | die "Automatic patch generation for `drivers/i2c/i2c-core.c' failed.\n". |
|---|
| 858 | "Contact the authors please!" if $patch_nr != 3; |
|---|
| 859 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 860 | } |
|---|
| 861 | |
|---|
| 862 | # Generate the diffs for the list of MAINTAINERS |
|---|
| 863 | # $_[0]: i2c package root (like /tmp/i2c) |
|---|
| 864 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 865 | sub gen_MAINTAINERS |
|---|
| 866 | { |
|---|
| 867 | my ($package_root,$kernel_root) = @_; |
|---|
| 868 | my $kernel_file = "MAINTAINERS"; |
|---|
| 869 | my $package_file = $temp; |
|---|
| 870 | my $done = 0; |
|---|
| 871 | |
|---|
| 872 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 873 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 874 | open OUTPUT,">$package_root/$package_file" |
|---|
| 875 | or die "Can't open $package_root/$package_file"; |
|---|
| 876 | MAIN: while(<INPUT>) { |
|---|
| 877 | if (m@SENSORS DRIVERS@) { |
|---|
| 878 | $_=<INPUT> while not m@^$@; |
|---|
| 879 | $_=<INPUT>; |
|---|
| 880 | redo MAIN; |
|---|
| 881 | } |
|---|
| 882 | if (not $done and (m@SGI VISUAL WORKSTATION 320 AND 540@)) { |
|---|
| 883 | print OUTPUT <<'EOF'; |
|---|
| 884 | SENSORS DRIVERS |
|---|
| 885 | P: Frodo Looijaard |
|---|
| 886 | M: frodol@dds.nl |
|---|
| 887 | P: Philip Edelbrock |
|---|
| 888 | M: phil@netroedge.com |
|---|
| 889 | L: sensors@stimpy.netroedge.com |
|---|
| 890 | W: http://www.lm-sensors.nu/ |
|---|
| 891 | S: Maintained |
|---|
| 892 | |
|---|
| 893 | EOF |
|---|
| 894 | $done = 1; |
|---|
| 895 | } |
|---|
| 896 | print OUTPUT; |
|---|
| 897 | } |
|---|
| 898 | close INPUT; |
|---|
| 899 | close OUTPUT; |
|---|
| 900 | die "Automatic patch generation for `MAINTAINERS' failed.\n". |
|---|
| 901 | "Contact the authors please!" if $done == 0; |
|---|
| 902 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 903 | } |
|---|
| 904 | |
|---|
| 905 | |
|---|
| 906 | # Main function |
|---|
| 907 | sub main |
|---|
| 908 | { |
|---|
| 909 | my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file); |
|---|
| 910 | my ($diff_command,$dummy,$data0,$data1,$sedscript,$version_string); |
|---|
| 911 | |
|---|
| 912 | # --> Read the command-lineo |
|---|
| 913 | $package_root = $ARGV[0]; |
|---|
| 914 | die "Package root `$package_root' is not found\n" |
|---|
| 915 | unless -d "$package_root/mkpatch"; |
|---|
| 916 | $kernel_root = $ARGV[1]; |
|---|
| 917 | die "Kernel root `$kernel_root' is not found\n" |
|---|
| 918 | unless -f "$kernel_root/Rules.make"; |
|---|
| 919 | |
|---|
| 920 | # --> Read FILES |
|---|
| 921 | open INPUT, "$package_root/mkpatch/FILES" |
|---|
| 922 | or die "Can't open `$package_root/mkpatch/FILES'"; |
|---|
| 923 | while (<INPUT>) { |
|---|
| 924 | ($data0,$data1) = /(\S+)\s+(\S+)/; |
|---|
| 925 | $files{$data0} = $data1; |
|---|
| 926 | } |
|---|
| 927 | close INPUT; |
|---|
| 928 | |
|---|
| 929 | # --> Read INCLUDES |
|---|
| 930 | open INPUT, "$package_root/mkpatch/INCLUDES" |
|---|
| 931 | or die "Can't open `$package_root/mkpatch/INCLUDES'"; |
|---|
| 932 | while (<INPUT>) { |
|---|
| 933 | ($data0,$data1) = /(\S+)\s+(\S+)/; |
|---|
| 934 | $includes{$data0} = $data1; |
|---|
| 935 | $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; '; |
|---|
| 936 | } |
|---|
| 937 | close INPUT; |
|---|
| 938 | |
|---|
| 939 | die "First apply the i2c patches to `$kernel_root'!" |
|---|
| 940 | if ! -d "$kernel_root/drivers/i2c"; |
|---|
| 941 | |
|---|
| 942 | # --> Read "version.h" |
|---|
| 943 | open INPUT, "$package_root/version.h" |
|---|
| 944 | or die "Can't open `$package_root/version.h'"; |
|---|
| 945 | $version_string .= $_ while <INPUT>; |
|---|
| 946 | close INPUT; |
|---|
| 947 | |
|---|
| 948 | # --> Start generating |
|---|
| 949 | foreach $package_file (sort keys %files) { |
|---|
| 950 | open INPUT,"$package_root/$package_file" |
|---|
| 951 | or die "Can't open `$package_root/$package_file'"; |
|---|
| 952 | open OUTPUT,">$package_root/$temp" |
|---|
| 953 | or die "Can't open `$package_root/$temp'"; |
|---|
| 954 | while (<INPUT>) { |
|---|
| 955 | eval $sedscript; |
|---|
| 956 | if (m@#\s*include\s*"version.h"@) { |
|---|
| 957 | print OUTPUT $version_string; |
|---|
| 958 | } else { |
|---|
| 959 | print OUTPUT; |
|---|
| 960 | } |
|---|
| 961 | } |
|---|
| 962 | close INPUT; |
|---|
| 963 | close OUTPUT; |
|---|
| 964 | |
|---|
| 965 | $kernel_file = $files{$package_file}; |
|---|
| 966 | print_diff $package_root,$kernel_root,$kernel_file,$temp; |
|---|
| 967 | } |
|---|
| 968 | |
|---|
| 969 | gen_Makefile $package_root, $kernel_root; |
|---|
| 970 | gen_drivers_Makefile $package_root, $kernel_root; |
|---|
| 971 | gen_drivers_sensors_Makefile $package_root, $kernel_root; |
|---|
| 972 | gen_drivers_char_Config_in $package_root, $kernel_root; |
|---|
| 973 | gen_drivers_char_mem_c $package_root, $kernel_root; |
|---|
| 974 | gen_drivers_i2c_Config_in $package_root, $kernel_root; |
|---|
| 975 | gen_drivers_i2c_Makefile $package_root, $kernel_root; |
|---|
| 976 | gen_drivers_i2c_i2c_core_c $package_root, $kernel_root; |
|---|
| 977 | gen_Documentation_Configure_help $package_root, $kernel_root; |
|---|
| 978 | gen_MAINTAINERS $package_root, $kernel_root; |
|---|
| 979 | } |
|---|
| 980 | |
|---|
| 981 | main; |
|---|
| 982 | |
|---|