11da177e4SLinus Torvalds# 24f193362SPaul Smith# This file is included by the global makefile so that you can add your own 34f193362SPaul Smith# architecture-specific flags and dependencies. 44f193362SPaul Smith# 54c9e1385SJeff Dike# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 61da177e4SLinus Torvalds# Licensed under the GPL 71da177e4SLinus Torvalds# 81da177e4SLinus Torvalds 9e40f04d0SRamkumar Ramachandra# select defconfig based on actual architecture 10e40f04d0SRamkumar Ramachandraifeq ($(SUBARCH),x86) 11e40f04d0SRamkumar Ramachandra ifeq ($(shell uname -m),x86_64) 12e40f04d0SRamkumar Ramachandra KBUILD_DEFCONFIG := x86_64_defconfig 13e40f04d0SRamkumar Ramachandra else 14e40f04d0SRamkumar Ramachandra KBUILD_DEFCONFIG := i386_defconfig 15e40f04d0SRamkumar Ramachandra endif 16e40f04d0SRamkumar Ramachandraelse 17e40f04d0SRamkumar Ramachandra KBUILD_DEFCONFIG := $(SUBARCH)_defconfig 18e40f04d0SRamkumar Ramachandraendif 19e40f04d0SRamkumar Ramachandra 201da177e4SLinus TorvaldsARCH_DIR := arch/um 211da177e4SLinus Torvalds# We require bash because the vmlinux link and loader script cpp use bash 221da177e4SLinus Torvalds# features. 2319ee6923SYueh-Shun LiSHELL := bash 241da177e4SLinus Torvalds 258569c914SAl ViroMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 261da177e4SLinus Torvalds 277bbe7204SAl ViroHEADER_ARCH := $(SUBARCH) 287bbe7204SAl Viro 29fff6540cSRichard Weinbergerifneq ($(filter $(SUBARCH),x86 x86_64 i386),) 307bbe7204SAl Viro HEADER_ARCH := x86 317bbe7204SAl Viroendif 32fff6540cSRichard Weinberger 33fff6540cSRichard Weinbergerifdef CONFIG_64BIT 3412783aa0SRichard Weinberger KBUILD_CFLAGS += -mcmodel=large 357bbe7204SAl Viroendif 367bbe7204SAl Viro 375c48b108SAl ViroHOST_DIR := arch/$(HEADER_ARCH) 385c48b108SAl Viro 39d8285639SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-skas 40d8285639SMasahiro Yamadainclude $(srctree)/$(HOST_DIR)/Makefile.um 415c48b108SAl Viro 425c48b108SAl Virocore-y += $(HOST_DIR)/um/ 431da177e4SLinus Torvalds 4422409f9cSAl ViroSHARED_HEADERS := $(ARCH_DIR)/include/shared 4522409f9cSAl ViroARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) 465c48b108SAl ViroARCH_INCLUDE += -I$(srctree)/$(HOST_DIR)/um/shared 475c48b108SAl ViroKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um 481da177e4SLinus Torvalds 49*a74b6c0eSDavid Gow# -Dstrrchr=kernel_strrchr (as well as the various in6addr symbols) prevents 50*a74b6c0eSDavid Gow# anything from referencing 51*a74b6c0eSDavid Gow# libc symbols with the same name, which can cause a linker error. 5298105d47SPaolo 'Blaisorblade' Giarrusso# 53f44f1e7dSFlorian Fainelli# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a 54f44f1e7dSFlorian Fainelli# embedded copy of longjmp, same thing for setjmp. 55f44f1e7dSFlorian Fainelli# 56*a74b6c0eSDavid Gow# These apply to USER_CFLAGS too. 57ecc354a9SPaolo 'Blaisorblade' Giarrusso 58dc5be20aSAl ViroKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ 59*a74b6c0eSDavid Gow $(ARCH_INCLUDE) $(MODE_INCLUDE) \ 60f44f1e7dSFlorian Fainelli -Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \ 61818f6ef4SJeff Dike -Din6addr_loopback=kernel_in6addr_loopback \ 6232e8eaf2SBenjamin Berg -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr \ 6332e8eaf2SBenjamin Berg -D__close_range=kernel__close_range 64fd748104SPaolo 'Blaisorblade' Giarrusso 65905a7707SDavid GowKBUILD_RUSTFLAGS += -Crelocation-model=pie 66905a7707SDavid Gow 67222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 68ecc354a9SPaolo 'Blaisorblade' Giarrusso 69298e20baSRichard WeinbergerUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ 70298e20baSRichard Weinberger $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ 710b5aedfeSRichard Weinberger -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ 722f278b59SBenjamin Berg -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ \ 732f278b59SBenjamin Berg -include $(srctree)/include/linux/compiler-version.h \ 742f278b59SBenjamin Berg -include $(srctree)/include/linux/kconfig.h 75d45e44d4Sakpm@osdl.org 76d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 77d32df108SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-os-Linux 78ecc354a9SPaolo 'Blaisorblade' Giarrusso 79c9b284b2SH. Peter AnvinKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \ 80abbf1590SDavid Howells -I$(srctree)/$(HOST_DIR)/include/uapi \ 8158ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated \ 8258ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated/uapi 831de1502cSAl Viro 841da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 851da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 86a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 871da177e4SLinus Torvalds# errnos. 8898105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 89f15cf515SJeff Dike# 90f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 91f15cf515SJeff Dike# defines more robust 921da177e4SLinus Torvalds 93f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 94f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 95a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 961da177e4SLinus Torvalds 974f193362SPaul SmithPHONY += linux 981da177e4SLinus Torvalds 991da177e4SLinus Torvaldsall: linux 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvaldslinux: vmlinux 102a4b741e3SJeff Dike @echo ' LINK $@' 103cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvaldsdefine archhelp 1061da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 1071da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 1084b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 1091da177e4SLinus Torvalds echo ' find in the kernel root.' 1101da177e4SLinus Torvaldsendef 1111da177e4SLinus Torvalds 112c9b284b2SH. Peter Anvinarchheaders: 1130004438aSMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 114699d7a57SAl Viro 11565bba042SMasahiro Yamadaarchprepare: 11665bba042SMasahiro Yamada $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 1171da177e4SLinus Torvalds 1181da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 119118c40b7SArnd BergmannLINK-$(CONFIG_LD_SCRIPT_DYN) += -no-pie 120386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib 1211da177e4SLinus Torvalds 122275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 123893ab004SMasahiro Yamada -fno-stack-protector $(call cc-option, -fno-stack-protector-all) 124275e6e1eSPaolo 'Blaisorblade' Giarrusso 12551b563fcSSam Ravnborg# Options used by linker script 12651b563fcSSam Ravnborgexport LDS_START := $(START) 12751b563fcSSam Ravnborgexport LDS_ELF_ARCH := $(ELF_ARCH) 12851b563fcSSam Ravnborgexport LDS_ELF_FORMAT := $(ELF_FORMAT) 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1311da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1321da177e4SLinus Torvalds 133bd71558dSDavid Gow# Avoid binutils 2.39+ warnings by marking the stack non-executable and 134bd71558dSDavid Gow# ignorning warnings for the kallsyms sections. 135bd71558dSDavid GowLDFLAGS_EXECSTACK = -z noexecstack 136bd71558dSDavid Gowifeq ($(CONFIG_LD_IS_BFD),y) 137bd71558dSDavid GowLDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) 138bd71558dSDavid Gowendif 139bd71558dSDavid Gow 1406aa56115SPeter FoleyLD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt)) 1410ba7fe03SJeff Dike 1421f2bfbd0SSam Ravnborg# Used by link-vmlinux.sh which has special support for um link 14383e913f5SPeter Foleyexport CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO) 1441da177e4SLinus Torvalds 1451da177e4SLinus Torvalds# When cleaning we don't include .config, so we don't include 1461da177e4SLinus Torvalds# TT or skas makefiles and don't clean skas_ptregs.h. 1479e636452SAl ViroCLEAN_FILES += linux x.i gmon.out 148a5a319ecSKees CookMRPROPER_FILES += $(HOST_DIR)/include/generated 1491da177e4SLinus Torvalds 1501da177e4SLinus Torvaldsarchclean: 1511da177e4SLinus Torvalds @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 1521da177e4SLinus Torvalds -o -name '*.gcov' \) -type f -print | xargs rm -f 153ab09da75SMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) clean 1541da177e4SLinus Torvalds 155d32df108SMasahiro Yamadaexport HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH 156