/arch/ppc64/boot/Makefile

https://bitbucket.org/evzijst/gittest · Makefile · 117 lines · 69 code · 24 blank · 24 comment · 1 complexity · 2039d7b3fbc3a9d7073f0c91decd624b MD5 · raw file

  1. # Makefile for making ELF bootable images for booting on CHRP
  2. # using Open Firmware.
  3. #
  4. # Geert Uytterhoeven September 1997
  5. #
  6. # Based on coffboot by Paul Mackerras
  7. # Simplified for ppc64 by Todd Inglett
  8. #
  9. # NOTE: this code is built for 32 bit in ELF32 format even though
  10. # it packages a 64 bit kernel. We do this to simplify the
  11. # bootloader and increase compatibility with OpenFirmware.
  12. #
  13. # To this end we need to define BOOTCC, etc, as the tools
  14. # needed to build the 32 bit image. These are normally HOSTCC,
  15. # but may be a third compiler if, for example, you are cross
  16. # compiling from an intel box. Once the 64bit ppc gcc is
  17. # stable it will probably simply be a compiler switch to
  18. # compile for 32bit mode.
  19. # To make it easier to setup a cross compiler,
  20. # CROSS32_COMPILE is setup as a prefix just like CROSS_COMPILE
  21. # in the toplevel makefile.
  22. HOSTCC := gcc
  23. BOOTCFLAGS := $(HOSTCFLAGS) $(LINUXINCLUDE) -fno-builtin
  24. BOOTAFLAGS := -D__ASSEMBLY__ $(BOOTCFLAGS) -traditional
  25. BOOTLFLAGS := -Ttext 0x00400000 -e _start -T $(srctree)/$(src)/zImage.lds
  26. OBJCOPYFLAGS := contents,alloc,load,readonly,data
  27. src-boot := crt0.S string.S prom.c main.c zlib.c imagesize.c div64.S
  28. src-boot := $(addprefix $(obj)/, $(src-boot))
  29. obj-boot := $(addsuffix .o, $(basename $(src-boot)))
  30. quiet_cmd_bootcc = BOOTCC $@
  31. cmd_bootcc = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTCFLAGS) -c -o $@ $<
  32. quiet_cmd_bootas = BOOTAS $@
  33. cmd_bootas = $(CROSS32CC) -Wp,-MD,$(depfile) $(BOOTAFLAGS) -c -o $@ $<
  34. $(patsubst %.c,%.o, $(filter %.c, $(src-boot))): %.o: %.c
  35. $(call if_changed_dep,bootcc)
  36. $(patsubst %.S,%.o, $(filter %.S, $(src-boot))): %.o: %.S
  37. $(call if_changed_dep,bootas)
  38. #-----------------------------------------------------------
  39. # ELF sections within the zImage bootloader/wrapper
  40. #-----------------------------------------------------------
  41. required := vmlinux.strip
  42. initrd := initrd
  43. obj-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.o, $(section)))
  44. src-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.c, $(section)))
  45. gz-sec = $(foreach section, $(1), $(patsubst %,$(obj)/kernel-%.gz, $(section)))
  46. hostprogs-y := piggy addnote addRamDisk
  47. targets += zImage zImage.initrd imagesize.c \
  48. $(patsubst $(obj)/%,%, $(call obj-sec, $(required) $(initrd))) \
  49. $(patsubst $(obj)/%,%, $(call src-sec, $(required) $(initrd))) \
  50. $(patsubst $(obj)/%,%, $(call gz-sec, $(required) $(initrd))) \
  51. vmlinux.initrd
  52. extra-y := initrd.o
  53. quiet_cmd_ramdisk = RAMDISK $@
  54. cmd_ramdisk = $(obj)/addRamDisk $(obj)/ramdisk.image.gz $< $@
  55. quiet_cmd_stripvm = STRIP $@
  56. cmd_stripvm = $(STRIP) -s $< -o $@
  57. vmlinux.strip: vmlinux FORCE
  58. $(call if_changed,stripvm)
  59. $(obj)/vmlinux.initrd: vmlinux.strip $(obj)/addRamDisk $(obj)/ramdisk.image.gz FORCE
  60. $(call if_changed,ramdisk)
  61. addsection = $(CROSS32OBJCOPY) $(1) \
  62. --add-section=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(patsubst %.o,%.gz, $(1)) \
  63. --set-section-flags=.kernel:$(strip $(patsubst $(obj)/kernel-%.o,%, $(1)))=$(OBJCOPYFLAGS)
  64. quiet_cmd_addnote = ADDNOTE $@
  65. cmd_addnote = $(CROSS32LD) $(BOOTLFLAGS) -o $@ $(obj-boot) && $(obj)/addnote $@
  66. quiet_cmd_piggy = PIGGY $@
  67. cmd_piggy = $(obj)/piggyback $(@:.o=) < $< | $(CROSS32AS) -o $@
  68. $(call gz-sec, $(required)): $(obj)/kernel-%.gz: % FORCE
  69. $(call if_changed,gzip)
  70. $(obj)/kernel-initrd.gz: $(obj)/ramdisk.image.gz
  71. cp -f $(obj)/ramdisk.image.gz $@
  72. $(call src-sec, $(required) $(initrd)): $(obj)/kernel-%.c: $(obj)/kernel-%.gz FORCE
  73. touch $@
  74. $(call obj-sec, $(required) $(initrd)): $(obj)/kernel-%.o: $(obj)/kernel-%.c FORCE
  75. $(call if_changed_dep,bootcc)
  76. $(call addsection, $@)
  77. $(obj)/zImage: obj-boot += $(call obj-sec, $(required))
  78. $(obj)/zImage: $(call obj-sec, $(required)) $(obj-boot) $(obj)/addnote FORCE
  79. $(call if_changed,addnote)
  80. $(obj)/zImage.initrd: obj-boot += $(call obj-sec, $(required) $(initrd))
  81. $(obj)/zImage.initrd: $(call obj-sec, $(required) $(initrd)) $(obj-boot) $(obj)/addnote FORCE
  82. $(call if_changed,addnote)
  83. $(obj)/imagesize.c: vmlinux.strip
  84. @echo Generating $@
  85. ls -l vmlinux.strip | \
  86. awk '{printf "/* generated -- do not edit! */\n" \
  87. "unsigned long vmlinux_filesize = %d;\n", $$5}' > $(obj)/imagesize.c
  88. $(CROSS_COMPILE)nm -n vmlinux | tail -n 1 | \
  89. awk '{printf "unsigned long vmlinux_memsize = 0x%s;\n", substr($$1,8)}' \
  90. >> $(obj)/imagesize.c
  91. install: $(CONFIGURE) $(BOOTIMAGE)
  92. sh -x $(srctree)/$(src)/install.sh "$(KERNELRELEASE)" vmlinux System.map "$(INSTALL_PATH)" "$(BOOTIMAGE)"
  93. clean-files := $(addprefix $(objtree)/, $(obj-boot) vmlinux.strip)