| 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 | # Forward declaration |
|---|
| 26 | sub gen_drivers_char_Makefile; |
|---|
| 27 | |
|---|
| 28 | # Generate a diff between the old kernel file and the new I2C file. We |
|---|
| 29 | # arrange the headers to tell us the old tree was under directory |
|---|
| 30 | # `linux-old', and the new tree under `linux'. |
|---|
| 31 | # $_[0]: i2c package root (like /tmp/i2c) |
|---|
| 32 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 33 | # $_[2]: Name of the kernel file |
|---|
| 34 | # $_[3]: Name of the patched file |
|---|
| 35 | sub print_diff |
|---|
| 36 | { |
|---|
| 37 | my ($package_root,$kernel_root,$kernel_file,$package_file) = @_; |
|---|
| 38 | my ($diff_command,$dummy); |
|---|
| 39 | |
|---|
| 40 | $diff_command = "diff -u"; |
|---|
| 41 | $diff_command .= " $kernel_root/$kernel_file "; |
|---|
| 42 | $diff_command .= " $package_root/$package_file "; |
|---|
| 43 | open INPUT, "$diff_command|" or die "Can't call `$diff_command'"; |
|---|
| 44 | if (<INPUT>) { |
|---|
| 45 | print "--- linux-old/$kernel_file\t".`date`; |
|---|
| 46 | } |
|---|
| 47 | if (<INPUT>) { |
|---|
| 48 | print "+++ linux/$kernel_file\t".`date`; |
|---|
| 49 | } |
|---|
| 50 | while (<INPUT>) { |
|---|
| 51 | print; |
|---|
| 52 | } |
|---|
| 53 | close INPUT; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | |
|---|
| 57 | # This generates diffs for kernel file Documentation/Configure.help. This |
|---|
| 58 | # file contains the help texts that can be displayed during `make *config' |
|---|
| 59 | # for the kernel. |
|---|
| 60 | # The new texts are put at the end of the file, or just before the |
|---|
| 61 | # lm_sensors texts. |
|---|
| 62 | # Of course, care is taken old lines are removed. |
|---|
| 63 | # $_[0]: i2c package root (like /tmp/i2c) |
|---|
| 64 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 65 | sub gen_Documentation_Configure_help |
|---|
| 66 | { |
|---|
| 67 | my ($package_root,$kernel_root) = @_; |
|---|
| 68 | my $kernel_file = "Documentation/Configure.help"; |
|---|
| 69 | my $package_file = $temp; |
|---|
| 70 | my $printed = 0; |
|---|
| 71 | |
|---|
| 72 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 73 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 74 | open OUTPUT,">$package_root/$package_file" |
|---|
| 75 | or die "Can't open $package_root/$package_file"; |
|---|
| 76 | MAIN: while(<INPUT>) { |
|---|
| 77 | if (m@^I2C support$@ or m@^I2C bit-banging interfaces@ or |
|---|
| 78 | m@^Philips style parallel port adapter@ or |
|---|
| 79 | m@^ELV adapter@ or m@^Velleman K9000 adapter@ or |
|---|
| 80 | m@^I2C PCF 8584 interfaces@ or m@^Elektor ISA card@ or |
|---|
| 81 | m@^I2C device interface@ or |
|---|
| 82 | m@^I2C /proc interface \(required for hardware sensors\)@) { |
|---|
| 83 | $_ = <INPUT>; |
|---|
| 84 | $_ = <INPUT>; |
|---|
| 85 | $_ = <INPUT> while not m@^\S@ and not eof(INPUT); |
|---|
| 86 | redo MAIN; |
|---|
| 87 | } |
|---|
| 88 | if (not $printed and (eof(INPUT) or m@I2C mainboard interfaces@ or |
|---|
| 89 | m@A couple of things I keep forgetting@ or |
|---|
| 90 | m@Bus Mouse Support@)) { |
|---|
| 91 | print OUTPUT <<'EOF'; |
|---|
| 92 | I2C support |
|---|
| 93 | CONFIG_I2C |
|---|
| 94 | I2C (pronounce: I-square-C) is a slow serial bus protocol used in |
|---|
| 95 | many micro controller applications and developed by Philips. SMBus, |
|---|
| 96 | or System Management Bus is a subset of the I2C protocol. More |
|---|
| 97 | information is contained in the directory <file:Documentation/i2c/>, |
|---|
| 98 | especially in the file called "summary" there. |
|---|
| 99 | |
|---|
| 100 | Both I2C and SMBus are supported here. You will need this for |
|---|
| 101 | hardware sensors support, and also for Video For Linux support. |
|---|
| 102 | Specifically, if you want to use a BT848 based frame grabber/overlay |
|---|
| 103 | boards under Linux, say Y here and also to "I2C bit-banging |
|---|
| 104 | interfaces", below. |
|---|
| 105 | |
|---|
| 106 | If you want I2C support, you should say Y here and also to the |
|---|
| 107 | specific driver for your bus adapter(s) below. If you say Y to |
|---|
| 108 | "/proc file system" below, you will then get a /proc interface which |
|---|
| 109 | is documented in <file:Documentation/i2c/proc-interface>. |
|---|
| 110 | |
|---|
| 111 | This I2C support is also available as a module. If you want to |
|---|
| 112 | compile it as a module, say M here and read |
|---|
| 113 | <file:Documentation/modules.txt>. |
|---|
| 114 | The module will be called i2c-core.o. |
|---|
| 115 | |
|---|
| 116 | I2C bit-banging interfaces |
|---|
| 117 | CONFIG_I2C_ALGOBIT |
|---|
| 118 | This allows you to use a range of I2C adapters called bit-banging |
|---|
| 119 | adapters. Say Y if you own an I2C adapter belonging to this class |
|---|
| 120 | and then say Y to the specific driver for you adapter below. |
|---|
| 121 | |
|---|
| 122 | This support is also available as a module. If you want to compile |
|---|
| 123 | it as a module, say M here and read |
|---|
| 124 | <file:Documentation/modules.txt>. |
|---|
| 125 | The module will be called i2c-algo-bit.o. |
|---|
| 126 | |
|---|
| 127 | Philips style parallel port adapter |
|---|
| 128 | CONFIG_I2C_PHILIPSPAR |
|---|
| 129 | This supports parallel-port I2C adapters made by Philips. Say Y if |
|---|
| 130 | you own such an adapter. |
|---|
| 131 | |
|---|
| 132 | This driver is also available as a module. If you want to compile |
|---|
| 133 | it as a module, say M here and read |
|---|
| 134 | <file:Documentation/modules.txt>. |
|---|
| 135 | The module will be called i2c-philips-par.o. |
|---|
| 136 | |
|---|
| 137 | Note that if you want support for different parallel port devices, |
|---|
| 138 | life will be much easier if you compile them all as modules. |
|---|
| 139 | |
|---|
| 140 | ELV adapter |
|---|
| 141 | CONFIG_I2C_ELV |
|---|
| 142 | This supports parallel-port I2C adapters called ELV. Say Y if you |
|---|
| 143 | own such an adapter. |
|---|
| 144 | |
|---|
| 145 | This driver is also available as a module. If you want to compile |
|---|
| 146 | it as a module, say M here and read |
|---|
| 147 | <file:Documentation/modules.txt>. |
|---|
| 148 | The module will be called i2c-elv.o. |
|---|
| 149 | |
|---|
| 150 | Velleman K9000 adapter |
|---|
| 151 | CONFIG_I2C_VELLEMAN |
|---|
| 152 | This supports the Velleman K9000 parallel-port I2C adapter. Say Y |
|---|
| 153 | if you own such an adapter. |
|---|
| 154 | |
|---|
| 155 | This driver is also available as a module. If you want to compile |
|---|
| 156 | it as a module, say M here and read |
|---|
| 157 | <file:Documentation/modules.txt>. |
|---|
| 158 | The module will be called i2c-velleman.o. |
|---|
| 159 | |
|---|
| 160 | Basic I2C on Parallel Port adapter |
|---|
| 161 | CONFIG_I2C_PPORT |
|---|
| 162 | This supports directly connecting I2C devices to the parallel port. |
|---|
| 163 | See <file:Documentation/i2c/i2c-pport> for more information. |
|---|
| 164 | |
|---|
| 165 | This driver is also available as a module. If you want to compile |
|---|
| 166 | it as a module, say M here and read |
|---|
| 167 | <file:Documentation/modules.txt>. |
|---|
| 168 | The module will be called i2c-pport.o. |
|---|
| 169 | |
|---|
| 170 | I2C PCF 8584 interfaces |
|---|
| 171 | CONFIG_I2C_ALGOPCF |
|---|
| 172 | This allows you to use a range of I2C adapters called PCF adapters. |
|---|
| 173 | Say Y if you own an I2C adapter belonging to this class and then say |
|---|
| 174 | Y to the specific driver for you adapter below. |
|---|
| 175 | |
|---|
| 176 | This support is also available as a module. If you want to compile |
|---|
| 177 | it as a module, say M here and read |
|---|
| 178 | <file:Documentation/modules.txt>. |
|---|
| 179 | The module will be called i2c-algo-pcf.o. |
|---|
| 180 | |
|---|
| 181 | Elektor ISA card |
|---|
| 182 | CONFIG_I2C_ELEKTOR |
|---|
| 183 | This supports the PCF8584 ISA bus I2C adapter. Say Y if you own |
|---|
| 184 | such an adapter. |
|---|
| 185 | |
|---|
| 186 | This driver is also available as a module. If you want to compile |
|---|
| 187 | it as a module, say M here and read |
|---|
| 188 | <file:Documentation/modules.txt>. |
|---|
| 189 | The module will be called i2c-elektor.o. |
|---|
| 190 | |
|---|
| 191 | PCF on the EPP Parallel Port |
|---|
| 192 | CONFIG_I2C_PCFEPP |
|---|
| 193 | This supports the PCF8584 connected to the parallel port. |
|---|
| 194 | |
|---|
| 195 | This driver is also available as a module. If you want to compile |
|---|
| 196 | it as a module, say M here and read |
|---|
| 197 | <file:Documentation/modules.txt>. |
|---|
| 198 | The module will be called i2c-pcf-epp.o. |
|---|
| 199 | |
|---|
| 200 | Motorola 8xx I2C algorithm |
|---|
| 201 | CONFIG_I2C_ALGO8XX |
|---|
| 202 | This is the algorithm that allows you to use Motorola 8xx I2C adapters. |
|---|
| 203 | |
|---|
| 204 | This driver is also available as a module. If you want to compile |
|---|
| 205 | it as a module, say M here and read |
|---|
| 206 | <file:Documentation/modules.txt>. |
|---|
| 207 | The module will be called i2c-algo-8xx.o. |
|---|
| 208 | |
|---|
| 209 | Motorola 8xx I2C interface |
|---|
| 210 | CONFIG_I2C_RPXLITE |
|---|
| 211 | This supports the Motorola 8xx I2C device. |
|---|
| 212 | |
|---|
| 213 | This driver is also available as a module. If you want to compile |
|---|
| 214 | it as a module, say M here and read |
|---|
| 215 | <file:Documentation/modules.txt>. |
|---|
| 216 | The module will be called i2c-rpx.o. |
|---|
| 217 | |
|---|
| 218 | IBM 405 I2C algorithm |
|---|
| 219 | CONFIG_I2C_IBM_OCP_ALGO |
|---|
| 220 | This is the algorithm that allows you to use IBM 405 I2C adapters. |
|---|
| 221 | |
|---|
| 222 | This driver is also available as a module. If you want to compile |
|---|
| 223 | it as a module, say M here and read |
|---|
| 224 | <file:Documentation/modules.txt>. |
|---|
| 225 | The module will be called i2c-algo-ibm_ocp.o. |
|---|
| 226 | |
|---|
| 227 | IBM 405 I2C interface |
|---|
| 228 | CONFIG_I2C_IBM_OCP_ADAP |
|---|
| 229 | This supports the IBM 405 I2C device. |
|---|
| 230 | |
|---|
| 231 | This driver is also available as a module. If you want to compile |
|---|
| 232 | it as a module, say M here and read |
|---|
| 233 | <file:Documentation/modules.txt>. |
|---|
| 234 | The module will be called i2c-adap-ibm_ocp.o. |
|---|
| 235 | |
|---|
| 236 | StrongARM SA-1110 interface |
|---|
| 237 | CONFIG_I2C_FRODO |
|---|
| 238 | This supports the StrongARM SA-1110 Development Board. |
|---|
| 239 | |
|---|
| 240 | This driver is also available as a module. If you want to compile |
|---|
| 241 | it as a module, say M here and read |
|---|
| 242 | <file:Documentation/modules.txt>. |
|---|
| 243 | The module will be called i2c-frodo.o. |
|---|
| 244 | |
|---|
| 245 | I2C device interface |
|---|
| 246 | CONFIG_I2C_CHARDEV |
|---|
| 247 | Say Y here to use i2c-* device files, usually found in the /dev |
|---|
| 248 | directory on your system. They make it possible to have user-space |
|---|
| 249 | programs use the I2C bus. Information on how to do this is |
|---|
| 250 | contained in the file <file:Documentation/i2c/dev-interface>. |
|---|
| 251 | |
|---|
| 252 | This code is also available as a module. If you want to compile |
|---|
| 253 | it as a module, say M here and read |
|---|
| 254 | <file:Documentation/modules.txt>. |
|---|
| 255 | The module will be called i2c-dev.o. |
|---|
| 256 | |
|---|
| 257 | I2C /proc interface (required for hardware sensors) |
|---|
| 258 | CONFIG_I2C_PROC |
|---|
| 259 | This provides support for i2c device entries in the /proc filesystem. |
|---|
| 260 | The entries will be found in /proc/sys/dev/sensors. |
|---|
| 261 | |
|---|
| 262 | This code is also available as a module. If you want to compile |
|---|
| 263 | it as a module, say M here and read <file:Documentation/modules.txt>. |
|---|
| 264 | The module will be called i2c-proc.o. |
|---|
| 265 | |
|---|
| 266 | EOF |
|---|
| 267 | $printed = 1; |
|---|
| 268 | } |
|---|
| 269 | print OUTPUT; |
|---|
| 270 | } |
|---|
| 271 | close INPUT; |
|---|
| 272 | close OUTPUT; |
|---|
| 273 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 274 | } |
|---|
| 275 | |
|---|
| 276 | # This generates diffs for drivers/Makefile |
|---|
| 277 | # $_[0]: i2c package root (like /tmp/i2c) |
|---|
| 278 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 279 | sub gen_drivers_Makefile |
|---|
| 280 | { |
|---|
| 281 | my ($package_root,$kernel_root) = @_; |
|---|
| 282 | my $kernel_file = "drivers/Makefile"; |
|---|
| 283 | my $package_file = $temp; |
|---|
| 284 | my $i2c_present; |
|---|
| 285 | my $printed = 0; |
|---|
| 286 | my $added = 0; |
|---|
| 287 | |
|---|
| 288 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 289 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 290 | open OUTPUT,">$package_root/$package_file" |
|---|
| 291 | or die "Can't open $package_root/$package_file"; |
|---|
| 292 | MAIN: while(<INPUT>) { |
|---|
| 293 | if (m@^ifeq.*CONFIG_I2C@) { |
|---|
| 294 | $_ = <INPUT> while not m@^endif@; |
|---|
| 295 | $_ = <INPUT>; |
|---|
| 296 | $_ = <INPUT> if m@^$@; |
|---|
| 297 | redo MAIN; |
|---|
| 298 | } |
|---|
| 299 | if (m@^subdir.*CONFIG_I2C@) { |
|---|
| 300 | $_ = <INPUT>; |
|---|
| 301 | redo MAIN; |
|---|
| 302 | } |
|---|
| 303 | if (not $printed and |
|---|
| 304 | (m@^ifeq \(\$\(CONFIG_ACPI\),y\)$@ or |
|---|
| 305 | m@^ifeq \(\$\(CONFIG_SENSORS\),y\)@) or |
|---|
| 306 | m@^subdir-\$\(CONFIG_ACPI\)@) { |
|---|
| 307 | print OUTPUT <<'EOF'; |
|---|
| 308 | subdir-$(CONFIG_I2C) += i2c |
|---|
| 309 | EOF |
|---|
| 310 | $printed = 1; |
|---|
| 311 | } |
|---|
| 312 | print OUTPUT; |
|---|
| 313 | } |
|---|
| 314 | close INPUT; |
|---|
| 315 | close OUTPUT; |
|---|
| 316 | die "Automatic patch generation for `drivers/Makefile' failed.\n". |
|---|
| 317 | "See our home page http://www.lm-sensors.nu for assistance!" if $printed == 0 or $added == 0; |
|---|
| 318 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 319 | } |
|---|
| 320 | |
|---|
| 321 | |
|---|
| 322 | # This generates diffs for drivers/i2c/Makefile |
|---|
| 323 | sub gen_drivers_i2c_Makefile |
|---|
| 324 | { |
|---|
| 325 | my ($package_root,$kernel_root) = @_; |
|---|
| 326 | my $kernel_file = "drivers/i2c/Makefile"; |
|---|
| 327 | my $package_file = $temp; |
|---|
| 328 | my $use_new_format = 0; |
|---|
| 329 | |
|---|
| 330 | open OUTPUT,">$package_root/$package_file" |
|---|
| 331 | or die "Can't open $package_root/$package_file"; |
|---|
| 332 | print OUTPUT <<'EOF'; |
|---|
| 333 | # |
|---|
| 334 | # Makefile for the kernel i2c bus driver. |
|---|
| 335 | # |
|---|
| 336 | |
|---|
| 337 | O_TARGET := i2c.o |
|---|
| 338 | |
|---|
| 339 | export-objs := i2c-core.o i2c-algo-bit.o i2c-algo-pcf.o \ |
|---|
| 340 | i2c-algo-8xx.o i2c-proc.o i2c-algo-ibm_ocp.o |
|---|
| 341 | |
|---|
| 342 | obj-$(CONFIG_I2C) += i2c-core.o |
|---|
| 343 | obj-$(CONFIG_I2C_CHARDEV) += i2c-dev.o |
|---|
| 344 | obj-$(CONFIG_I2C_ALGOBIT) += i2c-algo-bit.o |
|---|
| 345 | obj-$(CONFIG_I2C_PHILIPSPAR) += i2c-philips-par.o |
|---|
| 346 | obj-$(CONFIG_I2C_ELV) += i2c-elv.o |
|---|
| 347 | obj-$(CONFIG_I2C_VELLEMAN) += i2c-velleman.o |
|---|
| 348 | obj-$(CONFIG_I2C_PPORT) += i2c-pport.o |
|---|
| 349 | obj-$(CONFIG_I2C_ALGOPCF) += i2c-algo-pcf.o |
|---|
| 350 | obj-$(CONFIG_I2C_ELEKTOR) += i2c-elektor.o |
|---|
| 351 | obj-$(CONFIG_I2C_PCFEPP) += i2c-pcf-epp.o |
|---|
| 352 | obj-$(CONFIG_I2C_PROC) += i2c-proc.o |
|---|
| 353 | obj-$(CONFIG_I2C_ALGO8XX) += i2c-algo-8xx.o |
|---|
| 354 | obj-$(CONFIG_I2C_RPXLITE) += i2c-rpx.o |
|---|
| 355 | obj-$(CONFIG_I2C_IBM_OCP_ALGO) += i2c-algo-ibm_ocp.o |
|---|
| 356 | obj-$(CONFIG_I2C_IBM_OCP_ADAP) += i2c-adap-ibm_ocp.o |
|---|
| 357 | obj-$(CONFIG_I2C_FRODO) += i2c-frodo.o |
|---|
| 358 | |
|---|
| 359 | EOF |
|---|
| 360 | |
|---|
| 361 | close OUTPUT; |
|---|
| 362 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 363 | } |
|---|
| 364 | |
|---|
| 365 | |
|---|
| 366 | # Generate the diffs for the list of MAINTAINERS |
|---|
| 367 | # $_[0]: i2c package root (like /tmp/i2c) |
|---|
| 368 | # $_[1]: Linux kernel tree (like /usr/src/linux) |
|---|
| 369 | sub gen_MAINTAINERS |
|---|
| 370 | { |
|---|
| 371 | my ($package_root,$kernel_root) = @_; |
|---|
| 372 | my $kernel_file = "MAINTAINERS"; |
|---|
| 373 | my $package_file = $temp; |
|---|
| 374 | my $done = 0; |
|---|
| 375 | |
|---|
| 376 | open INPUT,"$kernel_root/$kernel_file" |
|---|
| 377 | or die "Can't open `$kernel_root/$kernel_file'"; |
|---|
| 378 | open OUTPUT,">$package_root/$package_file" |
|---|
| 379 | or die "Can't open $package_root/$package_file"; |
|---|
| 380 | MAIN: while(<INPUT>) { |
|---|
| 381 | if (m@I2C DRIVERS@) { |
|---|
| 382 | $_=<INPUT> while not m@^$@; |
|---|
| 383 | $_=<INPUT>; |
|---|
| 384 | redo MAIN; |
|---|
| 385 | } |
|---|
| 386 | if (not $done and (m@i386 BOOT CODE@ or m@IBM MCA SCSI SUBSYSTEM DRIVER@)) { |
|---|
| 387 | print OUTPUT <<'EOF'; |
|---|
| 388 | I2C DRIVERS |
|---|
| 389 | P: Simon Vogl |
|---|
| 390 | M: simon@tk.uni-linz.ac.at |
|---|
| 391 | P: Frodo Looijaard |
|---|
| 392 | M: frodol@dds.nl |
|---|
| 393 | L: linux-i2c@pelican.tk.uni-linz.ac.at |
|---|
| 394 | W: http://www.tk.uni-linz.ac.at/~simon/private/i2c |
|---|
| 395 | S: Maintained |
|---|
| 396 | |
|---|
| 397 | EOF |
|---|
| 398 | $done = 1; |
|---|
| 399 | } |
|---|
| 400 | print OUTPUT; |
|---|
| 401 | } |
|---|
| 402 | close INPUT; |
|---|
| 403 | close OUTPUT; |
|---|
| 404 | die "Automatic patch generation for `MAINTAINERS' failed.\n". |
|---|
| 405 | "See our home page http://www.lm-sensors.nu for assistance!" if $done == 0; |
|---|
| 406 | print_diff $package_root,$kernel_root,$kernel_file,$package_file; |
|---|
| 407 | } |
|---|
| 408 | |
|---|
| 409 | # Main function |
|---|
| 410 | sub main |
|---|
| 411 | { |
|---|
| 412 | my ($package_root,$kernel_root,%files,%includes,$package_file,$kernel_file); |
|---|
| 413 | my ($diff_command,$dummy,$data0,$data1,$sedscript,@sensors_subs); |
|---|
| 414 | |
|---|
| 415 | # --> Read the command-line |
|---|
| 416 | $package_root = $ARGV[0]; |
|---|
| 417 | die "Package root `$package_root' is not found\n" |
|---|
| 418 | unless -d "$package_root/mkpatch"; |
|---|
| 419 | $kernel_root = $ARGV[1]; |
|---|
| 420 | |
|---|
| 421 | # --> Read FILES |
|---|
| 422 | open INPUT, "$package_root/mkpatch/FILES" |
|---|
| 423 | or die "Can't open `$package_root/mkpatch/FILES'"; |
|---|
| 424 | while (<INPUT>) { |
|---|
| 425 | ($data0,$data1) = /(\S+)\s+(\S+)/; |
|---|
| 426 | $files{$data0} = $data1; |
|---|
| 427 | } |
|---|
| 428 | close INPUT; |
|---|
| 429 | |
|---|
| 430 | # --> Read INCLUDES |
|---|
| 431 | open INPUT, "$package_root/mkpatch/INCLUDES" |
|---|
| 432 | or die "Can't open `$package_root/mkpatch/INCLUDES'"; |
|---|
| 433 | while (<INPUT>) { |
|---|
| 434 | ($data0,$data1) = /(\S+)\s+(\S+)/; |
|---|
| 435 | $includes{$data0} = $data1; |
|---|
| 436 | $sedscript .= 's,(#\s*include\s*)'.$data0.'(\s*),\1'."$data1".'\2, ; '; |
|---|
| 437 | } |
|---|
| 438 | close INPUT; |
|---|
| 439 | |
|---|
| 440 | # --> Start generating |
|---|
| 441 | foreach $package_file (sort keys %files) { |
|---|
| 442 | $kernel_file = $files{$package_file}; |
|---|
| 443 | open INPUT, "$package_root/$package_file" |
|---|
| 444 | or die "Can't open `$package_root/$package_file'"; |
|---|
| 445 | open OUTPUT, ">$package_root/$temp" |
|---|
| 446 | or die "Can't open `$package_root/$temp'"; |
|---|
| 447 | while (<INPUT>) { |
|---|
| 448 | eval $sedscript; |
|---|
| 449 | print OUTPUT; |
|---|
| 450 | } |
|---|
| 451 | close INPUT; |
|---|
| 452 | close OUTPUT; |
|---|
| 453 | print_diff "$package_root","$kernel_root","$kernel_file","$temp"; |
|---|
| 454 | } |
|---|
| 455 | |
|---|
| 456 | # gen_Makefile $package_root, $kernel_root; |
|---|
| 457 | # gen_drivers_Makefile $package_root, $kernel_root; |
|---|
| 458 | # gen_drivers_i2c_Makefile $package_root, $kernel_root; |
|---|
| 459 | # gen_Documentation_Configure_help $package_root, $kernel_root; |
|---|
| 460 | } |
|---|
| 461 | |
|---|
| 462 | main; |
|---|
| 463 | |
|---|