blob: 548bac6c60f8ccd18216e58f99197034c313b41a [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 +02004ifeq ($(CONFIG_MMU),y)
5UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
6else
Michal Simek5f8ffb52009-03-27 14:25:51 +01007UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
Michal Simek4b2368f2009-05-26 16:30:32 +02008endif
Michal Simek5f8ffb52009-03-27 14:25:51 +01009
10# What CPU vesion are we building for, and crack it open
11# as major.minor.rev
Sam Ravnborg950b2602009-07-24 09:04:49 +020012CPU_VER := $(shell echo $(CONFIG_XILINX_MICROBLAZE0_HW_VER))
13CPU_MAJOR := $(shell echo $(CPU_VER) | cut -d '.' -f 1)
14CPU_MINOR := $(shell echo $(CPU_VER) | cut -d '.' -f 2)
15CPU_REV := $(shell echo $(CPU_VER) | cut -d '.' -f 3)
Michal Simek5f8ffb52009-03-27 14:25:51 +010016
17export CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
18
19# Use cpu-related CONFIG_ vars to set compile options.
Sam Ravnborg950b2602009-07-24 09:04:49 +020020# The various CONFIG_XILINX cpu features options are integers 0/1/2...
21# rather than bools y/n
Michal Simek5f8ffb52009-03-27 14:25:51 +010022
Michal Simek7f01af02011-01-03 11:35:28 +010023# Work out HW multipler support. This is tricky.
Lucas De Marchi25985ed2011-03-30 22:57:33 -030024# 1. Spartan2 has no HW multipliers.
Michal Simek5f8ffb52009-03-27 14:25:51 +010025# 2. MicroBlaze v3.x always uses them, except in Spartan 2
26# 3. All other FPGa/CPU ver combos, we can trust the CONFIG_ settings
27ifeq (,$(findstring spartan2,$(CONFIG_XILINX_MICROBLAZE0_FAMILY)))
28 ifeq ($(CPU_MAJOR),3)
29 CPUFLAGS-1 += -mno-xl-soft-mul
30 else
Uwe Kleine-König732bee72010-06-11 12:16:59 +020031 # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
Michal Simek5f8ffb52009-03-27 14:25:51 +010032 CPUFLAGS-$(subst 1,,$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL)) += -mxl-multiply-high
33 CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_HW_MUL) += -mno-xl-soft-mul
34 endif
35endif
36CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_DIV) += -mno-xl-soft-div
37CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_BARREL) += -mxl-barrel-shift
Michal Simek04e3a552009-04-20 09:56:24 +020038CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
Arnd Bergmann71e76732018-01-02 12:47:19 +010039
40ifdef CONFIG_CPU_BIG_ENDIAN
41KBUILD_CFLAGS += -mbig-endian
42KBUILD_AFLAGS += -mbig-endian
Masahiro Yamadad503ac52018-08-24 08:20:39 +090043KBUILD_LDFLAGS += -EB
Arnd Bergmann71e76732018-01-02 12:47:19 +010044else
45KBUILD_CFLAGS += -mlittle-endian
46KBUILD_AFLAGS += -mlittle-endian
Masahiro Yamadad503ac52018-08-24 08:20:39 +090047KBUILD_LDFLAGS += -EL
Arnd Bergmann71e76732018-01-02 12:47:19 +010048endif
Michal Simek5f8ffb52009-03-27 14:25:51 +010049
50CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
51
Michal Simek5f8ffb52009-03-27 14:25:51 +010052# r31 holds current when in kernel mode
Arnd Bergmann71e76732018-01-02 12:47:19 +010053KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
Michal Simek5f8ffb52009-03-27 14:25:51 +010054
Sam Ravnborg950b2602009-07-24 09:04:49 +020055head-y := arch/microblaze/kernel/head.o
56libs-y += arch/microblaze/lib/
Sam Ravnborg950b2602009-07-24 09:04:49 +020057core-y += arch/microblaze/kernel/
58core-y += arch/microblaze/mm/
Michal Simeka6475c12010-01-18 15:27:10 +010059core-$(CONFIG_PCI) += arch/microblaze/pci/
Michal Simek5f8ffb52009-03-27 14:25:51 +010060
John Williams3540ce82009-11-24 20:27:54 +100061drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
62
Sam Ravnborg950b2602009-07-24 09:04:49 +020063boot := arch/microblaze/boot
Michal Simek5f8ffb52009-03-27 14:25:51 +010064
Michal Simekf05131c2009-09-14 15:15:49 +020065# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
66DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
67
68ifneq ($(DTB),)
Stephen Warren300db342012-11-27 16:29:15 -070069 core-y += $(boot)/dts/
Michal Simekf05131c2009-09-14 15:15:49 +020070endif
71
Michal Simek5f8ffb52009-03-27 14:25:51 +010072# defines filename extension depending memory management type
73ifeq ($(CONFIG_MMU),)
Sam Ravnborg950b2602009-07-24 09:04:49 +020074MMU := -nommu
Michal Simek5f8ffb52009-03-27 14:25:51 +010075endif
Sam Ravnborg950b2602009-07-24 09:04:49 +020076
Michal Simekf05131c2009-09-14 15:15:49 +020077export MMU DTB
Michal Simek5f8ffb52009-03-27 14:25:51 +010078
79all: linux.bin
80
81archclean:
82 $(Q)$(MAKE) $(clean)=$(boot)
83
Jason Wuec2eba52013-08-21 07:10:32 +020084linux.bin linux.bin.gz linux.bin.ub: vmlinux
Thomas Backlundb843e4e2010-10-21 13:19:10 +030085 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
Masahiro Yamada04bafea2018-12-07 20:33:53 +090086 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Jason Wu5f5e3232013-01-31 13:59:09 +100087
88simpleImage.%: vmlinux
Masahiro Yamada694c90c2018-12-07 20:33:54 +090089 $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
Masahiro Yamada04bafea2018-12-07 20:33:53 +090090 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Michal Simek5f8ffb52009-03-27 14:25:51 +010091
92define archhelp
Michal Simekf05131c2009-09-14 15:15:49 +020093 echo '* linux.bin - Create raw binary'
94 echo ' linux.bin.gz - Create compressed raw binary'
Jason Wuec2eba52013-08-21 07:10:32 +020095 echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
Masahiro Yamada4e860e92018-12-07 20:33:52 +090096 echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
97 echo ' simpleImage.<dt> : raw image'
98 echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
99 echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
100 echo ' simpleImage.<dt>.strip : stripped ELF'
Michal Simekf05131c2009-09-14 15:15:49 +0200101 echo ' Targets with <dt> embed a device tree blob inside the image'
102 echo ' These targets support board with firmware that does not'
103 echo ' support passing a device tree directly. Replace <dt> with the'
104 echo ' name of a dts file from the arch/microblaze/boot/dts/ directory'
105 echo ' (minus the .dts extension).'
Michal Simek5f8ffb52009-03-27 14:25:51 +0100106endef
Arun Bhanu8a8804f2010-03-17 16:06:03 +0800107
108MRPROPER_FILES += $(boot)/simpleImage.*