debuggers.hg

annotate stubdom/Makefile @ 18007:433d1b26fd51

stubdom: use host's gcc

This makes stubdom use the host's gcc instead of downloading/compiling
binutils+gcc. That requires a bunch of changes and even uncovered a
few bugs, but saves a lot of time.

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