Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | # SPDX-License-Identifier: GPL-2.0 |
Sam Ravnborg | 74b469f | 2007-10-25 19:42:04 +0200 | [diff] [blame] | 2 | # Unified Makefile for i386 and x86_64 |
| 3 | |
Sam Ravnborg | 2266cfd | 2007-10-25 20:31:19 +0200 | [diff] [blame] | 4 | # select defconfig based on actual architecture |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 5 | ifeq ($(ARCH),x86) |
David Woodhouse | ffee0de | 2012-12-20 21:51:55 +0000 | [diff] [blame] | 6 | ifeq ($(shell uname -m),x86_64) |
| 7 | KBUILD_DEFCONFIG := x86_64_defconfig |
| 8 | else |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 9 | KBUILD_DEFCONFIG := i386_defconfig |
David Woodhouse | ffee0de | 2012-12-20 21:51:55 +0000 | [diff] [blame] | 10 | endif |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 11 | else |
| 12 | KBUILD_DEFCONFIG := $(ARCH)_defconfig |
| 13 | endif |
Sam Ravnborg | 2266cfd | 2007-10-25 20:31:19 +0200 | [diff] [blame] | 14 | |
Peter Zijlstra | b2f825b | 2021-11-19 17:50:24 +0100 | [diff] [blame] | 15 | ifdef CONFIG_CC_IS_GCC |
| 16 | RETPOLINE_CFLAGS := $(call cc-option,-mindirect-branch=thunk-extern -mindirect-branch-register) |
Peter Zijlstra | 68cf4f2 | 2021-11-19 17:50:25 +0100 | [diff] [blame] | 17 | RETPOLINE_CFLAGS += $(call cc-option,-mindirect-branch-cs-prefix) |
Peter Zijlstra | b2f825b | 2021-11-19 17:50:24 +0100 | [diff] [blame] | 18 | RETPOLINE_VDSO_CFLAGS := $(call cc-option,-mindirect-branch=thunk-inline -mindirect-branch-register) |
| 19 | endif |
| 20 | ifdef CONFIG_CC_IS_CLANG |
| 21 | RETPOLINE_CFLAGS := -mretpoline-external-thunk |
| 22 | RETPOLINE_VDSO_CFLAGS := -mretpoline |
| 23 | endif |
| 24 | export RETPOLINE_CFLAGS |
| 25 | export RETPOLINE_VDSO_CFLAGS |
| 26 | |
Matthias Kaehlcke | d77698df | 2017-06-21 16:28:05 -0700 | [diff] [blame] | 27 | # For gcc stack alignment is specified with -mpreferred-stack-boundary, |
| 28 | # clang has the option -mstack-alignment for that purpose. |
| 29 | ifneq ($(call cc-option, -mpreferred-stack-boundary=4),) |
Matthias Kaehlcke | 8f91869 | 2017-08-16 17:47:40 -0700 | [diff] [blame] | 30 | cc_stack_align4 := -mpreferred-stack-boundary=2 |
| 31 | cc_stack_align8 := -mpreferred-stack-boundary=3 |
| 32 | else ifneq ($(call cc-option, -mstack-alignment=16),) |
| 33 | cc_stack_align4 := -mstack-alignment=4 |
| 34 | cc_stack_align8 := -mstack-alignment=8 |
Matthias Kaehlcke | d77698df | 2017-06-21 16:28:05 -0700 | [diff] [blame] | 35 | endif |
| 36 | |
David Woodhouse | 1c678da | 2014-01-08 11:21:20 +0000 | [diff] [blame] | 37 | # How to compile the 16-bit code. Note we always compile for -march=i386; |
| 38 | # that way we can complain to the user if the CPU is insufficient. |
Nick Desaulniers | 2838307 | 2020-11-30 17:13:06 -0800 | [diff] [blame] | 39 | REALMODE_CFLAGS := -m16 -g -Os -DDISABLE_BRANCH_PROFILING \ |
David Woodhouse | 1c678da | 2014-01-08 11:21:20 +0000 | [diff] [blame] | 40 | -Wall -Wstrict-prototypes -march=i386 -mregparm=3 \ |
David Woodhouse | 1c678da | 2014-01-08 11:21:20 +0000 | [diff] [blame] | 41 | -fno-strict-aliasing -fomit-frame-pointer -fno-pic \ |
Arnd Bergmann | 9fcb51c | 2021-03-23 13:48:36 +0100 | [diff] [blame] | 42 | -mno-mmx -mno-sse $(call cc-option,-fcf-protection=none) |
Matthias Kaehlcke | 032a2c4 | 2017-06-21 16:28:04 -0700 | [diff] [blame] | 43 | |
Masahiro Yamada | 685969e | 2020-06-27 03:59:13 +0900 | [diff] [blame] | 44 | REALMODE_CFLAGS += -ffreestanding |
Masahiro Yamada | 893ab004 | 2020-06-27 03:59:12 +0900 | [diff] [blame] | 45 | REALMODE_CFLAGS += -fno-stack-protector |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 46 | REALMODE_CFLAGS += -Wno-address-of-packed-member |
| 47 | REALMODE_CFLAGS += $(cc_stack_align4) |
John Millikin | 8abe7fc | 2021-03-25 17:04:33 -0700 | [diff] [blame] | 48 | REALMODE_CFLAGS += $(CLANG_FLAGS) |
David Woodhouse | 1c678da | 2014-01-08 11:21:20 +0000 | [diff] [blame] | 49 | export REALMODE_CFLAGS |
| 50 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 51 | # BITS is used as extension for files which are available in a 32 bit |
| 52 | # and a 64 bit version to simplify shared Makefiles. |
| 53 | # e.g.: obj-y += foo_$(BITS).o |
| 54 | export BITS |
Sam Ravnborg | 74b469f | 2007-10-25 19:42:04 +0200 | [diff] [blame] | 55 | |
Andy Lutomirski | b2c5110 | 2015-07-21 09:27:18 -0700 | [diff] [blame] | 56 | # |
| 57 | # Prevent GCC from generating any FP code by mistake. |
| 58 | # |
| 59 | # This must happen before we try the -mpreferred-stack-boundary, see: |
| 60 | # |
| 61 | # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53383 |
| 62 | # |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 63 | KBUILD_CFLAGS += -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx |
Andy Lutomirski | b2c5110 | 2015-07-21 09:27:18 -0700 | [diff] [blame] | 64 | |
Borislav Petkov | 256b92a | 2021-02-08 16:43:30 +0100 | [diff] [blame] | 65 | # Intel CET isn't enabled in the kernel |
| 66 | KBUILD_CFLAGS += $(call cc-option,-fcf-protection=none) |
| 67 | |
Sam Ravnborg | d746d64 | 2007-11-12 20:14:19 +0100 | [diff] [blame] | 68 | ifeq ($(CONFIG_X86_32),y) |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 69 | BITS := 32 |
Andreas Herrmann | 8c6531f | 2007-11-19 23:58:57 +0100 | [diff] [blame] | 70 | UTS_MACHINE := i386 |
Sam Ravnborg | 4ba7e5c | 2008-01-30 13:32:23 +0100 | [diff] [blame] | 71 | CHECKFLAGS += -D__i386__ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 72 | |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 73 | KBUILD_AFLAGS += -m32 |
| 74 | KBUILD_CFLAGS += -m32 |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 75 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 76 | KBUILD_CFLAGS += -msoft-float -mregparm=3 -freg-struct-return |
| 77 | |
Andrew Boie | 484d90e | 2012-08-10 11:49:06 -0700 | [diff] [blame] | 78 | # Never want PIC in a 32-bit kernel, prevent breakage with GCC built |
| 79 | # with nonstandard options |
| 80 | KBUILD_CFLAGS += -fno-pic |
| 81 | |
Matthias Kaehlcke | d77698df | 2017-06-21 16:28:05 -0700 | [diff] [blame] | 82 | # Align the stack to the register width instead of using the default |
| 83 | # alignment of 16 bytes. This reduces stack usage and the number of |
| 84 | # alignment instructions. |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 85 | KBUILD_CFLAGS += $(cc_stack_align4) |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 86 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 87 | # CPU-specific tuning. Anything which can be shared with UML should go here. |
Masahiro Yamada | d8285639 | 2021-07-25 03:35:56 +0900 | [diff] [blame] | 88 | include $(srctree)/arch/x86/Makefile_32.cpu |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 89 | KBUILD_CFLAGS += $(cflags-y) |
| 90 | |
| 91 | # temporary until string.h is fixed |
| 92 | KBUILD_CFLAGS += -ffreestanding |
Andy Lutomirski | 3fb0fdb | 2021-02-13 11:19:44 -0800 | [diff] [blame] | 93 | |
| 94 | ifeq ($(CONFIG_STACKPROTECTOR),y) |
| 95 | ifeq ($(CONFIG_SMP),y) |
| 96 | KBUILD_CFLAGS += -mstack-protector-guard-reg=fs -mstack-protector-guard-symbol=__stack_chk_guard |
| 97 | else |
| 98 | KBUILD_CFLAGS += -mstack-protector-guard=global |
| 99 | endif |
| 100 | endif |
Sam Ravnborg | 74b469f | 2007-10-25 19:42:04 +0200 | [diff] [blame] | 101 | else |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 102 | BITS := 64 |
Andreas Herrmann | 8c6531f | 2007-11-19 23:58:57 +0100 | [diff] [blame] | 103 | UTS_MACHINE := x86_64 |
Luc Van Oostenryck | 1f2f01b | 2018-05-30 22:48:38 +0200 | [diff] [blame] | 104 | CHECKFLAGS += -D__x86_64__ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 105 | |
| 106 | KBUILD_AFLAGS += -m64 |
| 107 | KBUILD_CFLAGS += -m64 |
| 108 | |
Ingo Molnar | be6cb02 | 2015-04-10 14:08:46 +0200 | [diff] [blame] | 109 | # Align jump targets to 1 byte, not the default 16 bytes: |
Matthias Kaehlcke | 2c4fd1a | 2017-04-13 10:26:09 -0700 | [diff] [blame] | 110 | KBUILD_CFLAGS += $(call cc-option,-falign-jumps=1) |
Ingo Molnar | be6cb02 | 2015-04-10 14:08:46 +0200 | [diff] [blame] | 111 | |
Ingo Molnar | 52648e8 | 2015-05-17 07:56:54 +0200 | [diff] [blame] | 112 | # Pack loops tightly as well: |
Matthias Kaehlcke | 2c4fd1a | 2017-04-13 10:26:09 -0700 | [diff] [blame] | 113 | KBUILD_CFLAGS += $(call cc-option,-falign-loops=1) |
Ingo Molnar | 52648e8 | 2015-05-17 07:56:54 +0200 | [diff] [blame] | 114 | |
Rasmus Villemoes | 5c63008 | 2014-09-10 18:05:39 +0200 | [diff] [blame] | 115 | # Don't autogenerate traditional x87 instructions |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 116 | KBUILD_CFLAGS += -mno-80387 |
Behan Webster | 8f2dd67 | 2014-04-21 22:40:27 -0700 | [diff] [blame] | 117 | KBUILD_CFLAGS += $(call cc-option,-mno-fp-ret-in-387) |
H. Peter Anvin | 5551a34 | 2013-11-20 13:31:49 -0800 | [diff] [blame] | 118 | |
Matthias Kaehlcke | d77698df | 2017-06-21 16:28:05 -0700 | [diff] [blame] | 119 | # By default gcc and clang use a stack alignment of 16 bytes for x86. |
| 120 | # However the standard kernel entry on x86-64 leaves the stack on an |
| 121 | # 8-byte boundary. If the compiler isn't informed about the actual |
| 122 | # alignment it will generate extra alignment instructions for the |
| 123 | # default alignment which keep the stack *mis*aligned. |
| 124 | # Furthermore an alignment to the register width reduces stack usage |
| 125 | # and the number of alignment instructions. |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 126 | KBUILD_CFLAGS += $(cc_stack_align8) |
H.J. Lu | d9b0cde9 | 2012-05-29 14:31:23 -0700 | [diff] [blame] | 127 | |
H.J. Lu | d9ee948d | 2014-12-17 18:05:29 -0800 | [diff] [blame] | 128 | # Use -mskip-rax-setup if supported. |
| 129 | KBUILD_CFLAGS += $(call cc-option,-mskip-rax-setup) |
| 130 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 131 | # FIXME - should be integrated in Makefile.cpu (Makefile_32.cpu) |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 132 | cflags-$(CONFIG_MK8) += -march=k8 |
| 133 | cflags-$(CONFIG_MPSC) += -march=nocona |
| 134 | cflags-$(CONFIG_MCORE2) += -march=core2 |
| 135 | cflags-$(CONFIG_MATOM) += -march=atom |
| 136 | cflags-$(CONFIG_GENERIC_CPU) += -mtune=generic |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 137 | KBUILD_CFLAGS += $(cflags-y) |
| 138 | |
| 139 | KBUILD_CFLAGS += -mno-red-zone |
| 140 | KBUILD_CFLAGS += -mcmodel=kernel |
Tejun Heo | 5d707e9 | 2009-02-09 22:17:39 +0900 | [diff] [blame] | 141 | endif |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 142 | |
H. Peter Anvin | 0bf6276 | 2012-02-27 14:09:10 -0800 | [diff] [blame] | 143 | ifdef CONFIG_X86_X32 |
| 144 | x32_ld_ok := $(call try-run,\ |
| 145 | /bin/echo -e '1: .quad 1b' | \ |
Jean Delvare | b1e0d8b | 2012-10-02 16:42:36 +0200 | [diff] [blame] | 146 | $(CC) $(KBUILD_AFLAGS) -c -x assembler -o "$$TMP" - && \ |
Masahiro Yamada | e345605 | 2021-04-15 16:26:59 +0900 | [diff] [blame] | 147 | $(OBJCOPY) -O elf32-x86-64 "$$TMP" "$$TMP.o" && \ |
| 148 | $(LD) -m elf32_x86_64 "$$TMP.o" -o "$$TMP",y,n) |
Ingo Molnar | 8bd69c2 | 2012-02-28 10:35:06 +0100 | [diff] [blame] | 149 | ifeq ($(x32_ld_ok),y) |
| 150 | CONFIG_X86_X32_ABI := y |
| 151 | KBUILD_AFLAGS += -DCONFIG_X86_X32_ABI |
| 152 | KBUILD_CFLAGS += -DCONFIG_X86_X32_ABI |
| 153 | else |
| 154 | $(warning CONFIG_X86_X32 enabled but no binutils support) |
| 155 | endif |
H. Peter Anvin | 0bf6276 | 2012-02-27 14:09:10 -0800 | [diff] [blame] | 156 | endif |
| 157 | export CONFIG_X86_X32_ABI |
| 158 | |
Josh Poimboeuf | 3f135e5 | 2017-03-16 14:31:33 -0500 | [diff] [blame] | 159 | # |
| 160 | # If the function graph tracer is used with mcount instead of fentry, |
| 161 | # '-maccumulate-outgoing-args' is needed to prevent a GCC bug |
| 162 | # (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=42109) |
| 163 | # |
| 164 | ifdef CONFIG_FUNCTION_GRAPH_TRACER |
| 165 | ifndef CONFIG_HAVE_FENTRY |
| 166 | ACCUMULATE_OUTGOING_ARGS := 1 |
Josh Poimboeuf | 3f135e5 | 2017-03-16 14:31:33 -0500 | [diff] [blame] | 167 | endif |
| 168 | endif |
| 169 | |
Josh Poimboeuf | 3f135e5 | 2017-03-16 14:31:33 -0500 | [diff] [blame] | 170 | ifeq ($(ACCUMULATE_OUTGOING_ARGS), 1) |
Nick Desaulniers | 4a1bec4 | 2017-05-08 20:29:46 -0700 | [diff] [blame] | 171 | # This compiler flag is not supported by Clang: |
| 172 | KBUILD_CFLAGS += $(call cc-option,-maccumulate-outgoing-args,) |
Josh Poimboeuf | 3f135e5 | 2017-03-16 14:31:33 -0500 | [diff] [blame] | 173 | endif |
| 174 | |
Sam Ravnborg | 25dfeeb | 2008-01-30 13:32:21 +0100 | [diff] [blame] | 175 | # Workaround for a gcc prelease that unfortunately was shipped in a suse release |
| 176 | KBUILD_CFLAGS += -Wno-sign-compare |
| 177 | # |
| 178 | KBUILD_CFLAGS += -fno-asynchronous-unwind-tables |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 179 | |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 180 | # Avoid indirect branches in kernel to deal with Spectre |
| 181 | ifdef CONFIG_RETPOLINE |
Zhenzhong Duan | 4cd24de | 2018-11-02 01:45:41 -0700 | [diff] [blame] | 182 | KBUILD_CFLAGS += $(RETPOLINE_CFLAGS) |
Daniel Borkmann | ce02ef06 | 2019-02-21 23:19:41 +0100 | [diff] [blame] | 183 | # Additionally, avoid generating expensive indirect jumps which |
| 184 | # are subject to retpolines for small number of switch cases. |
| 185 | # clang turns off jump table generation by default when under |
Daniel Borkmann | a9d57ef | 2019-03-25 14:56:20 +0100 | [diff] [blame] | 186 | # retpoline builds, however, gcc does not for x86. This has |
| 187 | # only been fixed starting from gcc stable version 8.4.0 and |
| 188 | # onwards, but not for older ones. See gcc bug #86952. |
| 189 | ifndef CONFIG_CC_IS_CLANG |
Nick Desaulniers | 989ceac | 2021-08-12 11:38:48 -0700 | [diff] [blame] | 190 | KBUILD_CFLAGS += -fno-jump-tables |
Daniel Borkmann | a9d57ef | 2019-03-25 14:56:20 +0100 | [diff] [blame] | 191 | endif |
David Woodhouse | 76b0438 | 2018-01-11 21:46:25 +0000 | [diff] [blame] | 192 | endif |
| 193 | |
Peter Zijlstra | e463a09 | 2021-12-04 14:43:44 +0100 | [diff] [blame] | 194 | ifdef CONFIG_SLS |
| 195 | KBUILD_CFLAGS += -mharden-sls=all |
| 196 | endif |
| 197 | |
Nathan Chancellor | 0024430 | 2021-05-18 12:01:06 -0700 | [diff] [blame] | 198 | KBUILD_LDFLAGS += -m elf_$(UTS_MACHINE) |
| 199 | |
| 200 | ifdef CONFIG_LTO_CLANG |
Tor Vic | 2398ce8 | 2021-06-10 20:58:06 +0000 | [diff] [blame] | 201 | ifeq ($(shell test $(CONFIG_LLD_VERSION) -lt 130000; echo $$?),0) |
| 202 | KBUILD_LDFLAGS += -plugin-opt=-stack-alignment=$(if $(CONFIG_X86_32),4,8) |
| 203 | endif |
Nathan Chancellor | 0024430 | 2021-05-18 12:01:06 -0700 | [diff] [blame] | 204 | endif |
Arvind Sankar | 587af64 | 2020-07-22 14:43:34 -0400 | [diff] [blame] | 205 | |
| 206 | ifdef CONFIG_X86_NEED_RELOCS |
| 207 | LDFLAGS_vmlinux := --emit-relocs --discard-none |
| 208 | else |
| 209 | LDFLAGS_vmlinux := |
| 210 | endif |
| 211 | |
| 212 | # |
| 213 | # The 64-bit kernel must be aligned to 2MB. Pass -z max-page-size=0x200000 to |
| 214 | # the linker to force 2MB page size regardless of the default page size used |
| 215 | # by the linker. |
| 216 | # |
| 217 | ifdef CONFIG_X86_64 |
| 218 | LDFLAGS_vmlinux += -z max-page-size=0x200000 |
| 219 | endif |
| 220 | |
Kees Cook | 83109d5 | 2020-09-01 19:53:46 -0700 | [diff] [blame] | 221 | |
Michal Marek | 3ce9e53 | 2012-10-15 21:16:56 +0200 | [diff] [blame] | 222 | archscripts: scripts_basic |
H. Peter Anvin | 6520fe5 | 2012-05-08 21:22:24 +0300 | [diff] [blame] | 223 | $(Q)$(MAKE) $(build)=arch/x86/tools relocs |
| 224 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 225 | ### |
H. Peter Anvin | 303395a | 2011-11-11 16:07:41 -0800 | [diff] [blame] | 226 | # Syscall table generation |
| 227 | |
| 228 | archheaders: |
Ingo Molnar | 1f57d5d | 2015-06-03 18:36:41 +0200 | [diff] [blame] | 229 | $(Q)$(MAKE) $(build)=arch/x86/entry/syscalls all |
H. Peter Anvin | 303395a | 2011-11-11 16:07:41 -0800 | [diff] [blame] | 230 | |
| 231 | ### |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 232 | # Kernel objects |
| 233 | |
Eric W. Biederman | 700efc1 | 2008-02-23 09:58:20 +0100 | [diff] [blame] | 234 | head-y := arch/x86/kernel/head_$(BITS).o |
| 235 | head-y += arch/x86/kernel/head$(BITS).o |
Luis R. Rodriguez | f2d8529 | 2016-04-13 17:04:43 -0700 | [diff] [blame] | 236 | head-y += arch/x86/kernel/ebda.o |
Luis R. Rodriguez | 8d152e7 | 2016-04-13 17:04:34 -0700 | [diff] [blame] | 237 | head-y += arch/x86/kernel/platform-quirks.o |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 238 | |
| 239 | libs-y += arch/x86/lib/ |
| 240 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 241 | # drivers-y are linked after core-y |
| 242 | drivers-$(CONFIG_MATH_EMULATION) += arch/x86/math-emu/ |
| 243 | drivers-$(CONFIG_PCI) += arch/x86/pci/ |
| 244 | |
Rafael J. Wysocki | cf7700f | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 245 | # suspend and hibernation support |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 246 | drivers-$(CONFIG_PM) += arch/x86/power/ |
Rafael J. Wysocki | cf7700f | 2008-02-09 23:24:09 +0100 | [diff] [blame] | 247 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 248 | drivers-$(CONFIG_FB) += arch/x86/video/ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 249 | |
| 250 | #### |
| 251 | # boot loader support. Several targets are kept for legacy purposes |
| 252 | |
| 253 | boot := arch/x86/boot |
| 254 | |
H. Peter Anvin (Intel) | f279b49 | 2021-05-10 01:28:40 -0700 | [diff] [blame] | 255 | BOOT_TARGETS = bzdisk fdimage fdimage144 fdimage288 hdimage isoimage |
H. Peter Anvin | f9c5107 | 2009-03-12 12:50:33 -0700 | [diff] [blame] | 256 | |
| 257 | PHONY += bzImage $(BOOT_TARGETS) |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 258 | |
| 259 | # Default kernel to build |
| 260 | all: bzImage |
| 261 | |
| 262 | # KBUILD_IMAGE specify target image being built |
H. Peter Anvin | f9c5107 | 2009-03-12 12:50:33 -0700 | [diff] [blame] | 263 | KBUILD_IMAGE := $(boot)/bzImage |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 264 | |
H. Peter Anvin | f9c5107 | 2009-03-12 12:50:33 -0700 | [diff] [blame] | 265 | bzImage: vmlinux |
Masami Hiramatsu | ca0e9ba | 2009-08-13 16:34:21 -0400 | [diff] [blame] | 266 | ifeq ($(CONFIG_X86_DECODER_SELFTEST),y) |
| 267 | $(Q)$(MAKE) $(build)=arch/x86/tools posttest |
| 268 | endif |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 269 | $(Q)$(MAKE) $(build)=$(boot) $(KBUILD_IMAGE) |
| 270 | $(Q)mkdir -p $(objtree)/arch/$(UTS_MACHINE)/boot |
Jan Beulich | 41b3eae | 2008-04-22 16:29:26 +0100 | [diff] [blame] | 271 | $(Q)ln -fsn ../../x86/boot/bzImage $(objtree)/arch/$(UTS_MACHINE)/boot/$@ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 272 | |
H. Peter Anvin | f9c5107 | 2009-03-12 12:50:33 -0700 | [diff] [blame] | 273 | $(BOOT_TARGETS): vmlinux |
| 274 | $(Q)$(MAKE) $(build)=$(boot) $@ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 275 | |
Masahiro Yamada | 6d61b8e | 2021-07-29 23:00:22 +0900 | [diff] [blame] | 276 | PHONY += install |
| 277 | install: |
Masahiro Yamada | 0815512 | 2021-07-29 23:00:23 +0900 | [diff] [blame] | 278 | $(CONFIG_SHELL) $(srctree)/$(boot)/install.sh $(KERNELRELEASE) \ |
| 279 | $(KBUILD_IMAGE) System.map "$(INSTALL_PATH)" |
H. Peter Anvin | 1648e4f | 2009-04-17 10:46:37 -0700 | [diff] [blame] | 280 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 281 | PHONY += vdso_install |
| 282 | vdso_install: |
Ingo Molnar | d603c8e | 2015-06-03 18:05:44 +0200 | [diff] [blame] | 283 | $(Q)$(MAKE) $(build)=arch/x86/entry/vdso $@ |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 284 | |
Ben Hutchings | 829fe4a | 2018-08-29 20:43:17 +0100 | [diff] [blame] | 285 | archprepare: checkbin |
| 286 | checkbin: |
Masahiro Yamada | e9666d1 | 2018-12-31 00:14:15 +0900 | [diff] [blame] | 287 | ifndef CONFIG_CC_HAS_ASM_GOTO |
Ben Hutchings | 829fe4a | 2018-08-29 20:43:17 +0100 | [diff] [blame] | 288 | @echo Compiler lacks asm-goto support. |
| 289 | @exit 1 |
| 290 | endif |
Masahiro Yamada | 25896d0 | 2018-12-05 15:27:19 +0900 | [diff] [blame] | 291 | ifdef CONFIG_RETPOLINE |
| 292 | ifeq ($(RETPOLINE_CFLAGS),) |
| 293 | @echo "You are building kernel with non-retpoline compiler." >&2 |
| 294 | @echo "Please update your compiler." >&2 |
| 295 | @false |
| 296 | endif |
| 297 | endif |
Ben Hutchings | 829fe4a | 2018-08-29 20:43:17 +0100 | [diff] [blame] | 298 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 299 | archclean: |
| 300 | $(Q)rm -rf $(objtree)/arch/i386 |
| 301 | $(Q)rm -rf $(objtree)/arch/x86_64 |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 302 | |
| 303 | define archhelp |
Borislav Petkov | ac5d088 | 2020-12-17 14:42:00 +0100 | [diff] [blame] | 304 | echo '* bzImage - Compressed kernel image (arch/x86/boot/bzImage)' |
| 305 | echo ' install - Install kernel using (your) ~/bin/$(INSTALLKERNEL) or' |
| 306 | echo ' (distribution) /sbin/$(INSTALLKERNEL) or install to ' |
| 307 | echo ' $$(INSTALL_PATH) and run lilo' |
| 308 | echo '' |
| 309 | echo ' fdimage - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' |
| 310 | echo ' fdimage144 - Create 1.4MB boot floppy image (arch/x86/boot/fdimage)' |
| 311 | echo ' fdimage288 - Create 2.8MB boot floppy image (arch/x86/boot/fdimage)' |
H. Peter Anvin (Intel) | f279b49 | 2021-05-10 01:28:40 -0700 | [diff] [blame] | 312 | echo ' hdimage - Create a BIOS/EFI hard disk image (arch/x86/boot/hdimage)' |
Borislav Petkov | ac5d088 | 2020-12-17 14:42:00 +0100 | [diff] [blame] | 313 | echo ' isoimage - Create a boot CD-ROM image (arch/x86/boot/image.iso)' |
H. Peter Anvin (Intel) | f279b49 | 2021-05-10 01:28:40 -0700 | [diff] [blame] | 314 | echo ' bzdisk/fdimage*/hdimage/isoimage also accept:' |
Borislav Petkov | ac5d088 | 2020-12-17 14:42:00 +0100 | [diff] [blame] | 315 | echo ' FDARGS="..." arguments for the booted kernel' |
Elyes HAOUAS | a757ac5 | 2021-10-28 14:10:21 +0200 | [diff] [blame] | 316 | echo ' FDINITRD=file initrd for the booted kernel' |
Borislav Petkov | ac5d088 | 2020-12-17 14:42:00 +0100 | [diff] [blame] | 317 | echo '' |
| 318 | echo ' kvm_guest.config - Enable Kconfig items for running this kernel as a KVM guest' |
| 319 | echo ' xen.config - Enable Kconfig items for running this kernel as a Xen guest' |
Borislav Petkov | fbaf0aa | 2020-12-17 13:13:34 +0100 | [diff] [blame] | 320 | |
Sam Ravnborg | 0a6ef37 | 2008-01-30 13:32:20 +0100 | [diff] [blame] | 321 | endef |