debuggers.hg

annotate stubdom/Makefile @ 18034:5cd4fe68b6c2

stubdom: use a newlib snapshot instead of the slow cvs checkout.
Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Jul 08 17:25:04 2008 +0100 (2008-07-08)
parents 6f30a7367fa7
children 4743bfaa9259
rev   line source
keir@17066 1 XEN_ROOT = ..
keir@17905 2 MINI_OS = $(XEN_ROOT)/extras/mini-os
keir@17066 3
keir@17070 4 export XEN_OS=MiniOS
keir@17070 5
keir@17066 6 export stubdom=y
keir@17066 7 export debug=y
keir@18007 8 include $(XEN_ROOT)/Config.mk
keir@17066 9
keir@17066 10 IOEMU_OPTIONS=--disable-vnc-tls
keir@17066 11 ZLIB_VERSION=1.2.3
keir@17066 12 LIBPCI_VERSION=2.2.9
keir@18034 13 NEWLIB_VERSION=1.16.0
keir@17823 14 LWIP_DATE=2008-06-01
keir@17909 15 GRUB_DATE=2008-06-01
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@17830 26 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@18034 27 STUBDOM_SUPPORTED=1
keir@17066 28 endif
keir@17066 29 ifeq ($(GNU_TARGET_ARCH), x86_64)
keir@17066 30 TARGET_CFLAGS=-mno-red-zone
keir@17830 31 NEWLIB_CFLAGS+=-D_I386MACH_ALLOW_HW_INTERRUPTS
keir@18034 32 STUBDOM_SUPPORTED=1
keir@17066 33 endif
keir@17066 34 ifeq ($(GNU_TARGET_ARCH), ia64)
keir@17066 35 TARGET_CFLAGS=-mconstant-gp
keir@17066 36 endif
keir@17066 37
keir@17066 38 CROSS_ROOT=cross-root-$(GNU_TARGET_ARCH)
keir@17066 39 CROSS_PREFIX=$(CURDIR)/$(CROSS_ROOT)
keir@18007 40
keir@18007 41 # Disable PIE/SSP if GCC supports them. They can break us.
keir@18007 42 TARGET_CFLAGS += $(CFLAGS)
keir@18007 43 TARGET_CPPFLAGS += $(CPPFLAGS)
keir@18007 44 TARGET_CFLAGS += $(call cc-option,$(CC),-nopie,)
keir@18007 45 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
keir@18007 46 TARGET_CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
keir@18007 47
keir@18007 48 # Do not use host headers and libs
keir@18007 49 GCC_INSTALL = $(shell gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
keir@18007 50 TARGET_CPPFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
keir@18007 51 TARGET_CFLAGS += -nostdinc
keir@18007 52 TARGET_CPPFLAGS += -isystem $(realpath $(MINI_OS)/include/posix)
keir@18007 53 TARGET_CPPFLAGS += -isystem $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include
keir@18007 54 TARGET_CPPFLAGS += -isystem $(GCC_INSTALL)include
keir@18007 55
keir@18007 56 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
keir@17066 57
keir@17909 58 TARGETS=ioemu c caml grub
keir@17905 59
keir@17066 60 .PHONY: all
keir@18034 61 all: build
keir@18034 62 ifeq ($(STUBDOM_SUPPORTED),1)
keir@18034 63 build: ioemu-stubdom c-stubdom pv-grub
keir@18034 64 else
keir@18034 65 build:
keir@18034 66 endif
keir@17066 67
keir@17066 68 ##############
keir@17066 69 # Cross-newlib
keir@17066 70 ##############
keir@17066 71
keir@18034 72 newlib-$(NEWLIB_VERSION).tar.gz:
keir@18034 73 $(WGET) ftp://sources.redhat.com/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
keir@18034 74
keir@18034 75 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
keir@18034 76 tar xzf $<
keir@17905 77 patch -d $@ -p0 < newlib.patch
keir@18034 78 touch $@
keir@17066 79
keir@17066 80 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 81 .PHONY: cross-newlib
keir@17066 82 cross-newlib: $(NEWLIB_STAMPFILE)
keir@18034 83 $(NEWLIB_STAMPFILE): newlib-$(NEWLIB_VERSION)
keir@17071 84 mkdir -p newlib-build
keir@17071 85 ( cd newlib-build && \
keir@18034 86 CC_FOR_TARGET="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) $(NEWLIB_CFLAGS)" AR_FOR_TARGET=$(AR) LD_FOR_TARGET=$(LD) RANLIB_FOR_TARGET=$(RANLIB) ../newlib-$(NEWLIB_VERSION)/configure --prefix=$(CROSS_PREFIX) --verbose --target=$(GNU_TARGET_ARCH)-xen-elf --enable-newlib-io-long-long --disable-multilib && \
keir@17066 87 $(MAKE) && \
keir@18034 88 DESTDIR= $(MAKE) install )
keir@17066 89
keir@17066 90 ############
keir@17066 91 # Cross-zlib
keir@17066 92 ############
keir@17066 93
keir@17066 94 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 95 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 96
keir@17066 97 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 98 .PHONY: cross-zlib
keir@17066 99 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 100 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 101 tar xzf $<
keir@17066 102 ( cd zlib-$(ZLIB_VERSION) && \
keir@18007 103 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 104 $(MAKE) libz.a && \
keir@17066 105 $(MAKE) install )
keir@17066 106
keir@17066 107 ##############
keir@17066 108 # Cross-libpci
keir@17066 109 ##############
keir@17066 110
keir@17066 111 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 112 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 113
keir@17984 114 pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17984 115 tar xjf $<
keir@17984 116 patch -d $@ -p1 < pciutils.patch
keir@17984 117 touch $@
keir@17984 118
keir@17066 119 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 120 .PHONY: cross-libpci
keir@17066 121 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17984 122 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 123 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 124 cp ../libpci.config.h lib/config.h && \
keir@17066 125 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 126 cp ../libpci.config.mak lib/config.mk && \
keir@18007 127 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
keir@17066 128 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 129 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 130 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 131 )
keir@17066 132
keir@17066 133 ######
keir@17066 134 # lwIP
keir@17066 135 ######
keir@17066 136
keir@17071 137 lwip-cvs:
keir@17905 138 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
keir@17066 139
keir@17066 140 #######
keir@17066 141 # Links
keir@17066 142 #######
keir@17066 143
keir@17066 144 .PHONY: $(CROSS_ROOT)
keir@17066 145 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 146
keir@17066 147 .PHONY: mk-symlinks
keir@17066 148 mk-symlinks:
keir@17066 149 [ -h include ] || ln -sf ../tools/include .
keir@17066 150 mkdir -p libxc
keir@17066 151 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17905 152 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
keir@17905 153 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
keir@17905 154 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
keir@17066 155 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 156 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17905 157 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17905 158 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17905 159 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 160 mkdir -p ioemu
keir@17066 161 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17905 162 ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
keir@17066 163 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 164 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17905 165 $(MAKE) -C $(MINI_OS) links
keir@17905 166
keir@17905 167 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
keir@17905 168 $(TARGETS_MINIOS): mini-os-%:
keir@17905 169 [ -d $@ ] || \
keir@17905 170 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
keir@17905 171 mkdir -p $@/$$i ; \
keir@17905 172 done
keir@17066 173
keir@17066 174 #######
keir@17066 175 # libxc
keir@17066 176 #######
keir@17066 177
keir@17066 178 .PHONY: libxc
keir@17905 179 libxc: libxc/libxenctrl.a libxc/libxenguest.a
keir@18017 180 libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib mk-symlinks
keir@18007 181 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc
keir@17066 182
keir@17066 183 #######
keir@17066 184 # ioemu
keir@17066 185 #######
keir@17066 186
keir@17066 187 .PHONY: ioemu
keir@17066 188 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 189 [ -f ioemu/config-host.mak ] || \
keir@18007 190 ( cd ioemu ; \
keir@18007 191 XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@18033 192 CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs TOOLS=
keir@17066 193
keir@17066 194 ######
keir@17066 195 # caml
keir@17066 196 ######
keir@17066 197
keir@17066 198 .PHONY: caml
keir@17830 199 caml: cross-newlib mk-symlinks
keir@18007 200 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 201
keir@17299 202 ###
keir@17299 203 # C
keir@17299 204 ###
keir@17299 205
keir@17299 206 .PHONY: c
keir@17830 207 c: cross-newlib mk-symlinks
keir@18007 208 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17299 209
keir@17909 210 ######
keir@17909 211 # Grub
keir@17909 212 ######
keir@17909 213
keir@17909 214 grub-cvs:
keir@17909 215 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
keir@17909 216 for i in grub.patches/* ; do \
keir@17909 217 patch -d $@ -p1 < $$i ; \
keir@17909 218 done
keir@17909 219
keir@17909 220 .PHONY: grub
keir@17909 221 grub: grub-cvs cross-newlib mk-symlinks
keir@18007 222 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
keir@17909 223
keir@17066 224 ########
keir@17066 225 # minios
keir@17066 226 ########
keir@17066 227
keir@17778 228 .PHONY: ioemu-stubdom
keir@17905 229 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
keir@18007 230 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/ioemu/i386-dm-stubdom/qemu.a $(CURDIR)/ioemu/i386-dm-stubdom/libqemu.a"
keir@17066 231
keir@17778 232 CAMLLIB = $(shell ocamlc -where)
keir@17066 233 .PHONY: caml-stubdom
keir@17905 234 caml-stubdom: mini-os-caml lwip-cvs libxc caml
keir@18007 235 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
keir@17299 236
keir@17299 237 .PHONY: c-stubdom
keir@17905 238 c-stubdom: mini-os-c lwip-cvs libxc c
keir@18007 239 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-cvs APP_OBJS=$(CURDIR)/c/main.a
keir@17909 240
keir@17909 241 .PHONY: pv-grub
keir@17909 242 pv-grub: mini-os-grub libxc grub
keir@18007 243 DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub/main.a
keir@17066 244
keir@17066 245 #########
keir@17066 246 # install
keir@17066 247 #########
keir@17066 248
keir@18034 249 ifeq ($(STUBDOM_SUPPORTED),1)
keir@17909 250 install: install-ioemu install-grub
keir@18034 251 else
keir@18034 252 install:
keir@18034 253 endif
keir@17909 254
keir@18034 255 install-ioemu: ioemu-stubdom
keir@18034 256 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
keir@17066 257 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@18034 258 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
keir@18034 259 $(INSTALL_PROG) mini-os-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
keir@17909 260
keir@18034 261 install-grub: pv-grub
keir@18034 262 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
keir@18034 263 $(INSTALL_PROG) mini-os-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
keir@17066 264
keir@17066 265 #######
keir@17066 266 # clean
keir@17066 267 #######
keir@17066 268
keir@17066 269 # Only clean the libxc/ioemu/mini-os part
keir@17066 270 .PHONY: clean
keir@17066 271 clean:
keir@17905 272 rm -fr mini-os-ioemu
keir@17905 273 rm -fr mini-os-c
keir@17905 274 rm -fr mini-os-caml
keir@17909 275 rm -fr mini-os-grub
keir@17066 276 $(MAKE) -C caml clean
keir@17778 277 $(MAKE) -C c clean
keir@17909 278 $(MAKE) -C grub clean
keir@17066 279 rm -fr libxc ioemu mini-os include
keir@17066 280
keir@17066 281 # clean the cross-compilation result
keir@17066 282 .PHONY: crossclean
keir@17066 283 crossclean: clean
keir@17066 284 rm -fr $(CROSS_ROOT)
keir@18007 285 rm -fr newlib-build
keir@17066 286 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 287
keir@17066 288 # clean patched sources
keir@17066 289 .PHONY: patchclean
keir@17066 290 patchclean: crossclean
keir@18034 291 rm -fr newlib-$(NEWLIB_VERSION)
keir@17071 292 rm -fr lwip-cvs
keir@17909 293 rm -fr grub-cvs
keir@17066 294
keir@17066 295 # clean downloads
keir@17066 296 .PHONY: downloadclean
keir@17066 297 downloadclean: patchclean
keir@18034 298 rm -f newlib-$(ZLIB_VERSION).tar.gz
keir@17066 299 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 300 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 301
keir@17066 302 .PHONY: distclean
keir@17066 303 distclean: downloadclean