From: Tom Rini <trini@kernel.crashing.org>

The following patch fixes the 'znetboot' and 'znetbootrd' targets so that
they work again.

- Update the comments to reflect how things work with the correct
  usages now.

- Fix the znetboot / znetbootrd targets.  We now always set end-y,
  and use this to figure out what image will be tftpboot'ed.



 25-akpm/arch/ppc/boot/simple/Makefile |   65 ++++++++++++++--------------------
 1 files changed, 28 insertions(+), 37 deletions(-)

diff -puN arch/ppc/boot/simple/Makefile~ppc-netboot-build-fixes arch/ppc/boot/simple/Makefile
--- 25/arch/ppc/boot/simple/Makefile~ppc-netboot-build-fixes	Tue Dec 23 13:22:32 2003
+++ 25-akpm/arch/ppc/boot/simple/Makefile	Tue Dec 23 13:22:32 2003
@@ -4,30 +4,38 @@
 # Author: Tom Rini <trini@mvista.com>
 #
 # Notes:
-# (1) For machine targets which produce more than one image, define
-# ZNETBOOT and ZNETBOOTRD to the image which should be available for
-# 'znetboot' and 'znetboot.initrd`
-# (2) Also, for machine targets which just need to remove the ELF header,
-# define END to be the machine name you want in the image.
-# (3) For machine targets which use the mktree program, define END to be
-# the machine name you want in the image, and you can optionally set
-# ENTRYPOINT which the image should be loaded at.  The optimal setting
-# for ENTRYPOINT is the link address.
+# (1) For machines that do not want to use the ELF image directly (including
+# stripping just the ELF header off), they must set the variables
+# zimage-$(CONFIG_MACHINE) and zimagerd-$(CONFIG_MACHINE) to the target
+# that produces the desired image and they must set end-$(CONFIG_MACHINE)
+# to what will be suffixed to the image filename.
+# (2) Regardless of (1), to have the resulting image be something other
+# than 'zImage.elf', set end-$(CONFIG_MACHINE) to be the suffix used for
+# the zImage, znetboot, and znetbootrd targets.
+# (3) For machine targets which use the mktree program, you can optionally
+# set entrypoint-$(CONFIG_MACHINE) to the location which the image should be
+# loaded at.  The optimal setting for entrypoint-$(CONFIG_MACHINE) is the link
+# address.
 # (4) It is advisable to pass in the memory size using BI_MEMSIZE and
 # get_mem_size(), which is memory controller dependent.  Add in the correct
-# XXX_memory.o file for this to work, as well as editing the $(MISC) file.
-
+# XXX_memory.o file for this to work, as well as editing the
+# misc-$(CONFIG_MACHINE) variable.
 
 boot				:= arch/ppc/boot
 common				:= $(boot)/common
 utils				:= $(boot)/utils
 bootlib				:= $(boot)/lib
 images				:= $(boot)/images
+tftpboot			:= /tftpboot
 
 # Normally, we use the 'misc.c' file for decompress_kernel and
 # whatnot.  Sometimes we need to override this however.
 misc-y	:= misc.o
 
+# Normally, we have our images end in .elf, but something we want to
+# change this.
+end-y := elf
+
 # Additionally, we normally don't need to mess with the L2 / L3 caches
 # if present on 'classic' PPC.
 cacheflag-y	:= -DCLEAR_CACHES=""
@@ -41,35 +49,31 @@ clear_L2_L3	:= $(boot)/simple/clear.S
       zimage-$(CONFIG_IBM_OPENBIOS)	:= zImage-TREE
 zimageinitrd-$(CONFIG_IBM_OPENBIOS)	:= zImage.initrd-TREE
          end-$(CONFIG_IBM_OPENBIOS)	:= treeboot
-   tftpimage-$(CONFIG_IBM_OPENBIOS)	:= /tftpboot/zImage.$(end-y)
         misc-$(CONFIG_IBM_OPENBIOS)	:= misc-embedded.o
 
-   tftpimage-$(CONFIG_EMBEDDEDBOOT)	:=  /tftpboot/zImage.embedded
+         end-$(CONFIG_EMBEDDEDBOOT)	:= embedded
         misc-$(CONFIG_EMBEDDEDBOOT)	:= misc-embedded.o
 
       zimage-$(CONFIG_EBONY)		:= zImage-TREE
 zimageinitrd-$(CONFIG_EBONY)		:= zImage.initrd-TREE
          end-$(CONFIG_EBONY)		:= ebony
   entrypoint-$(CONFIG_EBONY)		:= 0x01000000
-   tftpimage-$(CONFIG_EBONY)		:= /tftpboot/zImage.$(end-y)
 
       zimage-$(CONFIG_OCOTEA)		:= zImage-TREE
 zimageinitrd-$(CONFIG_OCOTEA)		:= zImage.initrd-TREE
          end-$(CONFIG_OCOTEA)		:= ocotea
   entrypoint-$(CONFIG_OCOTEA)		:= 0x01000000
-   tftpimage-$(CONFIG_OCOTEA)		:= /tftpboot/zImage.$(end-y)
 
      extra.o-$(CONFIG_EV64260)		:= direct.o misc-ev64260.o
-   tftpimage-$(CONFIG_EV64260)		:= /tftpboot/zImage.ev64260
+         end-$(CONFIG_EV64260)		:= ev64260
    cacheflag-$(CONFIG_EV64260)		:= -include $(clear_L2_L3)
 
       zimage-$(CONFIG_GEMINI)		:= zImage-STRIPELF
 zimageinitrd-$(CONFIG_GEMINI)		:= zImage.initrd-STRIPELF
          end-$(CONFIG_GEMINI)		:= gemini
-   tftpimage-$(CONFIG_GEMINI)		:= /tftpboot/zImage.$(end-y)
 
      extra.o-$(CONFIG_K2)		:= legacy.o
-   tftpimage-$(CONFIG_K2)		:= /tftpboot/zImage.k2
+         end-$(CONFIG_K2)		:= k2
    cacheflag-$(CONFIG_K2)		:= -include $(clear_L2_L3)
 
 # kconfig 'feature', only one of these will ever be 'y' at a time.
@@ -81,9 +85,7 @@ pcore := $(CONFIG_PCORE)$(CONFIG_POWERPM
 
       zimage-$(motorola)		:= zImage-PPLUS
 zimageinitrd-$(motorola)		:= zImage.initrd-PPLUS
-   tftpimage-$(motorola)		:= /tftpboot/zImage.pplus
-    znetboot-$(motorola)		:= zImage.pplus
-  znetbootrd-$(motorola)		:= zImage.initrd.pplus
+         end-$(motorola)		:= pplus
 
 # Overrides previous assingment
      extra.o-$(CONFIG_PPLUS)		:= legacy.o
@@ -92,10 +94,9 @@ zimageinitrd-$(motorola)		:= zImage.init
 zimageinitrd-$(pcore)			:= zImage.initrd-STRIPELF
      extra.o-$(pcore)			:= chrpmap.o
          end-$(pcore)			:= pcore
-   tftpimage-$(pcore)			:= /tftpboot/zImage.$(end-y)
    cacheflag-$(pcore)			:= -include $(clear_L2_L3)
 
-   tftpimage-$(CONFIG_SANDPOINT)	:= /tftpboot/zImage.sandpoint
+         end-$(CONFIG_SANDPOINT)	:= sandpoint
    cacheflag-$(CONFIG_SANDPOINT)	:= -include $(clear_L2_L3)
 
       zimage-$(CONFIG_SPRUCE)		:= zImage-TREE
@@ -103,11 +104,9 @@ zimageinitrd-$(CONFIG_SPRUCE)		:= zImage
          end-$(CONFIG_SPRUCE)		:= spruce
   entrypoint-$(CONFIG_SPRUCE)		:= 0x00800000
         misc-$(CONFIG_SPRUCE)		:= misc-spruce.o
-   tftpimage-$(CONFIG_SPRUCE)		:= /tftpboot/zImage.$(end-y)
-
 
-# tftp image is prefixed with .smp if compiled for SMP
-tftpimage-$(CONFIG_SMP)	+= .smp
+# SMP images should have a '.smp' suffix.
+         end-$(CONFIG_SMP)		+= .smp
 
 # This is a treeboot that needs init functions until the
 # boot rom is sorted out (i.e. this is short lived)
@@ -181,18 +180,10 @@ zImage.initrd: $(images)/$(zimageinitrd-
 	rm -f $(obj)/zvmlinux.initrd
 
 znetboot: zImage
-ifneq ($(ZNETBOOT),)
-	cp $(images)/$(ZNETBOOT) $(tftpimage-y)
-else
-	cp $(images)/zImage.* $(tftpimage-y)
-endif
+	cp $(images)/zImage.$(end-y) $(tftpboot)/zImage.$(end-y)
 
 znetboot.initrd: zImage.initrd
-ifneq ($(znetbootrd-y),)
-	cp $(images)/$(znetbootrd-y) $(tftpimage-y)
-else
-	cp $(images)/zImage.* $(tftpimage-y)
-endif
+	cp $(images)/zImage.initrd.$(end-y) $(tftpboot)/zImage.initrd.$(end-y)
 
 $(images)/zImage-STRIPELF: $(obj)/zvmlinux
 	dd if=$(obj)/zvmlinux of=$(images)/zImage.$(end-y) skip=64 bs=1k

_