blob: e775a696aa6fc37dfab79287920b9ca0cfa4697e [file] [log] [blame]
Greg Kroah-Hartmanb2441312017-11-01 15:07:57 +01001# SPDX-License-Identifier: GPL-2.0
Geert Uytterhoeven8fad84c2013-11-12 20:22:44 +01002KBUILD_DEFCONFIG := mmu_defconfig
3
Michal Simek4b2368f2009-05-26 16:30:32 +02004UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
Michal Simek5f8ffb52009-03-27 14:25:51 +01005
Colin Ian King14a83242021-06-01 11:37:07 +01006# What CPU version are we building for, and crack it open
Michal Simek5f8ffb52009-03-27 14:25:51 +01007# as major.minor.rev
Sam Ravnborg950b2602009-07-24 09:04:49 +02008CPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER))
9CPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1)
10CPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2)
11CPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3)
Michal Simek5f8ffb52009-03-27 14:25:51 +010012
13export CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
14
15# Use cpu-related CONFIG_ vars to set compile options.
Sam Ravnborg950b2602009-07-24 09:04:49 +020016# The various CONFIG_XILINX cpu features options are integers 0/1/2...
17# rather than bools y/n
Michal Simek5f8ffb52009-03-27 14:25:51 +010018
Michal Simek7f01af02011-01-03 11:35:28 +010019# Work out HW multipler support. This is tricky.
Lucas De Marchi25985ed2011-03-30 22:57:33 -030020# 1. Spartan2 has no HW multipliers.
Michal Simek5f8ffb52009-03-27 14:25:51 +010021# 2. MicroBlaze v3.x always uses them, except in Spartan 2
22# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings
23ifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY)))
24 ifeq ($(CPU_MAJOR),3)
25 CPUFLAGS-1 += -mno-xl-soft-mul
26 else
Uwe Kleine-König732bee72010-06-11 12:16:59 +020027 # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
Michal Simek5f8ffb52009-03-27 14:25:51 +010028 CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high
29 CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul
30 endif
31endif
32CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
33CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
Michal Simek04e3a552009-04-20 09:56:24 +020034CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
Arnd Bergmann71e76732018-01-02 12:47:19 +010035
36ifdef CONFIG_CPU_BIG_ENDIAN
37KBUILD_CFLAGS += -mbig-endian
38KBUILD_AFLAGS += -mbig-endian
Masahiro Yamadad503ac52018-08-24 08:20:39 +090039KBUILD_LDFLAGS += -EB
Arnd Bergmann71e76732018-01-02 12:47:19 +010040else
41KBUILD_CFLAGS += -mlittle-endian
42KBUILD_AFLAGS += -mlittle-endian
Masahiro Yamadad503ac52018-08-24 08:20:39 +090043KBUILD_LDFLAGS += -EL
Arnd Bergmann71e76732018-01-02 12:47:19 +010044endif
Michal Simek5f8ffb52009-03-27 14:25:51 +010045
46CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
47
Michal Simek5f8ffb52009-03-27 14:25:51 +010048# r31 holds current when in kernel mode
Arnd Bergmann71e76732018-01-02 12:47:19 +010049KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
Michal Simek5f8ffb52009-03-27 14:25:51 +010050
Sam Ravnborg950b2602009-07-24 09:04:49 +020051head-y := arch/microblaze/kernel/head.o
52libs-y += arch/microblaze/lib/
Michal Simek5f8ffb52009-03-27 14:25:51 +010053
Sam Ravnborg950b2602009-07-24 09:04:49 +020054boot := arch/microblaze/boot
Michal Simek5f8ffb52009-03-27 14:25:51 +010055
Michal Simekf05131c2009-09-14 15:15:49 +020056# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
57DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
58
Michal Simek05cdf452020-11-26 14:32:25 +010059export DTB
Michal Simek5f8ffb52009-03-27 14:25:51 +010060
61all: linux.bin
62
Firoz Khan1e17ab52018-11-13 11:34:34 +053063archheaders:
64 $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
65
Masahiro Yamada3dda5632018-12-07 20:33:55 +090066PHONY += linux.bin linux.bin.gz linux.bin.ub
Masahiro Yamada52e79c42018-12-07 20:33:56 +090067linux.bin.ub linux.bin.gz: linux.bin
68linux.bin: vmlinux
69linux.bin linux.bin.gz linux.bin.ub:
Thomas Backlundb843e4e2010-10-21 13:19:10 +030070 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
Masahiro Yamada2e14f942018-12-07 20:33:53 +090071 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Jason Wu5f5e3232013-01-31 13:59:09 +100072
Masahiro Yamada3dda5632018-12-07 20:33:55 +090073PHONY += simpleImage.$(DTB)
74simpleImage.$(DTB): vmlinux
Masahiro Yamada4722a3e62018-12-07 20:33:54 +090075 $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
Masahiro Yamada2e14f942018-12-07 20:33:53 +090076 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Michal Simek5f8ffb52009-03-27 14:25:51 +010077
78define archhelp
Michal Simekf05131c2009-09-14 15:15:49 +020079 echo '* linux.bin - Create raw binary'
80 echo ' linux.bin.gz - Create compressed raw binary'
Jason Wuec2eba52013-08-21 07:10:32 +020081 echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
Masahiro Yamadabafcc612018-12-07 20:33:52 +090082 echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
83 echo ' simpleImage.<dt> : raw image'
84 echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
85 echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
86 echo ' simpleImage.<dt>.strip : stripped ELF'
Michal Simekf05131c2009-09-14 15:15:49 +020087 echo ' Targets with <dt> embed a device tree blob inside the image'
88 echo ' These targets support board with firmware that does not'
89 echo ' support passing a device tree directly. Replace <dt> with the'
90 echo ' name of a dts file from the arch/microblaze/boot/dts/ directory'
91 echo ' (minus the .dts extension).'
Michal Simek5f8ffb52009-03-27 14:25:51 +010092endef
Arun Bhanu8a8804f2010-03-17 16:06:03 +080093
94MRPROPER_FILES += $(boot)/simpleImage.*