#! /usr/bin/perl -w

use strict;

# NOTE: this script for linux 2.4.20 & similar

# Make a patch file for a Linux kernel that adds the Grid WiFi hooks,
# modifies the airo driver to work with the hooks, and adds a modified
# hostap driver that works with the extensions.

# The resulting output can be used thus:
#  cd /usr/src/linux
#  patch -p0 -b < patch-file

# List of files/directories that we modified and that should be patched.
# Each must be accompanied by a file.orig.
my @files = (
	     "include/linux/packet_anno.h",       # new file, must create empty .orig
	     "include/linux/click_wifi.h",        # new file
	     "drivers/net/wireless/click_wifi.c", # new file
	     "drivers/net/wireless/airo.h",       # new file 
	     "drivers/net/wireless/airo.c",
	     "drivers/net/wireless/Makefile",
	     "drivers/net/wireless/Config.in",
	     "drivers/net/wireless/hostap_ap.c",  # all the drivers/net/wireless/hostap* files are new
	     "drivers/net/wireless/hostap_ap.h",
	     "drivers/net/wireless/hostap.c",
	     "drivers/net/wireless/hostap_compat.h",
	     "drivers/net/wireless/hostap_config.h",
	     "drivers/net/wireless/hostap_crypt.c",
	     "drivers/net/wireless/hostap_crypt.h",
	     "drivers/net/wireless/hostap_crypt_wep.c",
	     "drivers/net/wireless/hostap_cs.c",
	     "drivers/net/wireless/hostap_download.c",
	     "drivers/net/wireless/hostap.h",
	     "drivers/net/wireless/hostap_hw.c",
	     "drivers/net/wireless/hostap_info.c",
	     "drivers/net/wireless/hostap_ioctl.c",
	     "drivers/net/wireless/hostap_pci.c",
	     "drivers/net/wireless/hostap_plx.c",
	     "drivers/net/wireless/hostap_proc.c",
	     "drivers/net/wireless/hostap_wlan.h",
	     "Documentation/Configure.help",
	     "MAINTAINERS"
             );


$| = 1;

my $f;
foreach $f (@files) {
    print "\nIndex: $f\n";

    if (!-e "${f}.orig") {
	print STDERR "${f}.orig missing, creating empty version\n";
	system "touch ${f}.orig";
    }

    system("diff -u ${f}.orig $f");
}
