162306a36Sopenharmony_ci# 262306a36Sopenharmony_ci# This file is included by the global makefile so that you can add your own 362306a36Sopenharmony_ci# architecture-specific flags and dependencies. 462306a36Sopenharmony_ci# 562306a36Sopenharmony_ci# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) 662306a36Sopenharmony_ci# Licensed under the GPL 762306a36Sopenharmony_ci# 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci# select defconfig based on actual architecture 1062306a36Sopenharmony_ciifeq ($(SUBARCH),x86) 1162306a36Sopenharmony_ci ifeq ($(shell uname -m),x86_64) 1262306a36Sopenharmony_ci KBUILD_DEFCONFIG := x86_64_defconfig 1362306a36Sopenharmony_ci else 1462306a36Sopenharmony_ci KBUILD_DEFCONFIG := i386_defconfig 1562306a36Sopenharmony_ci endif 1662306a36Sopenharmony_cielse 1762306a36Sopenharmony_ci KBUILD_DEFCONFIG := $(SUBARCH)_defconfig 1862306a36Sopenharmony_ciendif 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ciARCH_DIR := arch/um 2162306a36Sopenharmony_ci# We require bash because the vmlinux link and loader script cpp use bash 2262306a36Sopenharmony_ci# features. 2362306a36Sopenharmony_ciSHELL := /bin/bash 2462306a36Sopenharmony_ci 2562306a36Sopenharmony_ciMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 2662306a36Sopenharmony_ci 2762306a36Sopenharmony_ciHEADER_ARCH := $(SUBARCH) 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciifneq ($(filter $(SUBARCH),x86 x86_64 i386),) 3062306a36Sopenharmony_ci HEADER_ARCH := x86 3162306a36Sopenharmony_ciendif 3262306a36Sopenharmony_ci 3362306a36Sopenharmony_ciifdef CONFIG_64BIT 3462306a36Sopenharmony_ci KBUILD_CFLAGS += -mcmodel=large 3562306a36Sopenharmony_ciendif 3662306a36Sopenharmony_ci 3762306a36Sopenharmony_ciHOST_DIR := arch/$(HEADER_ARCH) 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ciinclude $(srctree)/$(ARCH_DIR)/Makefile-skas 4062306a36Sopenharmony_ciinclude $(srctree)/$(HOST_DIR)/Makefile.um 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cicore-y += $(HOST_DIR)/um/ 4362306a36Sopenharmony_ci 4462306a36Sopenharmony_ciSHARED_HEADERS := $(ARCH_DIR)/include/shared 4562306a36Sopenharmony_ciARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS) 4662306a36Sopenharmony_ciARCH_INCLUDE += -I$(srctree)/$(HOST_DIR)/um/shared 4762306a36Sopenharmony_ciKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um 4862306a36Sopenharmony_ci 4962306a36Sopenharmony_ci# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so 5062306a36Sopenharmony_ci# named - it's a common symbol in libpcap, so we get a binary which crashes. 5162306a36Sopenharmony_ci# 5262306a36Sopenharmony_ci# Same things for in6addr_loopback and mktime - found in libc. For these two we 5362306a36Sopenharmony_ci# only get link-time error, luckily. 5462306a36Sopenharmony_ci# 5562306a36Sopenharmony_ci# -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a 5662306a36Sopenharmony_ci# embedded copy of longjmp, same thing for setjmp. 5762306a36Sopenharmony_ci# 5862306a36Sopenharmony_ci# These apply to USER_CFLAGS to. 5962306a36Sopenharmony_ci 6062306a36Sopenharmony_ciKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \ 6162306a36Sopenharmony_ci $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 6262306a36Sopenharmony_ci -Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \ 6362306a36Sopenharmony_ci -Din6addr_loopback=kernel_in6addr_loopback \ 6462306a36Sopenharmony_ci -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_ciKBUILD_RUSTFLAGS += -Crelocation-model=pie 6762306a36Sopenharmony_ci 6862306a36Sopenharmony_ciKBUILD_AFLAGS += $(ARCH_INCLUDE) 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ciUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \ 7162306a36Sopenharmony_ci $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \ 7262306a36Sopenharmony_ci -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \ 7362306a36Sopenharmony_ci -idirafter $(objtree)/include -D__KERNEL__ -D__UM_HOST__ 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci#This will adjust *FLAGS accordingly to the platform. 7662306a36Sopenharmony_ciinclude $(srctree)/$(ARCH_DIR)/Makefile-os-Linux 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ciKBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \ 7962306a36Sopenharmony_ci -I$(srctree)/$(HOST_DIR)/include/uapi \ 8062306a36Sopenharmony_ci -I$(objtree)/$(HOST_DIR)/include/generated \ 8162306a36Sopenharmony_ci -I$(objtree)/$(HOST_DIR)/include/generated/uapi 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci# -Derrno=kernel_errno - This turns all kernel references to errno into 8462306a36Sopenharmony_ci# kernel_errno to separate them from the libc errno. This allows -fno-common 8562306a36Sopenharmony_ci# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 8662306a36Sopenharmony_ci# errnos. 8762306a36Sopenharmony_ci# These apply to kernelspace only. 8862306a36Sopenharmony_ci# 8962306a36Sopenharmony_ci# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 9062306a36Sopenharmony_ci# defines more robust 9162306a36Sopenharmony_ci 9262306a36Sopenharmony_ciKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 9362306a36Sopenharmony_ci -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 9462306a36Sopenharmony_ciKBUILD_CFLAGS += $(KERNEL_DEFINES) 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ciPHONY += linux 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ciall: linux 9962306a36Sopenharmony_ci 10062306a36Sopenharmony_cilinux: vmlinux 10162306a36Sopenharmony_ci @echo ' LINK $@' 10262306a36Sopenharmony_ci $(Q)ln -f $< $@ 10362306a36Sopenharmony_ci 10462306a36Sopenharmony_cidefine archhelp 10562306a36Sopenharmony_ci echo '* linux - Binary kernel image (./linux) - for backward' 10662306a36Sopenharmony_ci echo ' compatibility only, this creates a hard link to the' 10762306a36Sopenharmony_ci echo ' real kernel binary, the "vmlinux" binary you' 10862306a36Sopenharmony_ci echo ' find in the kernel root.' 10962306a36Sopenharmony_ciendef 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ciarchheaders: 11262306a36Sopenharmony_ci $(Q)$(MAKE) -f $(srctree)/Makefile ARCH=$(HEADER_ARCH) asm-generic archheaders 11362306a36Sopenharmony_ci 11462306a36Sopenharmony_ciarchprepare: 11562306a36Sopenharmony_ci $(Q)$(MAKE) $(build)=$(HOST_DIR)/um include/generated/user_constants.h 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ciLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 11862306a36Sopenharmony_ciifdef CONFIG_LD_SCRIPT_DYN 11962306a36Sopenharmony_ciLINK-$(call gcc-min-version, 60100)$(CONFIG_CC_IS_CLANG) += -no-pie 12062306a36Sopenharmony_ciendif 12162306a36Sopenharmony_ciLINK-$(CONFIG_LD_SCRIPT_DYN_RPATH) += -Wl,-rpath,/lib 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ciCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 12462306a36Sopenharmony_ci -fno-stack-protector $(call cc-option, -fno-stack-protector-all) 12562306a36Sopenharmony_ci 12662306a36Sopenharmony_ci# Options used by linker script 12762306a36Sopenharmony_ciexport LDS_START := $(START) 12862306a36Sopenharmony_ciexport LDS_ELF_ARCH := $(ELF_ARCH) 12962306a36Sopenharmony_ciexport LDS_ELF_FORMAT := $(ELF_FORMAT) 13062306a36Sopenharmony_ci 13162306a36Sopenharmony_ci# The wrappers will select whether using "malloc" or the kernel allocator. 13262306a36Sopenharmony_ciLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_ci# Avoid binutils 2.39+ warnings by marking the stack non-executable and 13562306a36Sopenharmony_ci# ignorning warnings for the kallsyms sections. 13662306a36Sopenharmony_ciLDFLAGS_EXECSTACK = -z noexecstack 13762306a36Sopenharmony_ciifeq ($(CONFIG_LD_IS_BFD),y) 13862306a36Sopenharmony_ciLDFLAGS_EXECSTACK += $(call ld-option,--no-warn-rwx-segments) 13962306a36Sopenharmony_ciendif 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ciLD_FLAGS_CMDLINE = $(foreach opt,$(KBUILD_LDFLAGS) $(LDFLAGS_EXECSTACK),-Wl,$(opt)) 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci# Used by link-vmlinux.sh which has special support for um link 14462306a36Sopenharmony_ciexport CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) $(CC_FLAGS_LTO) 14562306a36Sopenharmony_ci 14662306a36Sopenharmony_ci# When cleaning we don't include .config, so we don't include 14762306a36Sopenharmony_ci# TT or skas makefiles and don't clean skas_ptregs.h. 14862306a36Sopenharmony_ciCLEAN_FILES += linux x.i gmon.out 14962306a36Sopenharmony_ciMRPROPER_FILES += $(HOST_DIR)/include/generated 15062306a36Sopenharmony_ci 15162306a36Sopenharmony_ciarchclean: 15262306a36Sopenharmony_ci @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 15362306a36Sopenharmony_ci -o -name '*.gcov' \) -type f -print | xargs rm -f 15462306a36Sopenharmony_ci 15562306a36Sopenharmony_ciexport HEADER_ARCH SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING DEV_NULL_PATH 156