debuggers.hg

annotate stubdom/Makefile @ 17299:edfd0c343b13

stubdom: add C example target

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 19 16:21:39 2008 +0000 (2008-03-19)
parents e85399173769
children 460f72ca97b6
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@17066 40 all: qemu-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@17066 177
keir@17066 178 #######
keir@17066 179 # libxc
keir@17066 180 #######
keir@17066 181
keir@17066 182 .PHONY: libxc
keir@17066 183 libxc: cross-zlib mk-symlinks
keir@17066 184 $(MAKE) -C $@
keir@17066 185
keir@17066 186 #######
keir@17066 187 # ioemu
keir@17066 188 #######
keir@17066 189
keir@17066 190 .PHONY: ioemu
keir@17066 191 ioemu: cross-zlib cross-libpci mk-symlinks libxc
keir@17066 192 [ -f ioemu/config-host.mak ] || \
keir@17066 193 ( cd ioemu ; XEN_TARGET_ARCH=$(XEN_TARGET_ARCH) sh configure --prefix=/usr --enable-stubdom $(IOEMU_OPTIONS))
keir@17071 194 $(MAKE) -C ioemu LWIPDIR=$(CURDIR)/lwip-cvs
keir@17066 195
keir@17066 196 ######
keir@17066 197 # caml
keir@17066 198 ######
keir@17066 199
keir@17066 200 .PHONY: caml
keir@17066 201 caml:
keir@17066 202 $(MAKE) -C $@
keir@17066 203
keir@17299 204 ###
keir@17299 205 # C
keir@17299 206 ###
keir@17299 207
keir@17299 208 .PHONY: c
keir@17299 209 c:
keir@17299 210 $(MAKE) -C $@
keir@17299 211
keir@17066 212 ########
keir@17066 213 # minios
keir@17066 214 ########
keir@17066 215
keir@17066 216 .PHONY: qemu-stubdom
keir@17071 217 qemu-stubdom: mk-symlinks lwip-cvs libxc ioemu
keir@17071 218 $(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs QEMUDIR=$(CURDIR)/ioemu
keir@17066 219
keir@17066 220 .PHONY: caml-stubdom
keir@17071 221 caml-stubdom: mk-symlinks lwip-cvs libxc cross-libpci caml
keir@17299 222 $(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CAMLDIR=$(CURDIR)/caml
keir@17299 223
keir@17299 224 .PHONY: c-stubdom
keir@17299 225 c-stubdom: mk-symlinks lwip-cvs libxc cross-libpci c
keir@17299 226 $(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs CDIR=$(CURDIR)/c
keir@17066 227
keir@17066 228 #########
keir@17066 229 # install
keir@17066 230 #########
keir@17066 231
keir@17066 232 install: mini-os/mini-os.gz
keir@17066 233 $(INSTALL_PROG) stubdom-dm "$(DESTDIR)/usr/lib/xen/bin"
keir@17066 234 $(INSTALL_PROG) mini-os/mini-os.gz "$(DESTDIR)/usr/lib/xen/boot/stubdom.gz"
keir@17066 235
keir@17066 236 #######
keir@17066 237 # clean
keir@17066 238 #######
keir@17066 239
keir@17066 240 # Only clean the libxc/ioemu/mini-os part
keir@17066 241 .PHONY: clean
keir@17066 242 clean:
keir@17071 243 -$(MAKE) -C mini-os LWIPDIR=$(CURDIR)/lwip-cvs clean
keir@17066 244 $(MAKE) -C caml clean
keir@17066 245 rm -fr libxc ioemu mini-os include
keir@17066 246
keir@17066 247 # clean the cross-compilation result
keir@17066 248 .PHONY: crossclean
keir@17066 249 crossclean: clean
keir@17066 250 rm -fr $(CROSS_ROOT)
keir@17071 251 rm -fr binutils-build gcc-build newlib-build
keir@17066 252 rm -fr zlib-$(ZLIB_VERSION) pciutils-$(LIBPCI_VERSION)
keir@17066 253
keir@17066 254 # clean patched sources
keir@17066 255 .PHONY: patchclean
keir@17066 256 patchclean: crossclean
keir@17066 257 rm -fr binutils-$(BINUTILS_VERSION)
keir@17066 258 rm -fr gcc-$(GCC_VERSION)
keir@17071 259 rm -fr newlib-cvs
keir@17071 260 rm -fr lwip-cvs
keir@17066 261
keir@17066 262 # clean downloads
keir@17066 263 .PHONY: downloadclean
keir@17066 264 downloadclean: patchclean
keir@17066 265 rm -f binutils-$(BINUTILS_VERSION).tar.bz2
keir@17066 266 rm -f gcc-$(GCC_VERSION).tar.bz2
keir@17066 267 rm -f zlib-$(ZLIB_VERSION).tar.gz
keir@17066 268 rm -f pciutils-$(LIBPCI_VERSION).tar.bz2
keir@17066 269
keir@17066 270 .PHONY: distclean
keir@17066 271 distclean: downloadclean