debuggers.hg

annotate stubdom/Makefile @ 17905:7e00ebe2b7fd

minios,stubdom: Add OBJ_DIR parameter to compile outside sources,
which permits to easily compile mini-os in various flavors. Also clean
some parts of stubdom build.

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