source: trunk/packages/xen-common/xen-common/buildconfigs/Rules.mk @ 77

Last change on this file since 77 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

File size: 4.0 KB
Line 
1
2include Config.mk
3
4export DESTDIR
5
6# Choose the best mirror to download linux kernel
7KERNEL_REPO = http://www.kernel.org
8
9ALLKERNELS = $(patsubst buildconfigs/mk.%,%,$(wildcard buildconfigs/mk.*))
10ALLSPARSETREES = $(patsubst %-xen-sparse,%,$(wildcard *-xen-sparse))
11
12# Setup pristine search path
13PRISTINE_SRC_PATH       ?= .:..
14vpath pristine-% $(PRISTINE_SRC_PATH)
15
16# Let XEN_TARGET_ARCH override ARCH.
17ifeq ($(XEN_TARGET_ARCH),x86_32)
18LINUX_ARCH      ?= i386
19else
20LINUX_ARCH      ?= $(XEN_TARGET_ARCH)
21endif
22
23# Expand Linux series to Linux version
24LINUX_SERIES    ?= 2.6
25LINUX_VER       ?= $(shell grep "^LINUX_VER " buildconfigs/mk.linux-2.6-xen | sed -e 's/.*=[ ]*//')
26
27# Setup Linux search path
28LINUX_SRC_PATH  ?= .:..
29vpath linux-%.tar.bz2 $(LINUX_SRC_PATH)
30vpath patch-%.bz2 $(LINUX_SRC_PATH)
31
32# download a pristine Linux kernel tarball if there isn't one in LINUX_SRC_PATH
33linux-%.tar.bz2: override _LINUX_VDIR = $(word 1,$(subst ., ,$*)).$(word 2,$(subst ., ,$*))
34linux-%.tar.bz2:
35        @echo "Cannot find $@ in path $(LINUX_SRC_PATH)"
36        wget $(KERNEL_REPO)/pub/linux/kernel/v$(_LINUX_VDIR)/$@ -O./$@
37
38patch-%.bz2: override _LINUX_VDIR = $(word 1,$(subst ., ,$(*F))).$(word 2,$(subst ., ,$(*F)))
39patch-%.bz2: override _LINUX_XDIR = $(if $(word 3,$(subst -, ,$(*F))),snapshots,testing)
40patch-%.bz2:
41        @echo "Cannot find $(@F) in path $(LINUX_SRC_PATH)"
42        wget $(KERNEL_REPO)/pub/linux/kernel/v$(_LINUX_VDIR)/$(_LINUX_XDIR)/$(@F) -O./$@
43
44pristine-%: pristine-%/.valid-pristine
45        @true
46
47pristine-%/.valid-pristine: %.tar.bz2
48        rm -rf tmp-pristine-$* $(@D)
49        mkdir -p tmp-pristine-$*
50        tar -C tmp-pristine-$* -jxf $<
51        -@rm -f tmp-pristine-$*/pax_global_header
52        mv tmp-pristine-$*/* $(@D)
53        @rm -rf tmp-pristine-$*
54        touch $(@D)/.hgskip
55        touch $@ # update timestamp to avoid rebuild
56
57PATCHDIRS := $(wildcard patches/*-*)
58
59ifneq ($(PATCHDIRS),)
60-include $(patsubst %,%/.makedep,$(PATCHDIRS))
61
62$(patsubst patches/%,patches/%/.makedep,$(PATCHDIRS)): patches/%/.makedep:
63        @echo 'ref-$*/.valid-ref: $$(wildcard patches/$*/*.patch)' >$@
64
65ref-%/.valid-ref: pristine-%/.valid-pristine
66        set -e
67        rm -rf $(@D)
68        cp -al $(<D) $(@D)
69        if [ -d patches/$* ] ; then                                    \
70            echo Applying patches from patches/$*... ;                 \
71            for i in $$(cat patches/$*/series) ; do                    \
72                echo ... $$i ;                                         \
73                patch -d $(@D) -p1 --quiet <patches/$*/$$i || exit 1 ; \
74             done ;                                                    \
75        fi
76        touch $@ # update timestamp to avoid rebuild
77endif
78
79%-install:
80        $(MAKE) -f buildconfigs/mk.$* build
81
82%-dist: DESTDIR=$(DISTDIR)/install
83%-dist: %-install
84        @: # do nothing
85
86# Legacy dist target
87%-build: %-dist
88        @: # do nothing
89
90%-prep: DESTDIR=$(DISTDIR)/install
91%-prep:
92        $(MAKE) -f buildconfigs/mk.$* prep
93
94%-config: DESTDIR=$(DISTDIR)/install
95%-config:
96        $(MAKE) -f buildconfigs/mk.$* config
97
98%-delete:
99        $(MAKE) -f buildconfigs/mk.$* delete
100
101%-clean:
102        $(MAKE) -f buildconfigs/mk.$* clean
103
104linux-2.6-xen.patch: ref-linux-$(LINUX_VER)/.valid-ref
105        rm -rf tmp-$@
106        cp -al $(<D) tmp-$@
107        ( cd linux-2.6-xen-sparse && bash ./mkbuildtree ../tmp-$@ )     
108        diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true
109        rm -rf tmp-$@
110
111%-xen.patch: ref-%/.valid-ref
112        rm -rf tmp-$@
113        cp -al $(<D) tmp-$@
114        ( cd $*-xen-sparse && bash ./mkbuildtree ../tmp-$@ )   
115        diff -Nurp $(patsubst ref%,pristine%,$(<D)) tmp-$@ > $@ || true
116        rm -rf tmp-$@
117
118%-mrproper:
119        $(MAKE) -f buildconfigs/mk.$*-xen mrpropper
120        rm -rf pristine-$(*)* ref-$(*)*
121        rm -rf $*-xen.patch
122
123.PHONY: config-update-pae
124config-update-pae:
125ifeq ($(XEN_TARGET_X86_PAE),y)
126        sed -e 's!^CONFIG_HIGHMEM4G=y$$!\# CONFIG_HIGHMEM4G is not set!;s!^\# CONFIG_HIGHMEM64G is not set$$!CONFIG_HIGHMEM64G=y!' $(CONFIG_FILE) > $(CONFIG_FILE)- && mv $(CONFIG_FILE)- $(CONFIG_FILE)
127else
128        grep '^CONFIG_HIGHMEM64G=y' $(CONFIG_FILE) >/dev/null && ( sed -e 's!^CONFIG_HIGHMEM64G=y$$!\# CONFIG_HIGHMEM64G is not set!;s!^\# CONFIG_HIGHMEM4G is not set$$!CONFIG_HIGHMEM4G=y!' $(CONFIG_FILE) > $(CONFIG_FILE)- && mv $(CONFIG_FILE)- $(CONFIG_FILE) ) || true
129endif
130
131# never delete any intermediate files.
132.SECONDARY:
Note: See TracBrowser for help on using the repository browser.