debuggers.hg

changeset 21887:8f5c50120366

stubdom: correct handling DESTDIR during build

The stubdom/Makefile expects components to install themselves to
stubdom/$(CROSS_ROOT) and passes the appropriate configure and make
variables to make this happen.

However if the top-level build uses DESTDIR then this not only effects
the installation targets in stubdom/Makefile but is also propagated to
the individual components' build causing them to install into an
unexpected location and breaking the build.

In other words "make -C stubdom DESTDIR=/tmp/a-dest-dir" fails due to missing
headers because they had been installed into /tmp/a-dest-dir instead of
stubdom/$(CROSS_ROOT).

The existing attempt to clear DESTDIR for the newlib install phase was
insufficient.

Define a CROSS_MAKE variable which should be used to recurse into the
cross compiled components and which clears DESTDIR.

Also move the definition of the genpath target to after the first
"all" target so that the default target is all.

I have confirmed that with this fix only the Xen build system outputs end up in
/tmp/a-dest-dir.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Ian Campbell <ian.campbell@citrix.com>
date Wed Jul 21 16:36:19 2010 +0100 (2010-07-21)
parents e8dbc1262f52
children fcbdfb368e20
files stubdom/Makefile
line diff
     1.1 --- a/stubdom/Makefile	Wed Jul 21 09:02:10 2010 +0100
     1.2 +++ b/stubdom/Makefile	Wed Jul 21 16:36:19 2010 +0100
     1.3 @@ -78,9 +78,7 @@ TARGET_LDFLAGS += -nostdlib -L$(CROSS_PR
     1.4  
     1.5  TARGETS=ioemu c caml grub
     1.6  
     1.7 -STUBDOMPATH="stubdompath.sh"
     1.8 -genpath-target = $(call buildmakevars2file,$(STUBDOMPATH))
     1.9 -$(eval $(genpath-target))
    1.10 +CROSS_MAKE := $(MAKE) DESTDIR=
    1.11  
    1.12  .PHONY: all
    1.13  all: build
    1.14 @@ -90,6 +88,10 @@ else
    1.15  build: genpath
    1.16  endif
    1.17  
    1.18 +STUBDOMPATH="stubdompath.sh"
    1.19 +genpath-target = $(call buildmakevars2file,$(STUBDOMPATH))
    1.20 +$(eval $(genpath-target))
    1.21 +
    1.22  ##############
    1.23  # Cross-newlib
    1.24  ##############
    1.25 @@ -113,8 +115,8 @@ cross-newlib: $(NEWLIB_STAMPFILE)
    1.26  	mkdir -p newlib-$(XEN_TARGET_ARCH)
    1.27  	( cd newlib-$(XEN_TARGET_ARCH) && \
    1.28  	  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 && \
    1.29 -	  $(MAKE) && \
    1.30 -	  DESTDIR= $(MAKE) install )
    1.31 +	  $(CROSS_MAKE) && \
    1.32 +	  $(CROSS_MAKE) install )
    1.33  
    1.34  ############
    1.35  # Cross-zlib
    1.36 @@ -133,8 +135,8 @@ cross-zlib: $(ZLIB_STAMPFILE)
    1.37  $(ZLIB_STAMPFILE): zlib-$(XEN_TARGET_ARCH) $(NEWLIB_STAMPFILE)
    1.38  	( cd $< && \
    1.39  	  CFLAGS="$(TARGET_CPPFLAGS) $(TARGET_CFLAGS)" CC=$(CC) ./configure --prefix=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf && \
    1.40 -	  $(MAKE) libz.a && \
    1.41 -	  $(MAKE) install )
    1.42 +	  $(CROSS_MAKE) libz.a && \
    1.43 +	  $(CROSS_MAKE) install )
    1.44  
    1.45  ##############
    1.46  # Cross-libpci
    1.47 @@ -157,7 +159,7 @@ cross-libpci: $(LIBPCI_STAMPFILE)
    1.48  	  cp ../libpci.config.h lib/config.h && \
    1.49  	  echo '#define PCILIB_VERSION "$(LIBPCI_VERSION)"' >> lib/config.h && \
    1.50  	  cp ../libpci.config.mak lib/config.mk && \
    1.51 -	  $(MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
    1.52 +	  $(CROSS_MAKE) CC="$(CC) $(TARGET_CPPFLAGS) $(TARGET_CFLAGS) -I$(realpath $(MINI_OS)/include)" lib/libpci.a && \
    1.53  	  $(INSTALL_DATA) lib/libpci.a $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/lib/ && \
    1.54  	  $(INSTALL_DIR) $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci && \
    1.55  	  $(INSTALL_DATA) lib/config.h lib/header.h lib/pci.h lib/types.h $(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/include/pci/ \
    1.56 @@ -202,8 +204,8 @@ cross-ocaml: $(OCAML_STAMPFILE)
    1.57  		-no-pthread -no-shared-libs -no-tk -no-curses \
    1.58  		-cc "$(CC) -U_FORTIFY_SOURCE -fno-stack-protector"
    1.59  	$(foreach i,$(MINIOS_HASNOT),sed -i 's,^\(#define HAS_$(i)\),//\1,' ocaml-$(XEN_TARGET_ARCH)/config/s.h ; )
    1.60 -	$(MAKE) -C ocaml-$(XEN_TARGET_ARCH) world
    1.61 -	$(MAKE) -C ocaml-$(XEN_TARGET_ARCH) opt
    1.62 +	$(CROSS_MAKE) -C ocaml-$(XEN_TARGET_ARCH) world
    1.63 +	$(CROSS_MAKE) -C ocaml-$(XEN_TARGET_ARCH) opt
    1.64  	$(MAKE) -C ocaml-$(XEN_TARGET_ARCH) install
    1.65  	touch $@
    1.66  
    1.67 @@ -215,7 +217,7 @@ cross-ocaml: $(OCAML_STAMPFILE)
    1.68  $(CROSS_ROOT): cross-newlib cross-zlib cross-libpci
    1.69  
    1.70  $(XEN_ROOT)/tools/ioemu-dir:
    1.71 -	$(MAKE) -C $(XEN_ROOT)/tools ioemu-dir-find
    1.72 +	$(CROSS_MAKE) -C $(XEN_ROOT)/tools ioemu-dir-find
    1.73  
    1.74  ioemu/linkfarm.stamp: $(XEN_ROOT)/tools/ioemu-dir
    1.75  	mkdir -p ioemu
    1.76 @@ -239,7 +241,7 @@ mk-headers-$(XEN_TARGET_ARCH): ioemu/lin
    1.77            ( [ -h include/xen/libelf ] || ln -sf ../../$(XEN_ROOT)/tools/include/xen/libelf include/xen/libelf ) && \
    1.78  	  mkdir -p include/xen-foreign && \
    1.79  	  ln -sf $(addprefix ../../,$(wildcard $(XEN_ROOT)/tools/include/xen-foreign/*)) include/xen-foreign/ && \
    1.80 -	  $(MAKE) -C include/xen-foreign/ && \
    1.81 +	  $(CROSS_MAKE) -C include/xen-foreign/ && \
    1.82  	  ( [ -h include/xen/foreign ] || ln -sf ../xen-foreign include/xen/foreign )
    1.83  	mkdir -p libxc-$(XEN_TARGET_ARCH)
    1.84  	[ -h libxc-$(XEN_TARGET_ARCH)/Makefile ] || ( cd libxc-$(XEN_TARGET_ARCH) && \
    1.85 @@ -251,7 +253,7 @@ mk-headers-$(XEN_TARGET_ARCH): ioemu/lin
    1.86  	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.c . && \
    1.87  	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/*.h . && \
    1.88  	  ln -sf ../$(XEN_ROOT)/tools/libxc/$(XEN_TARGET_ARCH)/Makefile . )
    1.89 -	$(MAKE) -C $(MINI_OS) links
    1.90 +	$(CROSS_MAKE) -C $(MINI_OS) links
    1.91  	touch mk-headers-$(XEN_TARGET_ARCH)
    1.92  
    1.93  TARGETS_MINIOS=$(addprefix mini-os-$(XEN_TARGET_ARCH)-,$(TARGETS))
    1.94 @@ -268,7 +270,7 @@ TARGETS_MINIOS=$(addprefix mini-os-$(XEN
    1.95  .PHONY: libxc
    1.96  libxc: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a libxc-$(XEN_TARGET_ARCH)/libxenguest.a
    1.97  libxc-$(XEN_TARGET_ARCH)/libxenctrl.a: cross-zlib
    1.98 -	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C libxc-$(XEN_TARGET_ARCH)
    1.99 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(CROSS_MAKE) -C libxc-$(XEN_TARGET_ARCH)
   1.100  
   1.101   libxc-$(XEN_TARGET_ARCH)/libxenguest.a: libxc-$(XEN_TARGET_ARCH)/libxenctrl.a
   1.102  
   1.103 @@ -287,7 +289,7 @@ ioemu: cross-zlib cross-libpci libxc
   1.104  	    TARGET_CFLAGS="$(TARGET_CFLAGS)" \
   1.105  	    TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
   1.106  	    ./xen-setup-stubdom )
   1.107 -	$(MAKE) -C ioemu
   1.108 +	$(CROSS_MAKE) -C ioemu
   1.109  
   1.110  ######
   1.111  # caml
   1.112 @@ -295,7 +297,7 @@ ioemu: cross-zlib cross-libpci libxc
   1.113  
   1.114  .PHONY: caml
   1.115  caml: $(CROSS_ROOT)
   1.116 -	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) OCAMLC_CROSS_PREFIX=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/bin/
   1.117 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(CROSS_MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) OCAMLC_CROSS_PREFIX=$(CROSS_PREFIX)/$(GNU_TARGET_ARCH)-xen-elf/bin/
   1.118  
   1.119  ###
   1.120  # C
   1.121 @@ -303,7 +305,7 @@ caml: $(CROSS_ROOT)
   1.122  
   1.123  .PHONY: c
   1.124  c: $(CROSS_ROOT)
   1.125 -	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
   1.126 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(CROSS_MAKE) -C $@ LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) 
   1.127  
   1.128  ######
   1.129  # Grub
   1.130 @@ -322,7 +324,7 @@ grub-upstream: grub-$(GRUB_VERSION).tar.
   1.131  .PHONY: grub
   1.132  grub: grub-upstream $(CROSS_ROOT)
   1.133  	mkdir -p grub-$(XEN_TARGET_ARCH)
   1.134 -	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
   1.135 +	CPPFLAGS="$(TARGET_CPPFLAGS)" CFLAGS="$(TARGET_CFLAGS)" $(CROSS_MAKE) -C $@ OBJ_DIR=$(CURDIR)/grub-$(XEN_TARGET_ARCH)
   1.136  
   1.137  ########
   1.138  # minios
   1.139 @@ -331,19 +333,19 @@ grub: grub-upstream $(CROSS_ROOT)
   1.140  .PHONY: ioemu-stubdom
   1.141  ioemu-stubdom: APP_OBJS=$(CURDIR)/ioemu/i386-stubdom/qemu.a $(CURDIR)/ioemu/i386-stubdom/libqemu.a $(CURDIR)/ioemu/libqemu_common.a
   1.142  ioemu-stubdom: mini-os-$(XEN_TARGET_ARCH)-ioemu lwip-$(XEN_TARGET_ARCH) libxc ioemu
   1.143 -	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
   1.144 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_QEMU $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(APP_OBJS)"
   1.145  
   1.146  .PHONY: caml-stubdom
   1.147  caml-stubdom: mini-os-$(XEN_TARGET_ARCH)-caml lwip-$(XEN_TARGET_ARCH) libxc caml
   1.148 -	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
   1.149 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_CAML $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS="$(CURDIR)/caml/main-caml.o $(CURDIR)/caml/caml.o $(CAMLLIB)/libasmrun.a"
   1.150  
   1.151  .PHONY: c-stubdom
   1.152  c-stubdom: mini-os-$(XEN_TARGET_ARCH)-c lwip-$(XEN_TARGET_ARCH) libxc c
   1.153 -	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
   1.154 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_C $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< LWIPDIR=$(CURDIR)/lwip-$(XEN_TARGET_ARCH) APP_OBJS=$(CURDIR)/c/main.a
   1.155  
   1.156  .PHONY: pv-grub
   1.157  pv-grub: mini-os-$(XEN_TARGET_ARCH)-grub libxc grub
   1.158 -	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-$(XEN_TARGET_ARCH)/main.a
   1.159 +	DEF_CPPFLAGS="$(TARGET_CPPFLAGS)" DEF_CFLAGS="-DCONFIG_GRUB $(TARGET_CFLAGS)" DEF_LDFLAGS="$(TARGET_LDFLAGS)" $(CROSS_MAKE) -C $(MINI_OS) OBJ_DIR=$(CURDIR)/$< APP_OBJS=$(CURDIR)/grub-$(XEN_TARGET_ARCH)/main.a
   1.160  
   1.161  #########
   1.162  # install
   1.163 @@ -380,12 +382,12 @@ clean:
   1.164  	rm -fr mini-os-$(XEN_TARGET_ARCH)-c
   1.165  	rm -fr mini-os-$(XEN_TARGET_ARCH)-caml
   1.166  	rm -fr mini-os-$(XEN_TARGET_ARCH)-grub
   1.167 -	$(MAKE) -C caml clean
   1.168 -	$(MAKE) -C c clean
   1.169 +	$(CROSS_MAKE) -C caml clean
   1.170 +	$(CROSS_MAKE) -C c clean
   1.171  	rm -fr grub-$(XEN_TARGET_ARCH)
   1.172  	rm -f $(STUBDOMPATH)
   1.173 -	[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
   1.174 -	-[ ! -d ioemu ] || $(MAKE) -C ioemu clean
   1.175 +	[ ! -d libxc-$(XEN_TARGET_ARCH) ] || $(CROSS_MAKE) -C libxc-$(XEN_TARGET_ARCH) clean
   1.176 +	-[ ! -d ioemu ] || $(CROSS_MAKE) -C ioemu clean
   1.177  
   1.178  # clean the cross-compilation result
   1.179  .PHONY: crossclean