merge
[linux-based-stubdoms.git] / Makefile
blob603b6a5e3c8690062adef1a1466af7d4eb7562e5
1 XEN_ROOT = $(CURDIR)/..
2 STUBDOM_ARCH = x86_32
4 #download linux kernel
5 LINUX_STUBDOM_GIT_URL ?= git://git.kernel.org/pub/scm/linux/kernel/git/jeremy/xen.git
6 LINUX_SRCDIR = linux-src-$(STUBDOM_ARCH).git
7 XEN_GIT_ORIGIN ?= xen
8 XEN_LINUX_GIT_REMOTEBRANCH ?= xen/stable-2.6.32.x
9 XEN_LINUX_GIT_LOCALBRANCH ?= $(XEN_LINUX_GIT_REMOTEBRANCH)
10 XEN_LINUX_GITREV ?= $(XEN_GIT_ORIGIN)/$(XEN_LINUX_GIT_REMOTEBRANCH)
12 #build linux-stubdom kernel
13 IMAGE_TARGET ?= bzImage
14 LINUX_DIR = build-linux-$(STUBDOM_ARCH)
15 INSTALL_PATH = install-stubdom-$(STUBDOM_ARCH)
16 LINUX_ARCH = $$(sh $(CURDIR)/select-linux-arch $(LINUX_SRCDIR) $(STUBDOM_ARCH))
18 #download upstream qemu
19 IOEMU_GIT_URL ?= git://xenbits.xen.org/people/aperard/qemu-dm.git
20 IOEMU_SRCDIR = ioemu-src-$(STUBDOM_ARCH).git
21 IOEMU_GIT_ORIGIN ?= origin
22 IOEMU_GIT_REMOTEBRANCH ?= qemu-dm-v15
23 IOEMU_GIT_LOCALBRANCH ?= $(IOEMU_GIT_REMOTEBRANCH)
24 IOEMU_GITREV ?= $(IOEMU_GIT_ORIGIN)/$(IOEMU_GIT_REMOTEBRANCH)
26 #libxl
27 LIBXL_DIR = libxl-$(STUBDOM_ARCH)
28 LIBXL_SRCDIR = $(XEN_ROOT)/tools/libxl
30 #download udev
31 UDEV_URL?= http://www.us.kernel.org/pub/linux/utils/kernel/hotplug
32 UDEV_VERSION=100
34 #build ioemu
35 IOEMU_DIR = build-ioemu-$(STUBDOM_ARCH)
37 #build qemu-wrapper
38 QEMU_WRAPPER_DIR = qemu-wrapper
39 QEMU_WRAPPER = qemu-wrapper
41 TARGETS=ioemu
43 GIT ?= git
45 WGET=wget -c
47 .PHONY: all
48 all: ioemu-stubdom
50 ######################
51 # download source code
52 ######################
54 .PHONY: download-linux-src
55 download-linux-src:
56 if ! [ -d $(LINUX_SRCDIR) ]; then \
57 rm -rf $(LINUX_SRCDIR) $(LINUX_SRCDIR).tmp; \
58 mkdir $(LINUX_SRCDIR).tmp; rmdir $(LINUX_SRCDIR).tmp; \
59 $(GIT) clone -o $(XEN_GIT_ORIGIN) -n $(LINUX_STUBDOM_GIT_URL) $(LINUX_SRCDIR).tmp; \
60 (cd $(LINUX_SRCDIR).tmp; git checkout -b $(XEN_LINUX_GIT_LOCALBRANCH) $(XEN_LINUX_GITREV); git checkout); \
61 mv $(LINUX_SRCDIR).tmp $(LINUX_SRCDIR); \
62 patch -d $(LINUX_SRCDIR) -p1 < linux-src.patch; \
65 .PHONY: download-ioemu-src
66 download-ioemu-src:
67 if ! [ -d $(IOEMU_SRCDIR) ]; then \
68 rm -rf $(IOEMU_SRCDIR) $(IOEMU_SRCDIR).tmp; \
69 mkdir $(IOEMU_SRCDIR).tmp; rmdir $(IOEMU_SRCDIR).tmp; \
70 $(GIT) clone -o $(IOEMU_GIT_ORIGIN) -n $(IOEMU_GIT_URL) $(IOEMU_SRCDIR).tmp; \
71 (cd $(IOEMU_SRCDIR).tmp; git checkout -b $(IOEMU_GIT_LOCALBRANCH) $(IOEMU_GITREV); git checkout);\
72 mv $(IOEMU_SRCDIR).tmp $(IOEMU_SRCDIR);\
75 ################
76 # linux-stubdom
77 ################
79 TARGETS_LINUX=$(addprefix linux-stubdom-$(STUBDOM_ARCH)-,$(TARGETS))
80 LINUX_STUBDOM_CONFIG=$(addprefix linux-config-,$(TARGETS))
81 MAKE_RAMDISK_SCRIPT=$(addprefix mk-ramdisk-,$(TARGETS))
82 $(TARGETS_LINUX):download-linux-src
83 mkdir -p $@
84 mkdir -p $@/$(LINUX_DIR)
85 mkdir -p $@/$(INSTALL_PATH)
86 if [ ! -f $@/$(LINUX_DIR)/.config ]; then \
87 cp $(LINUX_STUBDOM_CONFIG) $@/$(LINUX_DIR)/.config;\
88 $(MAKE) -C $(LINUX_SRCDIR) ARCH=$(LINUX_ARCH) oldconfig O=$$(/bin/pwd)/$@/$(LINUX_DIR);\
89 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) prepare;\
91 if grep "^CONFIG_MODULES=" $@/$(LINUX_DIR)/.config ; then \
92 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) modules || exit 1 ; \
93 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_MOD_PATH=$(CURDIR)/$@/$(INSTALL_PATH) modules_install ; \
95 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$@/$(INSTALL_PATH) $(IMAGE_TARGET)
96 @cp -v $@/$(LINUX_DIR)/arch/$(LINUX_ARCH)/boot/bzImage $@/$(INSTALL_PATH)/vmlinuz-$(TARGETS)
97 @cp -v $@/$(LINUX_DIR)/.config $@/$(INSTALL_PATH)/config-$(TARGETS)
98 @cp -v $@/$(LINUX_DIR)/System.map $@/$(INSTALL_PATH)/System.map-$(TARGETS)
100 #######
101 # ioemu
102 #######
104 linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir:
105 mkdir -p linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR)
106 set -e; \
107 cd linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR); \
108 (cd $(CURDIR)/$(IOEMU_SRCDIR) && find * -type d -print) | xargs mkdir -p; \
109 (cd $(CURDIR)/$(IOEMU_SRCDIR) && find * ! -type l -type f $(addprefix ! -name , \
110 '*.[oda1]' 'config-*' config.mak \
111 '*.html' '*.pod' \
112 )) | \
113 while read f; do rm -f "$$f"; ln -s "$(CURDIR)/$(IOEMU_SRCDIR)/$$f" "$$f"; done
114 patch -d linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR) -p1 < ioemu-stubdom.patch
115 patch -d linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR) -p1 < ioemu-fbdev.patch
116 touch linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir
118 .PHONY: ioemu
119 ioemu: download-ioemu-src linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir
120 $(warning "build upstream qemu")
121 (cd linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR); \
122 sh configure --target-list=i386-softmmu --enable-xen --enable-stubdom \
123 --extra-cflags=-I$(XEN_ROOT)/dist/install/usr/include --extra-ldflags=-L$(XEN_ROOT)/dist/install/usr/lib; \
124 $(MAKE);\
125 cp -af i386-softmmu/qemu ../$(INSTALL_PATH))
127 #######
128 # libxl
129 #######
131 .link-libxl-dir:
132 mkdir -p $(LIBXL_DIR)
133 set -e; \
134 cd $(LIBXL_DIR); \
135 (cd $(LIBXL_SRCDIR) && $(MAKE) clean);\
136 (cd $(LIBXL_SRCDIR) && find * ! -type l -type f $(addprefix ! -name , \
137 '*.[oda1]' 'config-*' config.mak \
138 '*.html' '*.pod' \
139 )) | \
140 while read f; do rm -f "$$f"; ln -s "$(LIBXL_SRCDIR)/$$f" "$$f"; done
141 patch -d $(LIBXL_DIR) -p3 < libxl.patch
142 touch .link-libxl-dir
144 .PHONY: libxl
145 libxl: .link-libxl-dir
146 (cd $(LIBXL_DIR);$(MAKE) install;)
148 ######
149 # udev
150 ######
152 udev-$(UDEV_VERSION).tar.bz2:
153 $(WGET) $(UDEV_URL)/$@
155 .PHONY: udev
156 udev: udev-$(UDEV_VERSION).tar.bz2
157 tar xjvf $<
158 ( cd udev-$(UDEV_VERSION); \
159 $(MAKE) ; \
160 cp -af udevd ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH);\
161 cp -af udevstart ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH))
163 ###############
164 # qemu-wrapper
165 ###############
167 .PHONY: qemu-wrapper
168 qemu-wrapper:
169 ( cd $(QEMU_WRAPPER_DIR); \
170 $(MAKE) XEN_ROOT=$(XEN_ROOT);\
171 cp -af $(QEMU_WRAPPER) ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH))
174 ###########################
175 # functional-linux-stubdoms
176 ###########################
178 .PHONY: ioemu-stubdom
179 ioemu-stubdom: libxl linux-stubdom-$(STUBDOM_ARCH)-ioemu ioemu qemu-wrapper udev
180 $(warning "ioemu-linux-stubdom")
181 sh $(MAKE_RAMDISK_SCRIPT) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH) ramdisk-$(TARGETS) ioemu
183 .PHONY: xenstore-stubdom
184 xenstore-linux-stubdom:
185 $(warning "xenstore-linux-stubdom")
188 #########
189 # install
190 #########
191 include $(XEN_ROOT)/config/StdGNU.mk
193 .PHONY:install
194 install: install-ioemu
196 install-ioemu: ioemu-stubdom
197 $(INSTALL_DIR) "$(XENFIRMWAREDIR)"
198 $(INSTALL_DATA) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH)/vmlinuz-ioemu "$(XENFIRMWAREDIR)/vmlinuz-ioemu"
199 $(INSTALL_DATA) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH)/ramdisk-ioemu "$(XENFIRMWAREDIR)/ramdisk-ioemu"
201 #######
202 # clean
203 #######
205 # Only clean the build stuff
206 .PHONY: clean
207 clean:
208 rm -fr linux-stubdom-$(STUBDOM_ARCH)-ioemu
209 rm -fr udev-$(UDEV_VERSION)
210 rm -fr $(LIBXL_DIR) .link-libxl-dir
211 (cd $(QEMU_WRAPPER_DIR); $(MAKE) clean)
213 .PHONY: downloadclean
214 downloadclean: clean
215 rm -fr $(LINUX_SRCDIR)
216 rm -fr $(IOEMU_SRCDIR)
217 rm -fr udev-$(UDEV_VERSION).tar.bz2