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 TorvaldsOS := $(shell uname -s) 221da177e4SLinus Torvalds# We require bash because the vmlinux link and loader script cpp use bash 231da177e4SLinus Torvalds# features. 241da177e4SLinus TorvaldsSHELL := /bin/bash 251da177e4SLinus Torvalds 261da177e4SLinus Torvaldscore-y += $(ARCH_DIR)/kernel/ \ 271da177e4SLinus Torvalds $(ARCH_DIR)/drivers/ \ 281da177e4SLinus Torvalds $(ARCH_DIR)/os-$(OS)/ 291da177e4SLinus Torvalds 308569c914SAl ViroMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 311da177e4SLinus Torvalds 327bbe7204SAl ViroHEADER_ARCH := $(SUBARCH) 337bbe7204SAl Viro 34fff6540cSRichard Weinbergerifneq ($(filter $(SUBARCH),x86 x86_64 i386),) 357bbe7204SAl Viro HEADER_ARCH := x86 367bbe7204SAl Viroendif 37fff6540cSRichard Weinberger 38fff6540cSRichard Weinbergerifdef CONFIG_64BIT 3912783aa0SRichard Weinberger KBUILD_CFLAGS += -mcmodel=large 407bbe7204SAl Viroendif 417bbe7204SAl Viro 425c48b108SAl ViroHOST_DIR := arch/$(HEADER_ARCH) 435c48b108SAl Viro 44d8285639SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-skas 45d8285639SMasahiro Yamadainclude $(srctree)/$(HOST_DIR)/Makefile.um 465c48b108SAl Viro 475c48b108SAl Virocore-y += $(HOST_DIR)/um/ 481da177e4SLinus Torvalds 4922409f9cSAl ViroSHARED_HEADERS := $(ARCH_DIR)/include/shared 5022409f9cSAl ViroARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) 515c48b108SAl ViroARCH_INCLUDE += -I$(srctree)/$(HOST_DIR)/um/shared 525c48b108SAl ViroKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um 531da177e4SLinus Torvalds 5498105d47SPaolo 'Blaisorblade' Giarrusso# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so 5598105d47SPaolo 'Blaisorblade' Giarrusso# named - it's a common symbol in libpcap, so we get a binary which crashes. 56fd748104SPaolo 'Blaisorblade' Giarrusso# 5798105d47SPaolo 'Blaisorblade' Giarrusso# Same things for in6addr_loopback and mktime - found in libc. For these two we 5898105d47SPaolo 'Blaisorblade' Giarrusso# only get link-time error, luckily. 5998105d47SPaolo 'Blaisorblade' Giarrusso# 60f44f1e7dSFlorian Fainelli# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a 61f44f1e7dSFlorian Fainelli# embedded copy of longjmp, same thing for setjmp. 62f44f1e7dSFlorian Fainelli# 6398105d47SPaolo 'Blaisorblade' Giarrusso# These apply to USER_CFLAGS to. 64ecc354a9SPaolo 'Blaisorblade' Giarrusso 65dc5be20aSAl ViroKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ 66fd748104SPaolo 'Blaisorblade' Giarrusso $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 67f44f1e7dSFlorian Fainelli -Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \ 68818f6ef4SJeff Dike -Din6addr_loopback=kernel_in6addr_loopback \ 692c51a4bcSAl Viro -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr 70fd748104SPaolo 'Blaisorblade' Giarrusso 71905a7707SDavid GowKBUILD_RUSTFLAGS += -Crelocation-model=pie 72905a7707SDavid Gow 73222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 74ecc354a9SPaolo 'Blaisorblade' Giarrusso 75298e20baSRichard WeinbergerUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ 76298e20baSRichard Weinberger $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ 770b5aedfeSRichard Weinberger -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ 7875dd4747SMasahiro Yamada -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ 79d45e44d4Sakpm@osdl.org 80d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 81d8285639SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) 82ecc354a9SPaolo 'Blaisorblade' Giarrusso 83c9b284b2SH. Peter AnvinKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \ 84abbf1590SDavid Howells -I$(srctree)/$(HOST_DIR)/include/uapi \ 8558ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated \ 8658ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated/uapi 871de1502cSAl Viro 881da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 891da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 90a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 911da177e4SLinus Torvalds# errnos. 9298105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 93f15cf515SJeff Dike# 94f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 95f15cf515SJeff Dike# defines more robust 961da177e4SLinus Torvalds 97f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 98f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 99a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 1001da177e4SLinus Torvalds 1014f193362SPaul SmithPHONY += linux 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvaldsall: linux 1041da177e4SLinus Torvalds 1051da177e4SLinus Torvaldslinux: vmlinux 106a4b741e3SJeff Dike @echo ' LINK $@' 107cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 1081da177e4SLinus Torvalds 1091da177e4SLinus Torvaldsdefine archhelp 1101da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 1111da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 1124b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 1131da177e4SLinus Torvalds echo ' find in the kernel root.' 1141da177e4SLinus Torvaldsendef 1151da177e4SLinus Torvalds 116c9b284b2SH. Peter Anvinarchheaders: 1170004438aSMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 118699d7a57SAl Viro 11965bba042SMasahiro Yamadaarchprepare: 12065bba042SMasahiro Yamada $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 1211da177e4SLinus Torvalds 1221da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 123386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie) 124386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib 1251da177e4SLinus Torvalds 126275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 127893ab004SMasahiro Yamada -fno-stack-protector $(call cc-option, -fno-stack-protector-all) 128275e6e1eSPaolo 'Blaisorblade' Giarrusso 12951b563fcSSam Ravnborg# Options used by linker script 13051b563fcSSam Ravnborgexport LDS_START := $(START) 13151b563fcSSam Ravnborgexport LDS_ELF_ARCH := $(ELF_ARCH) 13251b563fcSSam Ravnborgexport LDS_ELF_FORMAT := $(ELF_FORMAT) 1331da177e4SLinus Torvalds 1341da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1351da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1361da177e4SLinus Torvalds 137bd71558dSDavid Gow# Avoid binutils 2.39+ warnings by marking the stack non-executable and 138bd71558dSDavid Gow# ignorning warnings for the kallsyms sections. 139bd71558dSDavid GowLDFLAGS_EXECSTACK = -z noexecstack 140bd71558dSDavid Gowifeq ($(CONFIG_LD_IS_BFD),y) 141bd71558dSDavid GowLDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) 142bd71558dSDavid Gowendif 143bd71558dSDavid Gow 1446aa56115SPeter FoleyLD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt)) 1450ba7fe03SJeff Dike 1461f2bfbd0SSam Ravnborg# Used by link-vmlinux.sh which has special support for um link 147*83e913f5SPeter Foleyexport CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO) 1481da177e4SLinus Torvalds 1491da177e4SLinus Torvalds# When cleaning we don't include .config, so we don't include 1501da177e4SLinus Torvalds# TT or skas makefiles and don't clean skas_ptregs.h. 1519e636452SAl ViroCLEAN_FILES += linux x.i gmon.out 1520663c68cSMasahiro YamadaMRPROPER_FILES += arch/$(SUBARCH)/include/generated 1531da177e4SLinus Torvalds 1541da177e4SLinus Torvaldsarchclean: 1551da177e4SLinus Torvalds @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 1561da177e4SLinus Torvalds -o -name '*.gcov' \) -type f -print | xargs rm -f 1571da177e4SLinus Torvalds 15879b05c1fSChristoph Hellwigexport HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH 159