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. 231da177e4SLinus TorvaldsSHELL := /bin/bash 241da177e4SLinus Torvalds 251da177e4SLinus Torvaldscore-y += $(ARCH_DIR)/kernel/ \ 261da177e4SLinus Torvalds $(ARCH_DIR)/drivers/ \ 27*d32df108SMasahiro Yamada $(ARCH_DIR)/os-Linux/ 281da177e4SLinus Torvalds 298569c914SAl ViroMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 301da177e4SLinus Torvalds 317bbe7204SAl ViroHEADER_ARCH := $(SUBARCH) 327bbe7204SAl Viro 33fff6540cSRichard Weinbergerifneq ($(filter $(SUBARCH),x86 x86_64 i386),) 347bbe7204SAl Viro HEADER_ARCH := x86 357bbe7204SAl Viroendif 36fff6540cSRichard Weinberger 37fff6540cSRichard Weinbergerifdef CONFIG_64BIT 3812783aa0SRichard Weinberger KBUILD_CFLAGS += -mcmodel=large 397bbe7204SAl Viroendif 407bbe7204SAl Viro 415c48b108SAl ViroHOST_DIR := arch/$(HEADER_ARCH) 425c48b108SAl Viro 43d8285639SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-skas 44d8285639SMasahiro Yamadainclude $(srctree)/$(HOST_DIR)/Makefile.um 455c48b108SAl Viro 465c48b108SAl Virocore-y += $(HOST_DIR)/um/ 471da177e4SLinus Torvalds 4822409f9cSAl ViroSHARED_HEADERS := $(ARCH_DIR)/include/shared 4922409f9cSAl ViroARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) 505c48b108SAl ViroARCH_INCLUDE += -I$(srctree)/$(HOST_DIR)/um/shared 515c48b108SAl ViroKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um 521da177e4SLinus Torvalds 5398105d47SPaolo 'Blaisorblade' Giarrusso# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so 5498105d47SPaolo 'Blaisorblade' Giarrusso# named - it's a common symbol in libpcap, so we get a binary which crashes. 55fd748104SPaolo 'Blaisorblade' Giarrusso# 5698105d47SPaolo 'Blaisorblade' Giarrusso# Same things for in6addr_loopback and mktime - found in libc. For these two we 5798105d47SPaolo 'Blaisorblade' Giarrusso# only get link-time error, luckily. 5898105d47SPaolo 'Blaisorblade' Giarrusso# 59f44f1e7dSFlorian Fainelli# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a 60f44f1e7dSFlorian Fainelli# embedded copy of longjmp, same thing for setjmp. 61f44f1e7dSFlorian Fainelli# 6298105d47SPaolo 'Blaisorblade' Giarrusso# These apply to USER_CFLAGS to. 63ecc354a9SPaolo 'Blaisorblade' Giarrusso 64dc5be20aSAl ViroKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ 65fd748104SPaolo 'Blaisorblade' Giarrusso $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 66f44f1e7dSFlorian Fainelli -Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \ 67818f6ef4SJeff Dike -Din6addr_loopback=kernel_in6addr_loopback \ 682c51a4bcSAl Viro -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr 69fd748104SPaolo 'Blaisorblade' Giarrusso 70905a7707SDavid GowKBUILD_RUSTFLAGS += -Crelocation-model=pie 71905a7707SDavid Gow 72222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 73ecc354a9SPaolo 'Blaisorblade' Giarrusso 74298e20baSRichard WeinbergerUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ 75298e20baSRichard Weinberger $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ 760b5aedfeSRichard Weinberger -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ 7775dd4747SMasahiro Yamada -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ 78d45e44d4Sakpm@osdl.org 79d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 80*d32df108SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-os-Linux 81ecc354a9SPaolo 'Blaisorblade' Giarrusso 82c9b284b2SH. Peter AnvinKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \ 83abbf1590SDavid Howells -I$(srctree)/$(HOST_DIR)/include/uapi \ 8458ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated \ 8558ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated/uapi 861de1502cSAl Viro 871da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 881da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 89a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 901da177e4SLinus Torvalds# errnos. 9198105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 92f15cf515SJeff Dike# 93f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 94f15cf515SJeff Dike# defines more robust 951da177e4SLinus Torvalds 96f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 97f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 98a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 991da177e4SLinus Torvalds 1004f193362SPaul SmithPHONY += linux 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvaldsall: linux 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvaldslinux: vmlinux 105a4b741e3SJeff Dike @echo ' LINK $@' 106cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvaldsdefine archhelp 1091da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 1101da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 1114b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 1121da177e4SLinus Torvalds echo ' find in the kernel root.' 1131da177e4SLinus Torvaldsendef 1141da177e4SLinus Torvalds 115c9b284b2SH. Peter Anvinarchheaders: 1160004438aSMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 117699d7a57SAl Viro 11865bba042SMasahiro Yamadaarchprepare: 11965bba042SMasahiro Yamada $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 1201da177e4SLinus Torvalds 1211da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 122386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie) 123386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib 1241da177e4SLinus Torvalds 125275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 126893ab004SMasahiro Yamada -fno-stack-protector $(call cc-option, -fno-stack-protector-all) 127275e6e1eSPaolo 'Blaisorblade' Giarrusso 12851b563fcSSam Ravnborg# Options used by linker script 12951b563fcSSam Ravnborgexport LDS_START := $(START) 13051b563fcSSam Ravnborgexport LDS_ELF_ARCH := $(ELF_ARCH) 13151b563fcSSam Ravnborgexport LDS_ELF_FORMAT := $(ELF_FORMAT) 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1341da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1351da177e4SLinus Torvalds 136bd71558dSDavid Gow# Avoid binutils 2.39+ warnings by marking the stack non-executable and 137bd71558dSDavid Gow# ignorning warnings for the kallsyms sections. 138bd71558dSDavid GowLDFLAGS_EXECSTACK = -z noexecstack 139bd71558dSDavid Gowifeq ($(CONFIG_LD_IS_BFD),y) 140bd71558dSDavid GowLDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) 141bd71558dSDavid Gowendif 142bd71558dSDavid Gow 1436aa56115SPeter FoleyLD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt)) 1440ba7fe03SJeff Dike 1451f2bfbd0SSam Ravnborg# Used by link-vmlinux.sh which has special support for um link 14683e913f5SPeter Foleyexport CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO) 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds# When cleaning we don't include .config, so we don't include 1491da177e4SLinus Torvalds# TT or skas makefiles and don't clean skas_ptregs.h. 1509e636452SAl ViroCLEAN_FILES += linux x.i gmon.out 151a5a319ecSKees CookMRPROPER_FILES += $(HOST_DIR)/include/generated 1521da177e4SLinus Torvalds 1531da177e4SLinus Torvaldsarchclean: 1541da177e4SLinus Torvalds @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 1551da177e4SLinus Torvalds -o -name '*.gcov' \) -type f -print | xargs rm -f 1561da177e4SLinus Torvalds 157*d32df108SMasahiro Yamadaexport HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH 158