#!/usr/bin/make
#
# The compat-wireless tree is assembled in a seperate directory. Use this
# makefile to update to the latest wireless testing tree.
#

PWD=$(shell pwd)
CW_URL=git://git.kernel.org/pub/scm/linux/kernel/git/mcgrof/compat-wireless-2.6-old.git
CDIR=$(PWD)/../../compat-wireless
CW=compat-wireless-2.6-old
LCW=compat-wireless-2.6
CWDIR=$(CDIR)/$(CW)

all: update-compat-wireless
	sed -i 's/#define.*IWL4965_UCODE_API.*"-2"/#define IWL4965_UCODE_API "-2-lbm"/' `find $(CWDIR)/drivers/net/wireless/iwlwifi -type f`
	sed -i 's/#define.*IWL3945_UCODE_API.*"-1"/#define IWL3945_UCODE_API "-1-lbm"/' `find $(CWDIR)/drivers/net/wireless/iwlwifi -type f`
	sed -i 's/#define.*IWL5000_UCODE_API.*"-1"/#define IWL5000_UCODE_API "-1-lbm"/' `find $(CWDIR)/drivers/net/wireless/iwlwifi -type f`
	rsync -av --delete --exclude=.git $(CWDIR)/ $(LCW)
	find $(LCW) | egrep "\.git*" | xargs rm -rvf
	find  $(LCW) -name "*.orig" | xargs rm -rvf
	#bash ./munge

$(CWDIR)/Makefile:
	mkdir -p $(CDIR)
	cd $(CDIR); rm -rf $(CW); git clone $(CW_URL)

PHONY: update-compat-wireless
update-compat-wireless: $(CWDIR)/Makefile
	cd $(CWDIR); git checkout -f; git fetch origin; git rebase origin
	touch $(CWDIR)/Makefile

clean:
	rm -rf $(CDIR)
