Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. # Makefile for the Sparc boot stuff.
  2. #
  3. # Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
  4. # Copyright (C) 1997,1998 Jakub Jelinek (jj@ultra.linux.cz)
  5. ROOT_IMG := /usr/src/root.img
  6. ELFTOAOUT := elftoaout
  7. MKIMAGE := $(srctree)/scripts/mkuboot.sh
  8. hostprogs-y := piggyback btfixupprep
  9. targets := tftpboot.img btfix.o btfix.S image zImage vmlinux.aout
  10. clean-files := System.map
  11. quiet_cmd_elftoaout = ELFTOAOUT $@
  12. cmd_elftoaout = $(ELFTOAOUT) $(obj)/image -o $@
  13. quiet_cmd_piggy = PIGGY $@
  14. cmd_piggy = $(obj)/piggyback $(BITS) $@ System.map $(ROOT_IMG)
  15. quiet_cmd_strip = STRIP $@
  16. cmd_strip = $(STRIP) -R .comment -R .note -K sun4u_init -K _end -K _start $< -o $@
  17. ifeq ($(CONFIG_SPARC32),y)
  18. quiet_cmd_btfix = BTFIX $@
  19. cmd_btfix = $(OBJDUMP) -x vmlinux | $(obj)/btfixupprep > $@
  20. quiet_cmd_sysmap = SYSMAP $(obj)/System.map
  21. cmd_sysmap = $(CONFIG_SHELL) $(srctree)/scripts/mksysmap
  22. quiet_cmd_image = LD $@
  23. cmd_image = $(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) $(LDFLAGS_$(@F)) -o $@
  24. define rule_image
  25. $(if $($(quiet)cmd_image), \
  26. echo ' $($(quiet)cmd_image)' &&) \
  27. $(cmd_image); \
  28. $(if $($(quiet)cmd_sysmap), \
  29. echo ' $($(quiet)cmd_sysmap)' &&) \
  30. $(cmd_sysmap) $@ $(obj)/System.map; \
  31. if [ $$? -ne 0 ]; then \
  32. rm -f $@; \
  33. /bin/false; \
  34. fi; \
  35. echo 'cmd_$@ := $(cmd_image)' > $(@D)/.$(@F).cmd
  36. endef
  37. BTOBJS := $(patsubst %/, %/built-in.o, $(VMLINUX_INIT))
  38. BTLIBS := $(patsubst %/, %/built-in.o, $(VMLINUX_MAIN))
  39. LDFLAGS_image := -T arch/sparc/kernel/vmlinux.lds $(BTOBJS) \
  40. --start-group $(BTLIBS) --end-group \
  41. $(kallsyms.o) $(obj)/btfix.o
  42. # Link the final image including btfixup'ed symbols.
  43. # This is a replacement for the link done in the top-level Makefile.
  44. # Note: No dependency on the prerequisite files since that would require
  45. # make to try check if they are updated - and due to changes
  46. # in gcc options (path for example) this would result in
  47. # these files being recompiled for each build.
  48. $(obj)/image: $(obj)/btfix.o FORCE
  49. $(call if_changed_rule,image)
  50. $(obj)/zImage: $(obj)/image
  51. $(call if_changed,strip)
  52. @echo ' kernel: $@ is ready'
  53. $(obj)/btfix.S: $(obj)/btfixupprep vmlinux FORCE
  54. $(call if_changed,btfix)
  55. endif
  56. ifeq ($(CONFIG_SPARC64),y)
  57. # Actual linking
  58. $(obj)/image: vmlinux FORCE
  59. $(call if_changed,strip)
  60. @echo ' kernel: $@ is ready'
  61. $(obj)/zImage: $(obj)/image
  62. $(call if_changed,gzip)
  63. @echo ' kernel: $@ is ready'
  64. $(obj)/vmlinux.aout: vmlinux FORCE
  65. $(call if_changed,elftoaout)
  66. @echo ' kernel: $@ is ready'
  67. else
  68. # The following lines make a readable image for U-Boot.
  69. # uImage - Binary file read by U-boot
  70. # uImage.o - object file of uImage for loading with a
  71. # flash programmer understanding ELF.
  72. OBJCOPYFLAGS_image.bin := -S -O binary -R .note -R .comment
  73. $(obj)/image.bin: $(obj)/image FORCE
  74. $(call if_changed,objcopy)
  75. $(obj)/image.gz: $(obj)/image.bin
  76. $(call if_changed,gzip)
  77. quiet_cmd_uimage = UIMAGE $@
  78. cmd_uimage = $(CONFIG_SHELL) $(MKIMAGE) -A sparc -O linux -T kernel \
  79. -C gzip -a $(CONFIG_UBOOT_LOAD_ADDR) \
  80. -e $(CONFIG_UBOOT_ENTRY_ADDR) -n 'Linux-$(KERNELRELEASE)' \
  81. -d $< $@
  82. quiet_cmd_uimage.o = UIMAGE.O $@
  83. cmd_uimage.o = $(LD) -Tdata $(CONFIG_UBOOT_FLASH_ADDR) \
  84. -r -b binary $@ -o $@.o
  85. targets += uImage
  86. $(obj)/uImage: $(obj)/image.gz
  87. $(call if_changed,uimage)
  88. $(call if_changed,uimage.o)
  89. @echo ' Image $@ is ready'
  90. endif
  91. $(obj)/tftpboot.img: $(obj)/image $(obj)/piggyback System.map $(ROOT_IMG) FORCE
  92. $(call if_changed,elftoaout)
  93. $(call if_changed,piggy)