Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. # Makefile for making bootable images on various OpenFirmware machines.
  2. #
  3. # Paul Mackerras January 1997
  4. # XCOFF bootable images for PowerMacs
  5. # Geert Uytterhoeven September 1997
  6. # ELF bootable iamges for CHRP machines.
  7. # Tom Rini January 2001
  8. # Cleaned up, moved into arch/ppc/boot/pmac
  9. # Tom Rini July/August 2002
  10. # Merged 'chrp' and 'pmac' into 'openfirmware', and cleaned up the
  11. # rules.
  12. zImage.initrd znetboot.initrd: del-ramdisk-sec := -R .ramdisk
  13. zImage.initrd znetboot.initrd: initrd := .initrd
  14. boot := arch/ppc/boot
  15. common := $(boot)/common
  16. utils := $(boot)/utils
  17. bootlib := $(boot)/lib
  18. of1275 := $(boot)/of1275
  19. images := $(boot)/images
  20. OBJCOPY_ARGS := -O aixcoff-rs6000 -R .stab -R .stabstr -R .comment
  21. COFF_LD_ARGS := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00500000 \
  22. -Bstatic
  23. CHRP_LD_ARGS := -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x00800000
  24. NEWWORLD_LD_ARGS:= -T $(srctree)/$(boot)/ld.script -e _start -Ttext 0x01000000
  25. COMMONOBJS := start.o misc.o common.o
  26. COFFOBJS := coffcrt0.o $(COMMONOBJS) coffmain.o
  27. CHRPOBJS := crt0.o $(COMMONOBJS) chrpmain.o
  28. NEWWORLDOBJS := crt0.o $(COMMONOBJS) newworldmain.o
  29. targets := $(COFFOBJS) $(CHRPOBJS) $(NEWWORLDOBJS) dummy.o
  30. COFFOBJS := $(addprefix $(obj)/, $(COFFOBJS))
  31. CHRPOBJS := $(addprefix $(obj)/, $(CHRPOBJS))
  32. NEWWORLDOBJS := $(addprefix $(obj)/, $(NEWWORLDOBJS))
  33. LIBS := lib/lib.a $(bootlib)/lib.a $(of1275)/lib.a $(common)/lib.a
  34. HACKCOFF := $(utils)/hack-coff
  35. ifdef CONFIG_SMP
  36. END := .smp
  37. endif
  38. ifdef CONFIG_PPC64BRIDGE
  39. END += .64
  40. endif
  41. $(images)/ramdisk.image.gz:
  42. @echo ' MISSING $@'
  43. @echo ' RAM disk image must be provided separately'
  44. @/bin/false
  45. quiet_cmd_genimage = GEN $@
  46. cmd_genimage = $(OBJCOPY) -R .comment \
  47. --add-section=.image=$(images)/vmlinux.gz \
  48. --set-section-flags=.image=contents,alloc,load,readonly,data $< $@
  49. targets += image.o
  50. $(obj)/image.o: $(obj)/dummy.o $(images)/vmlinux.gz FORCE
  51. $(call if_changed,genimage)
  52. # Place the ramdisk in the initrd image.
  53. quiet_cmd_genimage-initrd = GEN $@
  54. cmd_genimage-initrd = $(OBJCOPY) $< $@ \
  55. --add-section=.ramdisk=$(images)/ramdisk.image.gz \
  56. --set-section-flags=.ramdisk=contents,alloc,load,readonly,data
  57. targets += image.initrd.o
  58. $(obj)/image.initrd.o: $(obj)/image.o $(images)/ramdisk.image.gz FORCE
  59. $(call if_changed,genimage-initrd)
  60. # Create the note section for New-World PowerMacs.
  61. quiet_cmd_mknote = MKNOTE $@
  62. cmd_mknote = $(utils)/mknote > $@
  63. targets += note
  64. $(obj)/note: $(utils)/mknote FORCE
  65. $(call if_changed,mknote)
  66. $(obj)/coffcrt0.o: EXTRA_AFLAGS := -DXCOFF
  67. targets += coffcrt0.o crt0.o
  68. $(obj)/coffcrt0.o $(obj)/crt0.o: $(common)/crt0.S FORCE
  69. $(call if_changed_dep,as_o_S)
  70. quiet_cmd_gencoffb = COFF $@
  71. cmd_gencoffb = $(LD) -o $@ $(COFF_LD_ARGS) $(COFFOBJS) $< $(LIBS) && \
  72. $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
  73. targets += coffboot
  74. $(obj)/coffboot: $(obj)/image.o $(COFFOBJS) $(LIBS) $(srctree)/$(boot)/ld.script FORCE
  75. $(call if_changed,gencoffb)
  76. targets += coffboot.initrd
  77. $(obj)/coffboot.initrd: $(obj)/image.initrd.o $(COFFOBJS) $(LIBS) \
  78. $(srctree)/$(boot)/ld.script FORCE
  79. $(call if_changed,gencoffb)
  80. quiet_cmd_gen-coff = COFF $@
  81. cmd_gen-coff = $(OBJCOPY) $(OBJCOPY_ARGS) $< $@ && \
  82. $(HACKCOFF) $@ && \
  83. ln -sf $(notdir $@) $(images)/zImage$(initrd).pmac
  84. $(images)/vmlinux.coff: $(obj)/coffboot
  85. $(call cmd,gen-coff)
  86. $(images)/vmlinux.initrd.coff: $(obj)/coffboot.initrd
  87. $(call cmd,gen-coff)
  88. quiet_cmd_gen-elf-pmac = ELF $@
  89. cmd_gen-elf-pmac = $(LD) $(NEWWORLD_LD_ARGS) -o $@ \
  90. $(NEWWORLDOBJS) $(LIBS) $< && \
  91. $(OBJCOPY) $@ $@ --add-section=.note=$(obj)/note \
  92. -R .comment $(del-ramdisk-sec)
  93. $(images)/vmlinux.elf-pmac: $(obj)/image.o $(NEWWORLDOBJS) $(LIBS) \
  94. $(obj)/note $(srctree)/$(boot)/ld.script
  95. $(call cmd,gen-elf-pmac)
  96. $(images)/vmlinux.initrd.elf-pmac: $(obj)/image.initrd.o $(NEWWORLDOBJS) \
  97. $(LIBS) $(obj)/note \
  98. $(srctree)/$(boot)/ld.script
  99. $(call cmd,gen-elf-pmac)
  100. quiet_cmd_gen-chrp = CHRP $@
  101. cmd_gen-chrp = $(LD) $(CHRP_LD_ARGS) -o $@ $(CHRPOBJS) $< $(LIBS) && \
  102. $(OBJCOPY) $@ $@ -R .comment $(del-ramdisk-sec)
  103. $(images)/zImage.chrp: $(obj)/image.o $(CHRPOBJS) $(LIBS) \
  104. $(srctree)/$(boot)/ld.script
  105. $(call cmd,gen-chrp)
  106. $(images)/zImage.initrd.chrp: $(obj)/image.initrd.o $(CHRPOBJS) $(LIBS) \
  107. $(srctree)/$(boot)/ld.script
  108. $(call cmd,gen-chrp)
  109. quiet_cmd_addnote = ADDNOTE $@
  110. cmd_addnote = cat $< > $@ && $(utils)/addnote $@
  111. $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
  112. %-rs6k: %
  113. $(call cmd,addnote)
  114. quiet_cmd_gen-miboot = GEN $@
  115. cmd_gen-miboot = $(OBJCOPY) $(OBJCOPY_ARGS) \
  116. --add-section=$1=$(word 2, $^) $< $@
  117. $(images)/miboot.image: $(obj)/dummy.o $(images)/vmlinux.gz
  118. $(call cmd,gen-miboot,image)
  119. $(images)/miboot.initrd.image: $(images)/miboot.image $(images)/ramdisk.image.gz
  120. $(call cmd,gen-miboot,initrd)
  121. # The targets used on the make command-line
  122. .PHONY: zImage zImage.initrd
  123. zImage: $(images)/vmlinux.coff \
  124. $(images)/vmlinux.elf-pmac \
  125. $(images)/zImage.chrp \
  126. $(images)/zImage.chrp-rs6k \
  127. $(images)/miboot.image
  128. @echo ' kernel: $@ is ready ($<)'
  129. zImage.initrd: $(images)/vmlinux.initrd.coff \
  130. $(images)/vmlinux.initrd.elf-pmac \
  131. $(images)/zImage.initrd.chrp \
  132. $(images)/zImage.initrd.chrp-rs6k \
  133. $(images)/miboot.initrd.image
  134. @echo ' kernel: $@ is ready ($<)'
  135. TFTPIMAGE := /tftpboot/zImage
  136. .PHONY: znetboot znetboot.initrd
  137. znetboot: $(images)/vmlinux.coff \
  138. $(images)/vmlinux.elf-pmac \
  139. $(images)/zImage.chrp
  140. cp $(images)/vmlinux.coff $(TFTPIMAGE).pmac$(END)
  141. cp $(images)/vmlinux.elf-pmac $(TFTPIMAGE).pmac$(END).elf
  142. cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
  143. @echo ' kernel: $@ is ready ($<)'
  144. znetboot.initrd:$(images)/vmlinux.initrd.coff \
  145. $(images)/vmlinux.initrd.elf-pmac \
  146. $(images)/zImage.initrd.chrp
  147. cp $(images)/vmlinux.initrd.coff $(TFTPIMAGE).pmac$(END)
  148. cp $(images)/vmlinux.initrd.elf-pmac $(TFTPIMAGE).pmac$(END).elf
  149. cp $(images)/zImage.initrd.chrp $(TFTPIMAGE).chrp$(END)
  150. @echo ' kernel: $@ is ready ($<)'