debuggers.hg

annotate stubdom/Makefile @ 17778:460f72ca97b6

stubdom: make the build more generic by moving as many stubdom parts
into stubdom/ as possible. That also permits to build all of
ioemu, c and caml stubdoms at the same time.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed May 28 09:30:48 2008 +0100 (2008-05-28)
parents edfd0c343b13
children 9593ceb1470d
rev   line source
keir@17066 1 XEN_ROOT = ..
keir@17066 2
keir@17070 3 export XEN_OS=MiniOS
keir@17070 4
keir@17066 5 include $(XEN_ROOT)/Config.mk
keir@17066 6 export stubdom=y
keir@17066 7 export debug=y
keir@17066 8
keir@17066 9 IOEMU_OPTIONS=--disable-vnc-tls
keir@17066 10 BINUTILS_VERSION=2.18
keir@17066 11 GCC_VERSION=4.2.2
keir@17066 12 ZLIB_VERSION=1.2.3
keir@17066 13 LIBPCI_VERSION=2.2.9
keir@17066 14 NEWLIB_DATE=2008-01-01
keir@17066 15 LWIP_DATE=2008-02-08
keir@17066 16
keir@17066 17 WGET=wget -c
keir@17066 18
keir@17066 19 GNU_TARGET_ARCH:=$(XEN_TARGET_ARCH)
keir@17066 20 ifeq ($(XEN_TARGET_ARCH),x86_32)
keir@17066 21 GNU_TARGET_ARCH:=i686
keir@17066 22 endif
keir@17066 23
keir@17066 24 ifeq ($(GNU_TARGET_ARCH), i686)
keir@17066 25 TARGET_CFLAGS=
keir@17066 26 endif
keir@17066 27 ifeq ($(GNU_TARGET_ARCH), x86_64)
keir@17066 28 TARGET_CFLAGS=-mno-red-zone
keir@17066 29 endif
keir@17066 30 ifeq ($(GNU_TARGET_ARCH), ia64)
keir@17066 31 TARGET_CFLAGS=-mconstant-gp
keir@17066 32 endif
keir@17066 33
keir@17066 34 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
keir@17066 35 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
keir@17066 36 export CROSS_COMPILE=$(GNU_TARGET_ARCH)-xen-elf-
keir@17066 37 export PATH:=$(CROSS_PREFIX)/bin:$(PATH)
keir@17066 38
keir@17066 39 .PHONY: all
keir@17778 40 all: ioemu-stubdom c-stubdom
keir@17066 41
keir@17066 42 ################
keir@17066 43 # Cross-binutils
keir@17066 44 ################
keir@17066 45
keir@17066 46 binutils-$(BINUTILS_VERSION).tar.bz2:
keir@17066 47 $(WGET) http://ftp.gnu.org/gnu/binutils/$@
keir@17066 48 binutils-$(BINUTILS_VERSION): binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 49 tar xjf $@.tar.bz2
keir@17066 50 ( cd binutils-$(BINUTILS_VERSION) && patch -p1 < ../binutils.patch )
keir@17066 51 touch $@
keir@17066 52
keir@17066 53 BINUTILS_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-ar
keir@17066 54 .PHONY: cross-binutils
keir@17066 55 cross-binutils: $(BINUTILS_STAMPFILE)
keir@17066 56 $(BINUTILS_STAMPFILE): binutils-$(BINUTILS_VERSION)
keir@17071 57 mkdir -p binutils-build
keir@17071 58 ( cd binutils-build && \
keir@17066 59 ../binutils-$(BINUTILS_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 60 $(MAKE) && \
keir@17066 61 $(MAKE) check && \
keir@17066 62 $(MAKE) install )
keir@17066 63
keir@17066 64 ###########
keir@17066 65 # Cross-gcc
keir@17066 66 ###########
keir@17066 67
keir@17066 68 gcc-$(GCC_VERSION).tar.bz2:
keir@17066 69 $(WGET) http://ftp.gnu.org/gnu/gcc/gcc-$(GCC_VERSION)/gcc-$(GCC_VERSION).tar.bz2
keir@17066 70 gcc-$(GCC_VERSION): gcc-$(GCC_VERSION).tar.bz2
keir@17066 71 tar xjf gcc-$(GCC_VERSION).tar.bz2
keir@17066 72 ( cd gcc-$(GCC_VERSION) && patch -p1 < ../gcc.patch )
keir@17066 73 touch $@
keir@17066 74
keir@17066 75 GCC_STAMPFILE=$(CROSS_ROOT)/bin/$(GNU_TARGET_ARCH)-xen-elf-gcc-$(GCC_VERSION)
keir@17066 76 .PHONY: cross-gcc
keir@17066 77 cross-gcc: $(GCC_STAMPFILE)
keir@17066 78 $(GCC_STAMPFILE): gcc-$(GCC_VERSION) $(BINUTILS_STAMPFILE)
keir@17071 79 mkdir -p gcc-build
keir@17071 80 ( cd gcc-build && \
keir@17066 81 ../gcc-$(GCC_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-languages=c --disable-libssp --with-gnu-as --with-gnu-ld && \
keir@17066 82 $(MAKE) GCC_FOR_TARGET='$$$$r/gcc/xgcc -B$$$$r/gcc/ '"$(TARGET_CFLAGS)"' $$(FLAGS_FOR_TARGET)' && \
keir@17066 83 $(MAKE) install )
keir@17066 84
keir@17066 85 ##############
keir@17066 86 # Cross-newlib
keir@17066 87 ##############
keir@17066 88
keir@17072 89 newlib-cvs:
keir@17066 90 cvs -z 9 -d :pserver:anoncvs@sources.redhat.com:/cvs/src co -D $(NEWLIB_DATE) newlib
keir@17071 91 mv src newlib-cvs
keir@17071 92 ( cd newlib-cvs && patch -p0 < ../newlib.patch)
keir@17066 93
keir@17066 94 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 95 .PHONY: cross-newlib
keir@17066 96 cross-newlib: $(NEWLIB_STAMPFILE)
keir@17072 97 $(NEWLIB_STAMPFILE): newlib-cvs $(GCC_STAMPFILE)
keir@17071 98 mkdir -p newlib-build
keir@17071 99 ( cd newlib-build && \
keir@17071 100 CC_FOR_TARGET="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" ../newlib-cvs/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long && \
keir@17066 101 $(MAKE) && \
keir@17066 102 $(MAKE) install )
keir@17066 103
keir@17066 104 ############
keir@17066 105 # Cross-zlib
keir@17066 106 ############
keir@17066 107
keir@17066 108 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 109 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 110
keir@17066 111 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 112 .PHONY: cross-zlib
keir@17066 113 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 114 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 115 tar xzf $<
keir@17066 116 ( cd zlib-$(ZLIB_VERSION) && \
keir@17066 117 CFLAGS="$(TARGET_CFLAGS)" CC=$(GNU_TARGET_ARCH)-xen-elf-gcc ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 118 $(MAKE) libz.a && \
keir@17066 119 $(MAKE) install )
keir@17066 120
keir@17066 121 ##############
keir@17066 122 # Cross-libpci
keir@17066 123 ##############
keir@17066 124
keir@17066 125 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 126 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 127
keir@17066 128 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 129 .PHONY: cross-libpci
keir@17066 130 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17066 131 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION).tar.bz2 $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 132 tar xjf $<
keir@17066 133 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 134 cp ../libpci.config.h lib/config.h && \
keir@17066 135 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 136 cp ../libpci.config.mak lib/config.mk && \
keir@17066 137 $(MAKE) CC="$(GNU_TARGET_ARCH)-xen-elf-gcc $(TARGET_CFLAGS)" lib/libpci.a && \
keir@17066 138 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 139 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 140 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 141 )
keir@17066 142
keir@17066 143 ######
keir@17066 144 # lwIP
keir@17066 145 ######
keir@17066 146
keir@17071 147 lwip-cvs:
keir@17066 148 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) lwip
keir@17071 149 mv lwip lwip-cvs
keir@17066 150
keir@17066 151 #######
keir@17066 152 # Links
keir@17066 153 #######
keir@17066 154
keir@17066 155 .PHONY: $(CROSS_ROOT)
keir@17066 156 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 157
keir@17066 158 .PHONY: mk-symlinks
keir@17066 159 mk-symlinks:
keir@17066 160 [ -h include ] || ln -sf ../tools/include .
keir@17066 161 mkdir -p libxc
keir@17066 162 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17066 163 ln -sf ../../tools/libxc/*.h . && \
keir@17066 164 ln -sf ../../tools/libxc/*.c . && \
keir@17066 165 ln -sf ../../tools/libxc/Makefile . )
keir@17066 166 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 167 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17066 168 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17066 169 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17066 170 ln -sf ../../tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 171 mkdir -p ioemu
keir@17066 172 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17066 173 ln -sf ../../tools/ioemu/* . && \
keir@17066 174 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 175 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17066 176 [ -h mini-os ] || ln -sf ../extras/mini-os .
keir@17778 177 [ -h mini-os/include/xen ] || ln -sf ../../../xen/include/public mini-os/include/xen
keir@17066 178
keir@17066 179 #######
keir@17066 180 # libxc
keir@17066 181 #######
keir@17066 182
keir@17066 183 .PHONY: libxc
keir@17066 184 libxc: cross-zlib mk-symlinks
keir@17066 185 $(MAKE) -C $@
keir@17066 186
keir@17066 187 #######
keir@17066 188 # ioemu
keir@17066 189 #######
keir@17066 190
keir@17066 191 .PHONY: ioemu
keir@17066 192 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 193 [ -f ioemu/config-host.mak ] || \
keir@17066 194 ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@17071 195 $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 196
keir@17066 197 ######
keir@17066 198 # caml
keir@17066 199 ######
keir@17066 200
keir@17066 201 .PHONY: caml
keir@17778 202 caml: mk-symlinks
keir@17778 203 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 204
keir@17299 205 ###
keir@17299 206 # C
keir@17299 207 ###
keir@17299 208
keir@17299 209 .PHONY: c
keir@17778 210 c: mk-symlinks
keir@17778 211 $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17299 212
keir@17066 213 ########
keir@17066 214 # minios
keir@17066 215 ########
keir@17066 216
keir@17778 217 .PHONY: ioemu-stubdom
keir@17778 218 ioemu-stubdom: lwip-cvs libxc ioemu
keir@17778 219 $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a"
keir@17066 220
keir@17778 221 CAMLLIB = $(shell ocamlc -where)
keir@17066 222 .PHONY: caml-stubdom
keir@17778 223 caml-stubdom: lwip-cvs libxc caml
keir@17778 224 $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/caml/main-c.o $(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
keir@17299 225
keir@17299 226 .PHONY: c-stubdom
keir@17778 227 c-stubdom: lwip-cvs libxc c
keir@17778 228 $(MAKE) -C mini-os TARGET=$@ LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
keir@17066 229
keir@17066 230 #########
keir@17066 231 # install
keir@17066 232 #########
keir@17066 233
keir@17778 234 install: mini-os/ioemu-stubdom.gz
keir@17066 235 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@17778 236 $(INSTALL_PROG) $< "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
keir@17066 237
keir@17066 238 #######
keir@17066 239 # clean
keir@17066 240 #######
keir@17066 241
keir@17066 242 # Only clean the libxc/ioemu/mini-os part
keir@17066 243 .PHONY: clean
keir@17066 244 clean:
keir@17071 245 -$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
keir@17066 246 $(MAKE) -C caml clean
keir@17778 247 $(MAKE) -C c clean
keir@17066 248 rm -fr libxc ioemu mini-os include
keir@17066 249
keir@17066 250 # clean the cross-compilation result
keir@17066 251 .PHONY: crossclean
keir@17066 252 crossclean: clean
keir@17066 253 rm -fr $(CROSS_ROOT)
keir@17071 254 rm -fr binutils-build gcc-build newlib-build
keir@17066 255 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 256
keir@17066 257 # clean patched sources
keir@17066 258 .PHONY: patchclean
keir@17066 259 patchclean: crossclean
keir@17066 260 rm -fr binutils-$(BINUTILS_VERSION)
keir@17066 261 rm -fr gcc-$(GCC_VERSION)
keir@17071 262 rm -fr newlib-cvs
keir@17071 263 rm -fr lwip-cvs
keir@17066 264
keir@17066 265 # clean downloads
keir@17066 266 .PHONY: downloadclean
keir@17066 267 downloadclean: patchclean
keir@17066 268 rm -f binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 269 rm -f gcc-$(GCC_VERSION).tar.bz2
keir@17066 270 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 271 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 272
keir@17066 273 .PHONY: distclean
keir@17066 274 distclean: downloadclean