xref: /linux/arch/microblaze/Makefile (revision 3dda563b8349ccc27547883e6cf2be4391d19cb1)
1b2441318SGreg Kroah-Hartman# SPDX-License-Identifier: GPL-2.0
28fad84c1SGeert UytterhoevenKBUILD_DEFCONFIG := mmu_defconfig
38fad84c1SGeert Uytterhoeven
44b2368ffSMichal Simekifeq ($(CONFIG_MMU),y)
54b2368ffSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
64b2368ffSMichal Simekelse
75f8ffb5fSMichal SimekUTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
84b2368ffSMichal Simekendif
95f8ffb5fSMichal Simek
105f8ffb5fSMichal Simek# What CPU vesion are we building for, and crack it open
115f8ffb5fSMichal Simek# as major.minor.rev
12950b260eSSam RavnborgCPU_VER   := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER))
13950b260eSSam RavnborgCPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1)
14950b260eSSam RavnborgCPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2)
15950b260eSSam RavnborgCPU_REV   := $(shell echo $(CPU_VER) | cut -d '.' -f 3)
165f8ffb5fSMichal Simek
175f8ffb5fSMichal Simekexport CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
185f8ffb5fSMichal Simek
195f8ffb5fSMichal Simek# Use cpu-related CONFIG_ vars to set compile options.
20950b260eSSam Ravnborg# The various CONFIG_XILINX cpu features options are integers 0/1/2...
21950b260eSSam Ravnborg# rather than bools y/n
225f8ffb5fSMichal Simek
237f01af04SMichal Simek# Work out HW multipler support. This is tricky.
2425985edcSLucas De Marchi# 1. Spartan2 has no HW multipliers.
255f8ffb5fSMichal Simek# 2. MicroBlaze v3.x always uses them, except in Spartan 2
265f8ffb5fSMichal Simek# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings
275f8ffb5fSMichal Simekifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY)))
285f8ffb5fSMichal Simek  ifeq ($(CPU_MAJOR),3)
295f8ffb5fSMichal Simek    CPUFLAGS-1 += -mno-xl-soft-mul
305f8ffb5fSMichal Simek  else
31732bee7aSUwe Kleine-König    # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
325f8ffb5fSMichal Simek    CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high
335f8ffb5fSMichal Simek    CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul
345f8ffb5fSMichal Simek  endif
355f8ffb5fSMichal Simekendif
365f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
375f8ffb5fSMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
3804e3a553SMichal SimekCPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
3971e7673dSArnd Bergmann
4071e7673dSArnd Bergmannifdef CONFIG_CPU_BIG_ENDIAN
4171e7673dSArnd BergmannKBUILD_CFLAGS += -mbig-endian
4271e7673dSArnd BergmannKBUILD_AFLAGS += -mbig-endian
43d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EB
4471e7673dSArnd Bergmannelse
4571e7673dSArnd BergmannKBUILD_CFLAGS += -mlittle-endian
4671e7673dSArnd BergmannKBUILD_AFLAGS += -mlittle-endian
47d503ac53SMasahiro YamadaKBUILD_LDFLAGS += -EL
4871e7673dSArnd Bergmannendif
495f8ffb5fSMichal Simek
505f8ffb5fSMichal SimekCPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
515f8ffb5fSMichal Simek
525f8ffb5fSMichal Simek# r31 holds current when in kernel mode
5371e7673dSArnd BergmannKBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
545f8ffb5fSMichal Simek
555f8ffb5fSMichal Simekhead-y := arch/microblaze/kernel/head.o
56950b260eSSam Ravnborglibs-y += arch/microblaze/lib/
57950b260eSSam Ravnborgcore-y += arch/microblaze/kernel/
58950b260eSSam Ravnborgcore-y += arch/microblaze/mm/
59a6475c13SMichal Simekcore-$(CONFIG_PCI) += arch/microblaze/pci/
605f8ffb5fSMichal Simek
613540ce82SJohn Williamsdrivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
623540ce82SJohn Williams
63950b260eSSam Ravnborgboot := arch/microblaze/boot
645f8ffb5fSMichal Simek
65f05131cdSMichal Simek# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
66f05131cdSMichal SimekDTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
67f05131cdSMichal Simek
68300db34aSStephen Warrencore-y	+= $(boot)/dts/
69f05131cdSMichal Simek
705f8ffb5fSMichal Simek# defines filename extension depending memory management type
715f8ffb5fSMichal Simekifeq ($(CONFIG_MMU),)
72950b260eSSam RavnborgMMU := -nommu
735f8ffb5fSMichal Simekendif
74950b260eSSam Ravnborg
75f05131cdSMichal Simekexport MMU DTB
765f8ffb5fSMichal Simek
775f8ffb5fSMichal Simekall: linux.bin
785f8ffb5fSMichal Simek
795f8ffb5fSMichal Simekarchclean:
805f8ffb5fSMichal Simek	$(Q)$(MAKE) $(clean)=$(boot)
815f8ffb5fSMichal Simek
821e17ab53SFiroz Khanarchheaders:
831e17ab53SFiroz Khan	$(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
841e17ab53SFiroz Khan
85*3dda563bSMasahiro YamadaPHONY += linux.bin linux.bin.gz linux.bin.ub
86ec2eba55SJason Wulinux.bin linux.bin.gz linux.bin.ub: vmlinux
87b843e4ecSThomas Backlund	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
882e14f94cSMasahiro Yamada	@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
895f5e3236SJason Wu
90*3dda563bSMasahiro YamadaPHONY += simpleImage.$(DTB)
91*3dda563bSMasahiro YamadasimpleImage.$(DTB): vmlinux
924722a3e6SMasahiro Yamada	$(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
932e14f94cSMasahiro Yamada	@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
945f8ffb5fSMichal Simek
955f8ffb5fSMichal Simekdefine archhelp
965f8ffb5fSMichal Simek  echo '* linux.bin    - Create raw binary'
975f8ffb5fSMichal Simek  echo '  linux.bin.gz - Create compressed raw binary'
98ec2eba55SJason Wu  echo '  linux.bin.ub - Create U-Boot wrapped raw binary'
99bafcc61dSMasahiro Yamada  echo '  simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
100bafcc61dSMasahiro Yamada  echo '                    simpleImage.<dt>        : raw image'
101bafcc61dSMasahiro Yamada  echo '                    simpleImage.<dt>.ub     : raw image with U-Boot header'
102bafcc61dSMasahiro Yamada  echo '                    simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
103bafcc61dSMasahiro Yamada  echo '                    simpleImage.<dt>.strip  : stripped ELF'
104f05131cdSMichal Simek  echo '  Targets with <dt> embed a device tree blob inside the image'
105f05131cdSMichal Simek  echo '  These targets support board with firmware that does not'
106f05131cdSMichal Simek  echo '  support passing a device tree directly. Replace <dt> with the'
107f05131cdSMichal Simek  echo '  name of a dts file from the arch/microblaze/boot/dts/ directory'
108f05131cdSMichal Simek  echo '  (minus the .dts extension).'
1095f8ffb5fSMichal Simekendef
1108a8804f1SArun Bhanu
1118a8804f1SArun BhanuMRPROPER_FILES += $(boot)/simpleImage.*
112