mailestone-2
[linux-based-stubdoms.git] / Makefile
blob39761f3875cbb05dcb20f2b22bab0f1538446db2
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/sstabellini/qemu-dm.git
20 IOEMU_SRCDIR = ioemu-src-$(STUBDOM_ARCH).git
21 IOEMU_GIT_ORIGIN ?= origin
22 IOEMU_GIT_REMOTEBRANCH ?= xen-stable-0.15
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_URL?= http://ceos.googlecode.com/files
33 UDEV_VERSION=100
35 #download bridge-util
36 BRIDGE_UTILS_URL ?= http://cdnetworks-kr-2.dl.sourceforge.net/project/bridge/bridge
37 BRIDGE_UTILS_VERSION = 1.5
39 #build ioemu
40 IOEMU_DIR = build-ioemu-$(STUBDOM_ARCH)
42 #build qemu-tools
43 QEMU_TOOLS_DIR = qemu-tools
44 QEMU_TOOLS = qemu-wrapper qemu-ifup netconfig
46 TARGETS=ioemu
48 GIT ?= git
50 WGET=wget -c
52 .PHONY: all
53 all: ioemu-stubdom
55 ######################
56 # download source code
57 ######################
59 .PHONY: download-linux-src
60 download-linux-src:
61 if ! [ -d $(LINUX_SRCDIR) ]; then \
62 rm -rf $(LINUX_SRCDIR) $(LINUX_SRCDIR).tmp; \
63 mkdir $(LINUX_SRCDIR).tmp; rmdir $(LINUX_SRCDIR).tmp; \
64 $(GIT) clone -o $(XEN_GIT_ORIGIN) -n $(LINUX_STUBDOM_GIT_URL) $(LINUX_SRCDIR).tmp; \
65 (cd $(LINUX_SRCDIR).tmp; git checkout -b $(XEN_LINUX_GIT_LOCALBRANCH) $(XEN_LINUX_GITREV); git checkout); \
66 mv $(LINUX_SRCDIR).tmp $(LINUX_SRCDIR); \
67 patch -d $(LINUX_SRCDIR) -p1 < linux-src.patch; \
70 .PHONY: download-ioemu-src
71 download-ioemu-src:
72 if ! [ -d $(IOEMU_SRCDIR) ]; then \
73 rm -rf $(IOEMU_SRCDIR) $(IOEMU_SRCDIR).tmp; \
74 mkdir $(IOEMU_SRCDIR).tmp; rmdir $(IOEMU_SRCDIR).tmp; \
75 $(GIT) clone -o $(IOEMU_GIT_ORIGIN) -n $(IOEMU_GIT_URL) $(IOEMU_SRCDIR).tmp; \
76 (cd $(IOEMU_SRCDIR).tmp; git checkout -b $(IOEMU_GIT_LOCALBRANCH) $(IOEMU_GITREV); git checkout);\
77 mv $(IOEMU_SRCDIR).tmp $(IOEMU_SRCDIR);\
80 ################
81 # linux-stubdom
82 ################
84 TARGETS_LINUX=$(addprefix linux-stubdom-$(STUBDOM_ARCH)-,$(TARGETS))
85 LINUX_STUBDOM_CONFIG=$(addprefix linux-config-,$(TARGETS))
86 MAKE_RAMDISK_SCRIPT=$(addprefix mk-ramdisk-,$(TARGETS))
87 $(TARGETS_LINUX):download-linux-src
88 mkdir -p $@
89 mkdir -p $@/$(LINUX_DIR)
90 mkdir -p $@/$(INSTALL_PATH)
91 if [ ! -f $@/$(LINUX_DIR)/.config ]; then \
92 cp $(LINUX_STUBDOM_CONFIG) $@/$(LINUX_DIR)/.config;\
93 $(MAKE) -C $(LINUX_SRCDIR) ARCH=$(LINUX_ARCH) oldconfig O=$$(/bin/pwd)/$@/$(LINUX_DIR);\
94 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) prepare;\
96 if grep "^CONFIG_MODULES=" $@/$(LINUX_DIR)/.config ; then \
97 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) modules || exit 1 ; \
98 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_MOD_PATH=$(CURDIR)/$@/$(INSTALL_PATH) modules_install ; \
100 $(MAKE) -C $@/$(LINUX_DIR) ARCH=$(LINUX_ARCH) INSTALL_PATH=$@/$(INSTALL_PATH) $(IMAGE_TARGET)
101 @cp -v $@/$(LINUX_DIR)/arch/$(LINUX_ARCH)/boot/bzImage $@/$(INSTALL_PATH)/vmlinuz-$(TARGETS)
102 @cp -v $@/$(LINUX_DIR)/.config $@/$(INSTALL_PATH)/config-$(TARGETS)
103 @cp -v $@/$(LINUX_DIR)/System.map $@/$(INSTALL_PATH)/System.map-$(TARGETS)
105 #######
106 # ioemu
107 #######
109 linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir:
110 mkdir -p linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR)
111 set -e; \
112 cd linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR); \
113 (cd $(CURDIR)/$(IOEMU_SRCDIR) && find * -type d -print) | xargs mkdir -p; \
114 (cd $(CURDIR)/$(IOEMU_SRCDIR) && find * ! -type l -type f $(addprefix ! -name , \
115 '*.[oda1]' 'config-*' config.mak \
116 '*.html' '*.pod' \
117 )) | \
118 while read f; do rm -f "$$f"; ln -s "$(CURDIR)/$(IOEMU_SRCDIR)/$$f" "$$f"; done
119 # patch -d linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR) -p1 < ioemu-stubdom.patch
120 touch linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir
122 .PHONY: ioemu
123 ioemu: download-ioemu-src linux-stubdom-$(STUBDOM_ARCH)-ioemu/.link-ioemu-dir
124 $(warning "build upstream qemu")
125 (cd linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(IOEMU_DIR); \
126 sh configure --target-list=i386-softmmu --enable-xen --disable-werror --enable-stubdom \
127 --extra-cflags=-I$(XEN_ROOT)/dist/install/usr/include --extra-ldflags=-L$(XEN_ROOT)/dist/install/usr/lib; \
128 $(MAKE);\
129 cp -af i386-softmmu/qemu ../$(INSTALL_PATH))
131 #######
132 # libxl
133 #######
135 .link-libxl-dir:
136 mkdir -p $(LIBXL_DIR)
137 set -e; \
138 cd $(LIBXL_DIR); \
139 (cd $(LIBXL_SRCDIR) && $(MAKE) clean);\
140 (cd $(LIBXL_SRCDIR) && find * ! -type l -type f $(addprefix ! -name , \
141 '*.[oda1]' 'config-*' config.mak \
142 '*.html' '*.pod' \
143 )) | \
144 while read f; do rm -f "$$f"; ln -s "$(LIBXL_SRCDIR)/$$f" "$$f"; done
145 # patch -d $(LIBXL_DIR) -p3 < libxl.patch
146 touch .link-libxl-dir
148 .PHONY: libxl
149 libxl: .link-libxl-dir
150 (cd $(LIBXL_DIR);$(MAKE) install;)
152 ######
153 # udev
154 ######
156 udev-$(UDEV_VERSION).tar.tar:
157 $(WGET) $(UDEV_URL)/$@
159 .PHONY: udev
160 udev: udev-$(UDEV_VERSION).tar.tar
161 tar xjvf $<
162 ( cd udev-$(UDEV_VERSION); \
163 $(MAKE) ; \
164 cp -af udevd ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH);\
165 cp -af udevstart ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH))
167 ##############
168 # bridge-utils
169 ##############
171 bridge-utils-$(BRIDGE_UTILS_VERSION).tar.gz:
172 $(WGET) $(BRIDGE_UTILS_URL)/$@
174 .PHONY: bridge-utils
175 bridge-utils: bridge-utils-$(BRIDGE_UTILS_VERSION).tar.gz
176 tar zxvf $<
177 ( cd bridge-utils-$(BRIDGE_UTILS_VERSION); \
178 autoreconf;\
179 ./configure;\
180 $(MAKE);\
181 cp -af ./brctl/brctl ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH))
183 ###############
184 # qemu-tools
185 ###############
187 .PHONY: qemu-tools
188 qemu-tools:
189 ( cd $(QEMU_TOOLS_DIR); \
190 $(MAKE) XEN_ROOT=$(XEN_ROOT);\
191 cp -af $(QEMU_TOOLS) ../linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH))
193 ###########################
194 # functional-linux-stubdoms
195 ###########################
197 .PHONY: ioemu-stubdom
198 ioemu-stubdom: libxl linux-stubdom-$(STUBDOM_ARCH)-ioemu ioemu qemu-tools udev bridge-utils
199 sh $(MAKE_RAMDISK_SCRIPT) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH) ramdisk-$(TARGETS) ioemu
201 .PHONY: xenstore-stubdom
202 xenstore-linux-stubdom:
203 $(warning "xenstore-linux-stubdom")
206 #########
207 # install
208 #########
209 include $(XEN_ROOT)/config/StdGNU.mk
211 .PHONY:install
212 install: install-ioemu
214 install-ioemu: ioemu-stubdom
215 $(INSTALL_DIR) "$(XENFIRMWAREDIR)"
216 $(INSTALL_DATA) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH)/vmlinuz-ioemu "$(XENFIRMWAREDIR)/vmlinuz-ioemu"
217 $(INSTALL_DATA) linux-stubdom-$(STUBDOM_ARCH)-ioemu/$(INSTALL_PATH)/ramdisk-ioemu "$(XENFIRMWAREDIR)/ramdisk-ioemu"
219 #######
220 # clean
221 #######
223 # Only clean the build stuff
224 .PHONY: clean
225 clean:
226 rm -fr linux-stubdom-$(STUBDOM_ARCH)-ioemu
227 rm -fr udev-$(UDEV_VERSION)
228 rm -fr bridge-utils-$(BRIDGE_UTILS_VERSION)
229 rm -fr $(LIBXL_DIR) .link-libxl-dir
230 (cd $(QEMU_TOOLS_DIR); $(MAKE) clean)
232 .PHONY: downloadclean
233 downloadclean: clean
234 rm -fr $(LINUX_SRCDIR)
235 rm -fr $(IOEMU_SRCDIR)
236 rm -fr udev-$(UDEV_VERSION).tar.bz2