Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. # SPDX-License-Identifier: GPL-2.0
  2. KBUILD_DEFCONFIG := mmu_defconfig
  3. ifeq ($(CONFIG_MMU),y)
  4. UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
  5. else
  6. UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
  7. endif
  8. # What CPU vesion are we building for, and crack it open
  9. # as major.minor.rev
  10. CPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER))
  11. CPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1)
  12. CPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2)
  13. CPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3)
  14. export CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
  15. # Use cpu-related CONFIG_ vars to set compile options.
  16. # The various CONFIG_XILINX cpu features options are integers 0/1/2...
  17. # rather than bools y/n
  18. # Work out HW multipler support. This is tricky.
  19. # 1. Spartan2 has no HW multipliers.
  20. # 2. MicroBlaze v3.x always uses them, except in Spartan 2
  21. # 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings
  22. ifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY)))
  23. ifeq ($(CPU_MAJOR),3)
  24. CPUFLAGS-1 += -mno-xl-soft-mul
  25. else
  26. # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
  27. CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high
  28. CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul
  29. endif
  30. endif
  31. CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
  32. CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
  33. CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
  34. ifdef CONFIG_CPU_BIG_ENDIAN
  35. KBUILD_CFLAGS += -mbig-endian
  36. KBUILD_AFLAGS += -mbig-endian
  37. KBUILD_LDFLAGS += -EB
  38. else
  39. KBUILD_CFLAGS += -mlittle-endian
  40. KBUILD_AFLAGS += -mlittle-endian
  41. KBUILD_LDFLAGS += -EL
  42. endif
  43. CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
  44. # r31 holds current when in kernel mode
  45. KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
  46. head-y := arch/microblaze/kernel/head.o
  47. libs-y += arch/microblaze/lib/
  48. core-y += arch/microblaze/kernel/
  49. core-y += arch/microblaze/mm/
  50. core-$(CONFIG_PCI) += arch/microblaze/pci/
  51. drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
  52. boot := arch/microblaze/boot
  53. # Are we making a simpleImage.<boardname> target? If so, crack out the boardname
  54. DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
  55. core-y += $(boot)/dts/
  56. # defines filename extension depending memory management type
  57. ifeq ($(CONFIG_MMU),)
  58. MMU := -nommu
  59. endif
  60. export MMU DTB
  61. all: linux.bin
  62. archclean:
  63. $(Q)$(MAKE) $(clean)=$(boot)
  64. archheaders:
  65. $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
  66. PHONY += linux.bin linux.bin.gz linux.bin.ub
  67. linux.bin.ub linux.bin.gz: linux.bin
  68. linux.bin: vmlinux
  69. linux.bin linux.bin.gz linux.bin.ub:
  70. $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
  71. @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
  72. PHONY += simpleImage.$(DTB)
  73. simpleImage.$(DTB): vmlinux
  74. $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
  75. @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
  76. define archhelp
  77. echo '* linux.bin - Create raw binary'
  78. echo ' linux.bin.gz - Create compressed raw binary'
  79. echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
  80. echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
  81. echo ' simpleImage.<dt> : raw image'
  82. echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
  83. echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
  84. echo ' simpleImage.<dt>.strip : stripped ELF'
  85. echo ' Targets with <dt> embed a device tree blob inside the image'
  86. echo ' These targets support board with firmware that does not'
  87. echo ' support passing a device tree directly. Replace <dt> with the'
  88. echo ' name of a dts file from the arch/microblaze/boot/dts/ directory'
  89. echo ' (minus the .dts extension).'
  90. endef
  91. MRPROPER_FILES += $(boot)/simpleImage.*