blob: 7b340a35b194bb93506eb366f87865e33c39f990 [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
Rob Herring37c8a5f2018-01-10 15:19:37 -060068core-y += $(boot)/dts/
Michal Simekf05131c2009-09-14 15:15:49 +020069
Michal Simek5f8ffb52009-03-27 14:25:51 +010070# defines filename extension depending memory management type
71ifeq ($(CONFIG_MMU),)
Sam Ravnborg950b2602009-07-24 09:04:49 +020072MMU := -nommu
Michal Simek5f8ffb52009-03-27 14:25:51 +010073endif
Sam Ravnborg950b2602009-07-24 09:04:49 +020074
Michal Simekf05131c2009-09-14 15:15:49 +020075export MMU DTB
Michal Simek5f8ffb52009-03-27 14:25:51 +010076
77all: linux.bin
78
79archclean:
80 $(Q)$(MAKE) $(clean)=$(boot)
81
Firoz Khan1e17ab52018-11-13 11:34:34 +053082archheaders:
83 $(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
84
Masahiro Yamada3dda5632018-12-07 20:33:55 +090085PHONY += linux.bin linux.bin.gz linux.bin.ub
Masahiro Yamada52e79c42018-12-07 20:33:56 +090086linux.bin.ub linux.bin.gz: linux.bin
87linux.bin: vmlinux
88linux.bin linux.bin.gz linux.bin.ub:
Thomas Backlundb843e4e2010-10-21 13:19:10 +030089 $(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
Masahiro Yamada2e14f942018-12-07 20:33:53 +090090 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Jason Wu5f5e3232013-01-31 13:59:09 +100091
Masahiro Yamada3dda5632018-12-07 20:33:55 +090092PHONY += simpleImage.$(DTB)
93simpleImage.$(DTB): vmlinux
Masahiro Yamada4722a3e62018-12-07 20:33:54 +090094 $(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
Masahiro Yamada2e14f942018-12-07 20:33:53 +090095 @echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
Michal Simek5f8ffb52009-03-27 14:25:51 +010096
97define archhelp
Michal Simekf05131c2009-09-14 15:15:49 +020098 echo '* linux.bin - Create raw binary'
99 echo ' linux.bin.gz - Create compressed raw binary'
Jason Wuec2eba52013-08-21 07:10:32 +0200100 echo ' linux.bin.ub - Create U-Boot wrapped raw binary'
Masahiro Yamadabafcc612018-12-07 20:33:52 +0900101 echo ' simpleImage.<dt> - Create the following images with <dt>.dtb linked in'
102 echo ' simpleImage.<dt> : raw image'
103 echo ' simpleImage.<dt>.ub : raw image with U-Boot header'
104 echo ' simpleImage.<dt>.unstrip: ELF (identical to vmlinux)'
105 echo ' simpleImage.<dt>.strip : stripped ELF'
Michal Simekf05131c2009-09-14 15:15:49 +0200106 echo ' Targets with <dt> embed a device tree blob inside the image'
107 echo ' These targets support board with firmware that does not'
108 echo ' support passing a device tree directly. Replace <dt> with the'
109 echo ' name of a dts file from the arch/microblaze/boot/dts/ directory'
110 echo ' (minus the .dts extension).'
Michal Simek5f8ffb52009-03-27 14:25:51 +0100111endef
Arun Bhanu8a8804f2010-03-17 16:06:03 +0800112
113MRPROPER_FILES += $(boot)/simpleImage.*