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 71222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 72ecc354a9SPaolo 'Blaisorblade' Giarrusso 73298e20baSRichard WeinbergerUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ 74298e20baSRichard Weinberger $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ 750b5aedfeSRichard Weinberger -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ 7675dd4747SMasahiro Yamada -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ 77d45e44d4Sakpm@osdl.org 78d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 79d8285639SMasahiro Yamadainclude $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) 80ecc354a9SPaolo 'Blaisorblade' Giarrusso 81c9b284b2SH. Peter AnvinKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \ 82abbf1590SDavid Howells -I$(srctree)/$(HOST_DIR)/include/uapi \ 8358ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated \ 8458ab5e0cSArnd Bergmann -I$(objtree)/$(HOST_DIR)/include/generated/uapi 851de1502cSAl Viro 861da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 871da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 88a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 891da177e4SLinus Torvalds# errnos. 9098105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 91f15cf515SJeff Dike# 92f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 93f15cf515SJeff Dike# defines more robust 941da177e4SLinus Torvalds 95f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 96f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 97a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 981da177e4SLinus Torvalds 994f193362SPaul SmithPHONY += linux 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvaldsall: linux 1021da177e4SLinus Torvalds 1031da177e4SLinus Torvaldslinux: vmlinux 104a4b741e3SJeff Dike @echo ' LINK $@' 105cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 1061da177e4SLinus Torvalds 1071da177e4SLinus Torvaldsdefine archhelp 1081da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 1091da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 1104b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 1111da177e4SLinus Torvalds echo ' find in the kernel root.' 1121da177e4SLinus Torvaldsendef 1131da177e4SLinus Torvalds 114c9b284b2SH. Peter Anvinarchheaders: 1150004438aSMasahiro Yamada $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 116699d7a57SAl Viro 11765bba042SMasahiro Yamadaarchprepare: 11865bba042SMasahiro Yamada $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 1191da177e4SLinus Torvalds 1201da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 121386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN) += $(call cc-option, -no-pie) 122386093c6SJohannes BergLINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib 1231da177e4SLinus Torvalds 124275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 125893ab004SMasahiro Yamada -fno-stack-protector $(call cc-option, -fno-stack-protector-all) 126275e6e1eSPaolo 'Blaisorblade' Giarrusso 12751b563fcSSam Ravnborg# Options used by linker script 12851b563fcSSam Ravnborgexport LDS_START := $(START) 12951b563fcSSam Ravnborgexport LDS_ELF_ARCH := $(ELF_ARCH) 13051b563fcSSam Ravnborgexport LDS_ELF_FORMAT := $(ELF_FORMAT) 1311da177e4SLinus Torvalds 1321da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1331da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1341da177e4SLinus Torvalds 135*bd71558dSDavid Gow# Avoid binutils 2.39+ warnings by marking the stack non-executable and 136*bd71558dSDavid Gow# ignorning warnings for the kallsyms sections. 137*bd71558dSDavid GowLDFLAGS_EXECSTACK = -z noexecstack 138*bd71558dSDavid Gowifeq ($(CONFIG_LD_IS_BFD),y) 139*bd71558dSDavid GowLDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) 140*bd71558dSDavid Gowendif 141*bd71558dSDavid Gow 142d503ac53SMasahiro YamadaLD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS),-Wl,$(opt)) 1430ba7fe03SJeff Dike 1441f2bfbd0SSam Ravnborg# Used by link-vmlinux.sh which has special support for um link 1451f2bfbd0SSam Ravnborgexport CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 146*bd71558dSDavid Gowexport LDFLAGS_vmlinux := $(LDFLAGS_EXECSTACK) 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 1510663c68cSMasahiro YamadaMRPROPER_FILES += arch/$(SUBARCH)/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 15779b05c1fSChristoph Hellwigexport HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH 158