From 12c49b6a6adbbcb0c7a19119c8a8c94b5f025f79 Mon Sep 17 00:00:00 2001
From: nbd <nbd@3c298f89-4303-0410-b956-a3cf2f4a3e73>
Date: Tue, 7 Aug 2007 00:04:25 +0000
Subject: build system cleanup/restructuring as described in
 http://lists.openwrt.org/pipermail/openwrt-devel/2007-August/001159.html

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@8362 3c298f89-4303-0410-b956-a3cf2f4a3e73
---
 target/linux/adm5120-2.6/image/Makefile   | 12 ++++++------
 target/linux/adm5120eb-2.6/image/Makefile |  6 +++---
 target/linux/amazon-2.6/image/Makefile    |  2 +-
 target/linux/ar7-2.6/image/Makefile       |  6 +++---
 target/linux/at91-2.6/image/Makefile      |  2 +-
 target/linux/atheros-2.6/image/Makefile   |  2 +-
 target/linux/au1000-2.6/image/Makefile    |  2 +-
 target/linux/brcm-2.4/image/Makefile      | 10 +++++-----
 target/linux/brcm63xx-2.6/image/Makefile  |  4 ++--
 target/linux/rb532-2.6/image/Makefile     |  8 ++++----
 target/linux/rdc-2.6/image/Makefile       |  2 +-
 target/linux/x86-2.6/image/Makefile       |  9 ++++-----
 target/linux/x86-2.6/image/grub/Makefile  |  3 ++-
 13 files changed, 34 insertions(+), 34 deletions(-)

(limited to 'target/linux')

diff --git a/target/linux/adm5120-2.6/image/Makefile b/target/linux/adm5120-2.6/image/Makefile
index 802fd956a..8e36d45df 100644
--- a/target/linux/adm5120-2.6/image/Makefile
+++ b/target/linux/adm5120-2.6/image/Makefile
@@ -22,7 +22,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 endef
 
 define trxalign/jffs2-128k
@@ -36,12 +36,12 @@ define trxalign/squashfs
 endef
 
 define Image/Build/TRX
-	$(STAGING_DIR)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
+	$(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
 		$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
 endef
 
 define Image/Build/TRXNoloader
-	$(STAGING_DIR)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
+	$(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
 		$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
 endef
 
@@ -53,7 +53,7 @@ endef
 define Image/Build/Edimax
 	$(call Image/Build/Loader,$(2),gz,0x80500000,0x6D8,y,$(2))
 	$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
-	$(STAGING_DIR)/bin/mkcsysimg -B $(4) -d -w \
+	$(STAGING_DIR_HOST)/bin/mkcsysimg -B $(4) -d -w \
 		-r $(KDIR)/loader-$(2).gz \
 		-x $(IMGNAME)-$(3)-$(2).trx \
 		$(IMGNAME)-$(3)-$(2).bin
@@ -69,7 +69,7 @@ endef
 define Image/Build/MyLoader
 	$(call Image/Build/Loader,$(2),gz,0x80500000,0)
 	$(call Image/Build/TRXNoloader,$(IMGNAME)-$(3)-$(2).trx,$(1))
-	$(STAGING_DIR)/bin/mkmylofw -B $(4) \
+	$(STAGING_DIR_HOST)/bin/mkmylofw -B $(4) \
 		-p0x20000:0x10000:ahp:0x80001000 \
 		-p0x30000:0 \
 		-b0x20000:0x10000:h:$(KDIR)/loader-$(2).gz \
@@ -83,7 +83,7 @@ endef
 
 define Image/Build/RouterBoard
 	$(CP) $(KDIR)/vmlinux.elf $(IMGNAME)-rb1xx-vmlinux
-	$(STAGING_DIR)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/yaffs2)) '
+	$(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/yaffs2)) '
 endef
 
 define Image/Build/jffs2-64k
diff --git a/target/linux/adm5120eb-2.6/image/Makefile b/target/linux/adm5120eb-2.6/image/Makefile
index 7644a07ad..f47b3ab0b 100644
--- a/target/linux/adm5120eb-2.6/image/Makefile
+++ b/target/linux/adm5120eb-2.6/image/Makefile
@@ -22,7 +22,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 endef
 
 define trxalign/jffs2-128k
@@ -36,12 +36,12 @@ define trxalign/squashfs
 endef
 
 define Image/Build/TRX
-	$(STAGING_DIR)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
+	$(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
 		$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
 endef
 
 define Image/Build/TRXNoloader
-	$(STAGING_DIR)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
+	$(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
 		$(call trxalign/$(2)) -f $(KDIR)/root.$(2)
 endef
 
diff --git a/target/linux/amazon-2.6/image/Makefile b/target/linux/amazon-2.6/image/Makefile
index c749560db..29935f924 100644
--- a/target/linux/amazon-2.6/image/Makefile
+++ b/target/linux/amazon-2.6/image/Makefile
@@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
 include $(INCLUDE_DIR)/image.mk
 
 define Image/BuildKernel
-	$(STAGING_DIR)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.lzma
+	$(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.lzma
 	mkimage -A mips -O linux -T kernel -C lzma -a 0x80002000 -e \
 		0x80002000 \
 		-n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
diff --git a/target/linux/ar7-2.6/image/Makefile b/target/linux/ar7-2.6/image/Makefile
index 148b1bc42..33324cd36 100644
--- a/target/linux/ar7-2.6/image/Makefile
+++ b/target/linux/ar7-2.6/image/Makefile
@@ -33,7 +33,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 
 	$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
 		$(LOADER_MAKEOPTS) \
@@ -52,13 +52,13 @@ endef
 
 define Image/Build/CyberTAN
 	(dd if=/dev/zero bs=16 count=1; cat $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin) | \
-		$(STAGING_DIR)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(4).bin
+		$(STAGING_DIR_HOST)/bin/addpattern -p $(3) -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(4).bin
 endef
 
 #define Image/Build/sErCoMm
 #	cat sercomm/adam2.bin "$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin" > "$(KDIR)/dgfw.tmp"
 #	dd if=sercomm/$(2) of="$(KDIR)/dgfw.tmp" bs=$$$$((0x3e0000 - 80)) seek=1 conv=notrunc
-#	$(STAGING_DIR)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" "$(KDIR)/dgfw.tmp"
+#	$(STAGING_DIR_HOST)/bin/dgfirmware -f -w "$(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(3).img" "$(KDIR)/dgfw.tmp"
 #	rm -f "$(KDIR)/dgfw.tmp"
 #endef
 
diff --git a/target/linux/at91-2.6/image/Makefile b/target/linux/at91-2.6/image/Makefile
index f0b9dc507..7e855f06e 100644
--- a/target/linux/at91-2.6/image/Makefile
+++ b/target/linux/at91-2.6/image/Makefile
@@ -37,7 +37,7 @@ define Image/Build
 	dd if=$(KDIR)/uImage of=$(KDIR)/uImage.block bs=8448 conv=sync
 	dd if=$(KDIR)/root.squashfs of=$(KDIR)/root.block bs=8448 conv=sync
 	cat $(KDIR)/uImage.block $(KDIR)/root.block > $(KDIR)/knlroot.bin
-	$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).trx -f $(KDIR)/dfboot.bin -f$(KDIR)/u-boot.full -f$(KDIR)/knlroot.bin
+	$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL).trx -f $(KDIR)/dfboot.bin -f$(KDIR)/u-boot.full -f$(KDIR)/knlroot.bin
 	cp $(KDIR)/dfbptest.bin $(BIN_DIR)
 	$(call Image/Build/$(1),$(1))
 endef
diff --git a/target/linux/atheros-2.6/image/Makefile b/target/linux/atheros-2.6/image/Makefile
index 1d32a4bd4..5cfa77404 100644
--- a/target/linux/atheros-2.6/image/Makefile
+++ b/target/linux/atheros-2.6/image/Makefile
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/image.mk
 define Image/BuildKernel
 	cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
 	gzip -9 -c $(KDIR)/vmlinux > $(KDIR)/vmlinux.bin.gz
-	$(STAGING_DIR)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
+	$(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux $(KDIR)/vmlinux.bin.l7
 	dd if=$(KDIR)/vmlinux.bin.l7 of=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.lzma bs=65536 conv=sync
 	dd if=$(KDIR)/vmlinux.bin.gz of=$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.gz bs=65536 conv=sync
 endef
diff --git a/target/linux/au1000-2.6/image/Makefile b/target/linux/au1000-2.6/image/Makefile
index 5b8c3cc0f..1d4aa4707 100644
--- a/target/linux/au1000-2.6/image/Makefile
+++ b/target/linux/au1000-2.6/image/Makefile
@@ -29,7 +29,7 @@ OBJCOPY_SREC := $(TARGET_CROSS)objcopy -S -O srec $(addprefix --remove-section=,
 OBJCOPY_BIN := $(TARGET_CROSS)objcopy -S -O binary $(addprefix --remove-section=,$(DROP_SECTIONS))
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 	
 	# Build RAM image
 	$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader \
diff --git a/target/linux/brcm-2.4/image/Makefile b/target/linux/brcm-2.4/image/Makefile
index e2282a54e..960f5fa24 100644
--- a/target/linux/brcm-2.4/image/Makefile
+++ b/target/linux/brcm-2.4/image/Makefile
@@ -12,7 +12,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 	rm -f $(KDIR)/loader.gz
 	$(MAKE) -C lzma-loader \
 		BUILD_DIR="$(KDIR)" \
@@ -32,15 +32,15 @@ ifneq ($(KERNEL),2.4)
 endif
 
 define Image/Build/CyberTAN
-	$(STAGING_DIR)/bin/addpattern -4 -p $(3) -v v$(4) -i $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(5).bin
+	$(STAGING_DIR_HOST)/bin/addpattern -4 -p $(3) -v v$(4) -i $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -o $(BIN_DIR)/openwrt-$(2)-$(KERNEL)-$(5).bin
 endef
 
 define Image/Build/Motorola
-	$(STAGING_DIR)/bin/motorola-bin -$(3) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(4).bin
+	$(STAGING_DIR_HOST)/bin/motorola-bin -$(3) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(4).bin
 endef
 
 define Image/Build/USR
-	$(STAGING_DIR)/bin/trx2usr $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(3).bin
+	$(STAGING_DIR_HOST)/bin/trx2usr $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx $(BIN_DIR)/openwrt-$(2)-$(3).bin
 endef
 
 define trxalign/jffs2-128k
@@ -78,7 +78,7 @@ define Image/Build/squashfs
 endef
 
 define Image/Build
-	$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1),$(1))
+	$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1),$(1))
 	$(call Image/Build/$(1),$(1))
 	$(call Image/Build/Motorola,$(1),wr850g,1,$(1))
 	$(call Image/Build/USR,$(1),usr5461,$(1))
diff --git a/target/linux/brcm63xx-2.6/image/Makefile b/target/linux/brcm63xx-2.6/image/Makefile
index d930af850..fa1ccf765 100644
--- a/target/linux/brcm63xx-2.6/image/Makefile
+++ b/target/linux/brcm63xx-2.6/image/Makefile
@@ -32,7 +32,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 	rm -f $(KDIR)/loader.gz
 	$(MAKE) -C lzma-loader \
 		BUILD_DIR="$(KDIR)" \
@@ -42,7 +42,7 @@ define Image/Prepare
 endef
 
 define Image/Build
-	$(STAGING_DIR)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1)
+	$(STAGING_DIR_HOST)/bin/trx -o $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).trx -f $(KDIR)/loader.gz -f $(KDIR)/vmlinux.lzma $(call trxalign/$(1)) -f $(KDIR)/root.$(1)
 endef
 
 $(eval $(call BuildImage))
diff --git a/target/linux/rb532-2.6/image/Makefile b/target/linux/rb532-2.6/image/Makefile
index 3cdba3943..92984d1b7 100644
--- a/target/linux/rb532-2.6/image/Makefile
+++ b/target/linux/rb532-2.6/image/Makefile
@@ -25,7 +25,7 @@ define Build/Clean
 endef
 
 define Image/Prepare
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 	$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
 endef
 
@@ -54,14 +54,14 @@ root=/dev/mtdblock1 rootfstype=yaffs2 init=/etc/preinit
 endef
 
 define Image/Build
-	$(STAGING_DIR)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/$(1))) '
+	$(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux.elf '$(strip $(call Image/cmdline/$(1))) '
 	./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).bin 4 $(KDIR)/vmlinux.elf $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
 endef
 
 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
   define Image/Prepare
-	$(STAGING_DIR)/bin/patch-cmdline $(KDIR)/vmlinux '$(strip $(call Image/cmdline/yaffs2)) '
-	cat $(KDIR)/vmlinux | $(STAGING_DIR)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
+	$(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux '$(strip $(call Image/cmdline/yaffs2)) '
+	cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
 	$(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile	
   endef
   define Image/BuildKernel
diff --git a/target/linux/rdc-2.6/image/Makefile b/target/linux/rdc-2.6/image/Makefile
index 7f28507e7..0d53b26d0 100644
--- a/target/linux/rdc-2.6/image/Makefile
+++ b/target/linux/rdc-2.6/image/Makefile
@@ -26,7 +26,7 @@ define Image/Build/ar525w
 	mv $(KDIR)/root.$(1) $(KDIR)/root.tmp
 	dd of=$(KDIR)/root.$(1) if=$(KDIR)/root.tmp $(call trxalign/$(1)) conv=sync
 	rm -f $(KDIR)/root.tmp
-	$(STAGING_DIR)/bin/airlink -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-$(2).img
+	$(STAGING_DIR_HOST)/bin/airlink -b 1 -j $(shell bash -c 'echo $$[$(3)]') $(KDIR)/bzImage $(KDIR)/root.$(1) $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1)-$(2).img
 endef
 
 define Image/Build/wl153
diff --git a/target/linux/x86-2.6/image/Makefile b/target/linux/x86-2.6/image/Makefile
index 7c98ea8e4..f19e6b3f3 100644
--- a/target/linux/x86-2.6/image/Makefile
+++ b/target/linux/x86-2.6/image/Makefile
@@ -49,7 +49,7 @@ ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
 		-e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1))) $(BOOTOPTS)#g' \
 		-e 's#@BAUDRATE@#$(CONFIG_X86_GRUB_BAUDRATE)#g' \
 		./grub/menu.lst > $(KDIR)/root.grub/boot/grub/menu.lst
-	PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(STAGING_DIR)/usr/sbin:$(STAGING_DIR)/bin:$(PATH)" ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
+	PADDING="$(CONFIG_X86_GRUB_IMAGES_PAD)" PATH="$(TARGET_PATH)" ./gen_image.sh $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-$(1).image $(CONFIG_X86_GRUB_KERNELPART) $(KDIR)/root.grub $(CONFIG_TARGET_ROOTFS_FSPART) $(KDIR)/root.$(1)
 	$(call Image/Build/grub/$(1))
   endef
 endif
@@ -58,11 +58,10 @@ ifeq ($(CONFIG_X86_GRUB_IMAGES),y)
   define Image/Prepare/grub
 	# for the image builder
 	$(CP) \
-		$(STAGING_DIR)/usr/lib/grub/i386-pc/stage1 \
-		$(STAGING_DIR)/usr/lib/grub/i386-pc/stage2 \
-		$(STAGING_DIR)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
+		$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage1 \
+		$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/stage2 \
+		$(STAGING_DIR_HOST)/usr/lib/grub/i386-pc/e2fs_stage1_5 \
 		$(KDIR)/
-	$(CP) $(STAGING_DIR)/usr/sbin/grub $(STAGING_DIR)/bin
   endef
 endif
 
diff --git a/target/linux/x86-2.6/image/grub/Makefile b/target/linux/x86-2.6/image/grub/Makefile
index d37803012..dae74e9dc 100644
--- a/target/linux/x86-2.6/image/grub/Makefile
+++ b/target/linux/x86-2.6/image/grub/Makefile
@@ -65,8 +65,9 @@ endef
 
 define Build/InstallDev
 	$(MAKE) -C $(PKG_BUILD_DIR) \
-		DESTDIR="$(STAGING_DIR)" \
+		DESTDIR="$(STAGING_DIR_HOST)" \
 		install
+	mv $(STAGING_DIR_HOST)/usr/sbin/grub $(STAGING_DIR_HOST)/bin
 endef
 
 $(eval $(call Build/DefaultTargets))
-- 
cgit v1.2.3