aboutsummaryrefslogtreecommitdiffstats
path: root/buildconfigs/Rules.mk
diff options
context:
space:
mode:
Diffstat (limited to 'buildconfigs/Rules.mk')
-rw-r--r--buildconfigs/Rules.mk64
1 files changed, 64 insertions, 0 deletions
diff --git a/buildconfigs/Rules.mk b/buildconfigs/Rules.mk
new file mode 100644
index 0000000000..6f1caf7d67
--- /dev/null
+++ b/buildconfigs/Rules.mk
@@ -0,0 +1,64 @@
+
+LINUX_26VER ?= $(shell ( /bin/ls -ld linux-2.6.*-xen-sparse ) \
+ 2>/dev/null | sed -e 's!^.*linux-\(.\+\)-xen-sparse!\1!' )
+
+LINUX_24VER ?= $(shell ( /bin/ls -ld linux-2.4.*-xen-sparse ) \
+ 2>/dev/null | sed -e 's!^.*linux-\(.\+\)-xen-sparse!\1!' )
+
+LINUX_SRC_PATH ?= .:..
+
+LINUX_26SRC ?= $(firstword $(foreach dir,$(subst :, ,$(LINUX_SRC_PATH)),\
+ $(wildcard $(dir)/linux-$(LINUX_26VER).tar.*z*)))
+
+LINUX_24SRC ?= $(firstword $(foreach dir,$(subst :, ,$(LINUX_SRC_PATH)),\
+ $(wildcard $(dir)/linux-$(LINUX_24VER).tar.*z*)))
+
+.PHONY: mkpatches linux-$(LINUX_24VER)-xen.patch linux-$(LINUX_26VER)-xen.patch mrproper
+
+# search for a pristine kernel tar ball, or try downloading one
+linux-$(LINUX_26VER).tar.bz2:
+ifeq ($(LINUX_26SRC),)
+ echo "Cannot find linux-$(LINUX_26VER).tar.bz2 in path $(LINUX_SRC_PATH)"
+ wget http://www.kernel.org/pub/linux/kernel/v2.6/linux-$(LINUX_26VER).tar.bz2 -O./linux-$(LINUX_26VER).tar.bz2
+LINUX_26SRC := ./linux-$(LINUX_26VER).tar.bz2
+endif
+
+pristine-linux-$(LINUX_26VER): $(LINUX_26SRC)
+ rm -rf tmp $@ && mkdir -p tmp && tar -C tmp -jxf $(LINUX_26SRC) && mv tmp/* $@
+ touch $@ # update timestamp to avoid rebuild
+
+
+# search for a pristine kernel tar ball, or try downloading one
+linux-$(LINUX_24VER).tar.bz2:
+ifeq ($(LINUX_24SRC),)
+ echo "Cannot find linux-$(LINUX_24VER).tar.bz2 in path $(LINUX_SRC_PATH)"
+ wget http://www.kernel.org/pub/linux/kernel/v2.4/linux-$(LINUX_24VER).tar.bz2 -O./linux-$(LINUX_24VER).tar.bz2
+LINUX_24SRC := ./linux-$(LINUX_24VER).tar.bz2
+endif
+
+pristine-linux-$(LINUX_24VER): $(LINUX_24SRC)
+ rm -rf tmp $@ && mkdir -p tmp && tar -C tmp -jxf $(LINUX_24SRC) && mv tmp/* $@
+ touch $@ # update timestamp to avoid rebuild
+
+linux-$(LINUX_24VER)-xen.patch: pristine-linux-$(LINUX_24VER)
+ rm -rf tmp-$@
+ cp -al pristine-linux-$(LINUX_24VER) tmp-$@
+ ( cd linux-$(LINUX_24VER)-xen-sparse ; \
+ ./mkbuildtree ../tmp-$@ )
+ diff -Nurp pristine-linux-$(LINUX_24VER) tmp-$@ > $@ || true
+ rm -rf tmp-$@
+
+linux-$(LINUX_26VER)-xen.patch: pristine-linux-$(LINUX_26VER)
+ rm -rf tmp-$@
+ cp -al pristine-linux-$(LINUX_26VER) tmp-$@
+ ( cd linux-$(LINUX_26VER)-xen-sparse ; \
+ ./mkbuildtree ../tmp-$@ )
+ diff -Nurp pristine-linux-$(LINUX_26VER) tmp-$@ > $@ || true
+ rm -rf tmp-$@
+
+mkpatches: linux-$(LINUX_24VER)-xen.patch linux-$(LINUX_26VER)-xen.patch
+
+mrproper:
+ rm -rf pristine-linux-$(LINUX_24VER) linux-$(LINUX_24VER).tar.bz2
+ rm -rf pristine-linux-$(LINUX_26VER) linux-$(LINUX_26VER).tar.bz2
+ rm -rf linux-$(LINUX_24VER)-xen.patch linux-$(LINUX_26VER)-xen.patch \ No newline at end of file