debuggers.hg

annotate stubdom/Makefile @ 18044:4743bfaa9259

stubdom: make compilation independent of tools/ by building our own copy of the includes

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jul 09 11:51:46 2008 +0100 (2008-07-09)
parents 5cd4fe68b6c2
children 707e10c9a487
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@18044 55 TARGET_CPPFLAGS += -I$(CURDIR)/include
keir@18007 56
keir@18007 57 TARGET_LDFLAGS += -nostdlib -L$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib
keir@17066 58
keir@17909 59 TARGETS=ioemu c caml grub
keir@17905 60
keir@17066 61 .PHONY: all
keir@18034 62 all: build
keir@18034 63 ifeq ($(STUBDOM_SUPPORTED),1)
keir@18034 64 build: ioemu-stubdom c-stubdom pv-grub
keir@18034 65 else
keir@18034 66 build:
keir@18034 67 endif
keir@17066 68
keir@17066 69 ##############
keir@17066 70 # Cross-newlib
keir@17066 71 ##############
keir@17066 72
keir@18034 73 newlib-$(NEWLIB_VERSION).tar.gz:
keir@18034 74 $(WGET) ftp://sources.redhat.com/pub/newlib/newlib-$(NEWLIB_VERSION).tar.gz
keir@18034 75
keir@18034 76 newlib-$(NEWLIB_VERSION): newlib-$(NEWLIB_VERSION).tar.gz
keir@18034 77 tar xzf $<
keir@17905 78 patch -d $@ -p0 < newlib.patch
keir@18034 79 touch $@
keir@17066 80
keir@17066 81 NEWLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libc.a
keir@17066 82 .PHONY: cross-newlib
keir@17066 83 cross-newlib: $(NEWLIB_STAMPFILE)
keir@18034 84 $(NEWLIB_STAMPFILE): newlib-$(NEWLIB_VERSION)
keir@17071 85 mkdir -p newlib-build
keir@17071 86 ( cd newlib-build && \
keir@18034 87 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 88 $(MAKE) && \
keir@18034 89 DESTDIR= $(MAKE) install )
keir@17066 90
keir@17066 91 ############
keir@17066 92 # Cross-zlib
keir@17066 93 ############
keir@17066 94
keir@17066 95 zlib-$(ZLIB_VERSION).tar.gz:
keir@17066 96 $(WGET) http://www.zlib.net/zlib-$(ZLIB_VERSION).tar.gz
keir@17066 97
keir@17066 98 ZLIB_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libz.a
keir@17066 99 .PHONY: cross-zlib
keir@17066 100 cross-zlib: $(ZLIB_STAMPFILE)
keir@17066 101 $(ZLIB_STAMPFILE): zlib-$(ZLIB_VERSION).tar.gz $(NEWLIB_STAMPFILE)
keir@17066 102 tar xzf $<
keir@17066 103 ( cd zlib-$(ZLIB_VERSION) && \
keir@18007 104 CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
keir@17066 105 $(MAKE) libz.a && \
keir@17066 106 $(MAKE) install )
keir@17066 107
keir@17066 108 ##############
keir@17066 109 # Cross-libpci
keir@17066 110 ##############
keir@17066 111
keir@17066 112 pciutils-$(LIBPCI_VERSION).tar.bz2:
keir@17066 113 $(WGET) http://www.kernel.org/pub/software/utils/pciutils/pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 114
keir@17984 115 pciutils-$(LIBPCI_VERSION): pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17984 116 tar xjf $<
keir@17984 117 patch -d $@ -p1 < pciutils.patch
keir@17984 118 touch $@
keir@17984 119
keir@17066 120 LIBPCI_STAMPFILE=$(CROSS_ROOT)/$(GNU_TARGET_ARCH)-xen-elf/lib/libpci.a
keir@17066 121 .PHONY: cross-libpci
keir@17066 122 cross-libpci: $(LIBPCI_STAMPFILE)
keir@17984 123 $(LIBPCI_STAMPFILE): pciutils-$(LIBPCI_VERSION) $(NEWLIB_STAMPFILE) $(ZLIB_STAMPFILE)
keir@17066 124 ( cd pciutils-$(LIBPCI_VERSION) && \
keir@17066 125 cp ../libpci.config.h lib/config.h && \
keir@17066 126 echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
keir@17066 127 cp ../libpci.config.mak lib/config.mk && \
keir@18007 128 $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
keir@17066 129 $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
keir@17066 130 $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
keir@17066 131 $(INSTALL_DATA) lib/{config,header,pci,types}.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
keir@17066 132 )
keir@17066 133
keir@17066 134 ######
keir@17066 135 # lwIP
keir@17066 136 ######
keir@17066 137
keir@17071 138 lwip-cvs:
keir@17905 139 cvs -z 9 -d :pserver:anonymous@cvs.savannah.nongnu.org:/sources/lwip co -D $(LWIP_DATE) -d $@ lwip
keir@17066 140
keir@17066 141 #######
keir@17066 142 # Links
keir@17066 143 #######
keir@17066 144
keir@17066 145 .PHONY: $(CROSS_ROOT)
keir@17066 146 $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
keir@17066 147
keir@18044 148 .PHONY: mk-headers
keir@18044 149 mk-headers:
keir@18044 150 mkdir -p include/xen && \
keir@18044 151 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/xen/include/public/*.h)) include/xen && \
keir@18044 152 ( [ -h include/xen/sys ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen-sys/MiniOS include/xen/sys ) && \
keir@18044 153 mkdir -p include/xen-foreign && \
keir@18044 154 ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
keir@18044 155 $(MAKE) -C include/xen-foreign/ && \
keir@18044 156 ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
keir@17066 157 mkdir -p libxc
keir@17066 158 [ -h libxc/Makefile ] || ( cd libxc && \
keir@17905 159 ln -sf ../$(XEN_ROOT)/tools/libxc/*.h . && \
keir@17905 160 ln -sf ../$(XEN_ROOT)/tools/libxc/*.c . && \
keir@17905 161 ln -sf ../$(XEN_ROOT)/tools/libxc/Makefile . )
keir@17066 162 mkdir -p libxc/$(XEN_TARGET_ARCH)
keir@17066 163 [ -h libxc/$(XEN_TARGET_ARCH) ] || ( cd libxc/$(XEN_TARGET_ARCH) && \
keir@17905 164 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
keir@17905 165 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
keir@17905 166 ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
keir@17066 167 mkdir -p ioemu
keir@17066 168 [ -h ioemu/Makefile ] || ( cd ioemu && \
keir@17905 169 ln -sf ../$(XEN_ROOT)/tools/ioemu/* . && \
keir@17066 170 ([ ! -h config-host.h ] || rm -f config-host.h) && \
keir@17066 171 ([ ! -h config-host.mak ] || rm -f config-host.mak) )
keir@17905 172 $(MAKE) -C $(MINI_OS) links
keir@17905 173
keir@17905 174 TARGETS_MINIOS=$(addprefix mini-os-,$(TARGETS))
keir@17905 175 $(TARGETS_MINIOS): mini-os-%:
keir@17905 176 [ -d $@ ] || \
keir@17905 177 for i in $$(cd $(MINI_OS) ; find . -type d) ; do \
keir@17905 178 mkdir -p $@/$$i ; \
keir@17905 179 done
keir@17066 180
keir@17066 181 #######
keir@17066 182 # libxc
keir@17066 183 #######
keir@17066 184
keir@17066 185 .PHONY: libxc
keir@17905 186 libxc: libxc/libxenctrl.a libxc/libxenguest.a
keir@18044 187 libxc/libxenctrl.a libxc/libxenguest.a:: cross-zlib mk-headers
keir@18007 188 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc
keir@17066 189
keir@17066 190 #######
keir@17066 191 # ioemu
keir@17066 192 #######
keir@17066 193
keir@17066 194 .PHONY: ioemu
keir@18044 195 ioemu: cross-zlib cross-libpci mk-headers libxc
keir@17066 196 [ -f ioemu/config-host.mak ] || \
keir@18007 197 ( cd ioemu ; \
keir@18007 198 XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) CFLAGS="$(TARGET_CFLAGS)" sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@18033 199 CPPFLAGS="$(TARGET_CPPFLAGS)" $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs TOOLS=
keir@17066 200
keir@17066 201 ######
keir@17066 202 # caml
keir@17066 203 ######
keir@17066 204
keir@17066 205 .PHONY: caml
keir@18044 206 caml: cross-newlib mk-headers
keir@18007 207 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 208
keir@17299 209 ###
keir@17299 210 # C
keir@17299 211 ###
keir@17299 212
keir@17299 213 .PHONY: c
keir@18044 214 c: cross-newlib mk-headers
keir@18007 215 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-cvs
keir@17299 216
keir@17909 217 ######
keir@17909 218 # Grub
keir@17909 219 ######
keir@17909 220
keir@17909 221 grub-cvs:
keir@17909 222 cvs -z 9 -d :pserver:anonymous@cvs.sv.gnu.org:/sources/grub co -D $(GRUB_DATE) -d $@ grub
keir@17909 223 for i in grub.patches/* ; do \
keir@17909 224 patch -d $@ -p1 < $$i ; \
keir@17909 225 done
keir@17909 226
keir@17909 227 .PHONY: grub
keir@18044 228 grub: grub-cvs cross-newlib mk-headers
keir@18007 229 CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@
keir@17909 230
keir@17066 231 ########
keir@17066 232 # minios
keir@17066 233 ########
keir@17066 234
keir@17778 235 .PHONY: ioemu-stubdom
keir@17905 236 ioemu-stubdom: mini-os-ioemu lwip-cvs libxc ioemu
keir@18007 237 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 238
keir@17778 239 CAMLLIB = $(shell ocamlc -where)
keir@17066 240 .PHONY: caml-stubdom
keir@17905 241 caml-stubdom: mini-os-caml lwip-cvs libxc caml
keir@18007 242 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 243
keir@17299 244 .PHONY: c-stubdom
keir@17905 245 c-stubdom: mini-os-c lwip-cvs libxc c
keir@18007 246 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 247
keir@17909 248 .PHONY: pv-grub
keir@17909 249 pv-grub: mini-os-grub libxc grub
keir@18007 250 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 251
keir@17066 252 #########
keir@17066 253 # install
keir@17066 254 #########
keir@17066 255
keir@18034 256 ifeq ($(STUBDOM_SUPPORTED),1)
keir@17909 257 install: install-ioemu install-grub
keir@18034 258 else
keir@18034 259 install:
keir@18034 260 endif
keir@17909 261
keir@18034 262 install-ioemu: ioemu-stubdom
keir@18034 263 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/bin"
keir@17066 264 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@18034 265 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
keir@18034 266 $(INSTALL_PROG) mini-os-ioemu/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/ioemu-stubdom.gz"
keir@17909 267
keir@18034 268 install-grub: pv-grub
keir@18034 269 $(INSTALL_DIR) "$(DESTDIR)/usr/lib/xen/boot"
keir@18034 270 $(INSTALL_PROG) mini-os-grub/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/pv-grub.gz"
keir@17066 271
keir@17066 272 #######
keir@17066 273 # clean
keir@17066 274 #######
keir@17066 275
keir@17066 276 # Only clean the libxc/ioemu/mini-os part
keir@17066 277 .PHONY: clean
keir@17066 278 clean:
keir@17905 279 rm -fr mini-os-ioemu
keir@17905 280 rm -fr mini-os-c
keir@17905 281 rm -fr mini-os-caml
keir@17909 282 rm -fr mini-os-grub
keir@17066 283 $(MAKE) -C caml clean
keir@17778 284 $(MAKE) -C c clean
keir@17909 285 $(MAKE) -C grub clean
keir@17066 286 rm -fr libxc ioemu mini-os include
keir@17066 287
keir@17066 288 # clean the cross-compilation result
keir@17066 289 .PHONY: crossclean
keir@17066 290 crossclean: clean
keir@17066 291 rm -fr $(CROSS_ROOT)
keir@18007 292 rm -fr newlib-build
keir@17066 293 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 294
keir@17066 295 # clean patched sources
keir@17066 296 .PHONY: patchclean
keir@17066 297 patchclean: crossclean
keir@18034 298 rm -fr newlib-$(NEWLIB_VERSION)
keir@17071 299 rm -fr lwip-cvs
keir@17909 300 rm -fr grub-cvs
keir@17066 301
keir@17066 302 # clean downloads
keir@17066 303 .PHONY: downloadclean
keir@17066 304 downloadclean: patchclean
keir@18034 305 rm -f newlib-$(ZLIB_VERSION).tar.gz
keir@17066 306 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 307 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 308
keir@17066 309 .PHONY: distclean
keir@17066 310 distclean: downloadclean