xref: /linux/arch/microblaze/Makefile (revision 18f90d372cf35b387663f1567de701e5393f6eb5)
1# SPDX-License-Identifier: GPL-2.0
2KBUILD_DEFCONFIG := mmu_defconfig
3
4ifeq ($(CONFIG_MMU),y)
5UTS_SYSNAME = -DUTS_SYSNAME=\"Linux\"
6else
7UTS_SYSNAME = -DUTS_SYSNAME=\"uClinux\"
8endif
9
10# What CPU vesion are we building for, and crack it open
11# as major.minor.rev
12CPU_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)
16
17export CPU_VER CPU_MAJOR CPU_MINOR CPU_REV
18
19# Use cpu-related CONFIG_ vars to set compile options.
20# The various CONFIG_XILINX cpu features options are integers 0/1/2...
21# rather than bools y/n
22
23# Work out HW multipler support. This is tricky.
24# 1. Spartan2 has no HW multipliers.
25# 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
31    # USE_HW_MUL can be 0, 1, or 2, defining a hierarchy of HW Mul support.
32    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
38CPUFLAGS-$(CONFIG_XILINX_MICROBLAZE0_USE_PCMP_INSTR) += -mxl-pattern-compare
39
40ifdef CONFIG_CPU_BIG_ENDIAN
41KBUILD_CFLAGS += -mbig-endian
42KBUILD_AFLAGS += -mbig-endian
43KBUILD_LDFLAGS += -EB
44else
45KBUILD_CFLAGS += -mlittle-endian
46KBUILD_AFLAGS += -mlittle-endian
47KBUILD_LDFLAGS += -EL
48endif
49
50CPUFLAGS-1 += $(call cc-option,-mcpu=v$(CPU_VER))
51
52# r31 holds current when in kernel mode
53KBUILD_CFLAGS += -ffixed-r31 $(CPUFLAGS-y) $(CPUFLAGS-1) $(CPUFLAGS-2)
54
55head-y := arch/microblaze/kernel/head.o
56libs-y += arch/microblaze/lib/
57core-y += arch/microblaze/kernel/
58core-y += arch/microblaze/mm/
59core-$(CONFIG_PCI) += arch/microblaze/pci/
60
61drivers-$(CONFIG_OPROFILE) += arch/microblaze/oprofile/
62
63boot := arch/microblaze/boot
64
65# Are we making a simpleImage.<boardname> target? If so, crack out the boardname
66DTB:=$(subst simpleImage.,,$(filter simpleImage.%, $(MAKECMDGOALS)))
67
68core-y	+= $(boot)/dts/
69
70# defines filename extension depending memory management type
71ifeq ($(CONFIG_MMU),)
72MMU := -nommu
73endif
74
75export MMU DTB
76
77all: linux.bin
78
79archclean:
80	$(Q)$(MAKE) $(clean)=$(boot)
81
82archheaders:
83	$(Q)$(MAKE) $(build)=arch/microblaze/kernel/syscalls all
84
85PHONY += linux.bin linux.bin.gz linux.bin.ub
86linux.bin.ub linux.bin.gz: linux.bin
87linux.bin: vmlinux
88linux.bin linux.bin.gz linux.bin.ub:
89	$(Q)$(MAKE) $(build)=$(boot) $(boot)/$@
90	@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
91
92PHONY += simpleImage.$(DTB)
93simpleImage.$(DTB): vmlinux
94	$(Q)$(MAKE) $(build)=$(boot) $(addprefix $(boot)/$@., ub unstrip strip)
95	@echo 'Kernel: $(boot)/$@ is ready' ' (#'`cat .version`')'
96
97define archhelp
98  echo '* linux.bin    - Create raw binary'
99  echo '  linux.bin.gz - Create compressed raw binary'
100  echo '  linux.bin.ub - Create U-Boot wrapped raw binary'
101  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'
106  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).'
111endef
112
113MRPROPER_FILES += $(boot)/simpleImage.*
114