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 91da177e4SLinus TorvaldsARCH_DIR := arch/um 101da177e4SLinus TorvaldsOS := $(shell uname -s) 111da177e4SLinus Torvalds# We require bash because the vmlinux link and loader script cpp use bash 121da177e4SLinus Torvalds# features. 131da177e4SLinus TorvaldsSHELL := /bin/bash 141da177e4SLinus Torvalds 151da177e4SLinus Torvaldsfilechk_gen_header = $< 161da177e4SLinus Torvalds 171da177e4SLinus Torvaldscore-y += $(ARCH_DIR)/kernel/ \ 181da177e4SLinus Torvalds $(ARCH_DIR)/drivers/ \ 191da177e4SLinus Torvalds $(ARCH_DIR)/os-$(OS)/ 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds# Have to precede the include because the included Makefiles reference them. 221da177e4SLinus TorvaldsSYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \ 23fbdf2161SPaolo 'Blaisorblade' Giarrusso module.h vm-flags.h elf.h host_ldt.h 248ede0bdbSAl ViroSYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),$(ARCH_DIR)/include/asm/$(header)) 251da177e4SLinus Torvalds 261da177e4SLinus Torvalds# XXX: The "os" symlink is only used by arch/um/include/os.h, which includes 271da177e4SLinus Torvalds# ../os/include/file.h 281da177e4SLinus Torvalds# 291da177e4SLinus Torvalds# These are cleaned up during mrproper. Please DO NOT fix it again, this is 301da177e4SLinus Torvalds# the Correct Thing(tm) to do! 318ede0bdbSAl ViroARCH_SYMLINKS = $(ARCH_DIR)/include/asm/arch $(ARCH_DIR)/include/shared/sysdep $(ARCH_DIR)/os \ 328569c914SAl Viro $(SYMLINK_HEADERS) $(ARCH_DIR)/include/shared/uml-config.h 331da177e4SLinus Torvalds 348569c914SAl ViroMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 351da177e4SLinus Torvalds 3642fda663SJeff Dikeinclude $(srctree)/$(ARCH_DIR)/Makefile-skas 371da177e4SLinus Torvalds 388569c914SAl ViroARCH_INCLUDE := -I$(ARCH_DIR)/include/shared 39fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 408569c914SAl ViroARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared 418ede0bdbSAl ViroKBUILD_CPPFLAGS += -I$(ARCH_DIR)/include # for arch symlink 42fd7aab9cSAl Viroendif 438569c914SAl ViroSYS_DIR := $(ARCH_DIR)/include/shared/sysdep-$(SUBARCH) 441da177e4SLinus Torvalds 4598105d47SPaolo 'Blaisorblade' Giarrusso# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so 4698105d47SPaolo 'Blaisorblade' Giarrusso# named - it's a common symbol in libpcap, so we get a binary which crashes. 47fd748104SPaolo 'Blaisorblade' Giarrusso# 4898105d47SPaolo 'Blaisorblade' Giarrusso# Same things for in6addr_loopback and mktime - found in libc. For these two we 4998105d47SPaolo 'Blaisorblade' Giarrusso# only get link-time error, luckily. 5098105d47SPaolo 'Blaisorblade' Giarrusso# 5198105d47SPaolo 'Blaisorblade' Giarrusso# These apply to USER_CFLAGS to. 52ecc354a9SPaolo 'Blaisorblade' Giarrusso 53260c0cb8SJeff DikeKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ 54fd748104SPaolo 'Blaisorblade' Giarrusso $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 55818f6ef4SJeff Dike -Din6addr_loopback=kernel_in6addr_loopback \ 56818f6ef4SJeff Dike -Din6addr_any=kernel_in6addr_any 57fd748104SPaolo 'Blaisorblade' Giarrusso 58222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 59ecc354a9SPaolo 'Blaisorblade' Giarrusso 60d45e44d4Sakpm@osdl.orgUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\ 61a0f97e06SSam Ravnborg $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \ 62260c0cb8SJeff Dike $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 63d45e44d4Sakpm@osdl.org 64d45e44d4Sakpm@osdl.orginclude $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) 65d45e44d4Sakpm@osdl.org 66d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 67d45e44d4Sakpm@osdl.orginclude $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) 68ecc354a9SPaolo 'Blaisorblade' Giarrusso 69*1de1502cSAl ViroKBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include 70*1de1502cSAl Viro 711da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 721da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 73a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 741da177e4SLinus Torvalds# errnos. 7598105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 76f15cf515SJeff Dike# 77f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 78f15cf515SJeff Dike# defines more robust 791da177e4SLinus Torvalds 80f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 81f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 82a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 831da177e4SLinus Torvalds 844f193362SPaul SmithPHONY += linux 851da177e4SLinus Torvalds 861da177e4SLinus Torvaldsall: linux 871da177e4SLinus Torvalds 881da177e4SLinus Torvaldslinux: vmlinux 89a4b741e3SJeff Dike @echo ' LINK $@' 90cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 911da177e4SLinus Torvalds 921da177e4SLinus Torvaldsdefine archhelp 931da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 941da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 954b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 961da177e4SLinus Torvalds echo ' find in the kernel root.' 971da177e4SLinus Torvaldsendef 981da177e4SLinus Torvalds 99fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 10008b178ebSJeff Dike$(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch) 101fd7aab9cSAl Viroelse 1028569c914SAl Viro$(shell ln -fsn Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch) 103fd7aab9cSAl Viroendif 1041da177e4SLinus Torvalds 1058569c914SAl Viroarchprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/shared/user_constants.h 1068569c914SAl Viroprepare: $(ARCH_DIR)/include/shared/kern_constants.h 1071da177e4SLinus Torvalds 1081da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 1091da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib 1101da177e4SLinus Torvalds 111275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 112275e6e1eSPaolo 'Blaisorblade' Giarrusso $(call cc-option, -fno-stack-protector,) \ 113275e6e1eSPaolo 'Blaisorblade' Giarrusso $(call cc-option, -fno-stack-protector-all,) 114275e6e1eSPaolo 'Blaisorblade' Giarrusso 1151da177e4SLinus TorvaldsCONFIG_KERNEL_STACK_ORDER ?= 2 1161da177e4SLinus TorvaldsSTACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) 1171da177e4SLinus Torvalds 11842fda663SJeff DikeCPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ 11942fda663SJeff Dike -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE) 1201da177e4SLinus Torvalds 1211da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1221da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1231da177e4SLinus Torvalds 124260c0cb8SJeff DikeLD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) 1250ba7fe03SJeff Dike 1260ba7fe03SJeff DikeCFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 1271da177e4SLinus Torvaldsdefine cmd_vmlinux__ 1281da177e4SLinus Torvalds $(CC) $(CFLAGS_vmlinux) -o $@ \ 1291da177e4SLinus Torvalds -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ 1301da177e4SLinus Torvalds -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ 131776cfebbSPaolo 'Blaisorblade' Giarrusso -lutil \ 13275473c1dSAl Viro $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \ 1331da177e4SLinus Torvalds FORCE ,$^) ; rm -f linux 1341da177e4SLinus Torvaldsendef 1351da177e4SLinus Torvalds 1361da177e4SLinus Torvalds# When cleaning we don't include .config, so we don't include 1371da177e4SLinus Torvalds# TT or skas makefiles and don't clean skas_ptregs.h. 1388569c914SAl ViroCLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/shared/uml-config.h \ 1398569c914SAl Viro $(ARCH_DIR)/include/shared/user_constants.h \ 1408569c914SAl Viro $(ARCH_DIR)/include/shared/kern_constants.h $(ARCH_DIR)/Kconfig.arch 1411da177e4SLinus Torvalds 142cc70a40bSAl ViroMRPROPER_FILES += $(ARCH_SYMLINKS) 1431da177e4SLinus Torvalds 1441da177e4SLinus Torvaldsarchclean: 1451da177e4SLinus Torvalds @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 1461da177e4SLinus Torvalds -o -name '*.gcov' \) -type f -print | xargs rm -f 1471da177e4SLinus Torvalds 1481da177e4SLinus Torvalds$(SYMLINK_HEADERS): 1491da177e4SLinus Torvalds @echo ' SYMLINK $@' 150fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 1518ede0bdbSAl Viro $(Q)mkdir -p $(objtree)/$(ARCH_DIR)/include/asm 1528ede0bdbSAl Viro $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/asm/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ 153fd7aab9cSAl Viroelse 1548569c914SAl Viro $(Q)ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@ 155fd7aab9cSAl Viroendif 1561da177e4SLinus Torvalds 1578ede0bdbSAl Viro$(ARCH_DIR)/include/asm/arch: 1581da177e4SLinus Torvalds @echo ' SYMLINK $@' 159fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 1608ede0bdbSAl Viro $(Q)mkdir -p $(objtree)/$(ARCH_DIR)/include/asm 161bb898558SAl Viro $(Q)ln -fsn $(srctree)/arch/$(HEADER_ARCH)/include/asm $@ 162fd7aab9cSAl Viroelse 163bb898558SAl Viro $(Q)ln -fsn ../../../$(HEADER_ARCH)/include/asm $@ 164fd7aab9cSAl Viroendif 1651da177e4SLinus Torvalds 1668569c914SAl Viro$(objtree)/$(ARCH_DIR)/include/shared: 167c6b7a1edSJeff Dike @echo ' MKDIR $@' 168c6b7a1edSJeff Dike $(Q)mkdir -p $@ 169c6b7a1edSJeff Dike 1708569c914SAl Viro$(ARCH_DIR)/include/shared/sysdep: $(objtree)/$(ARCH_DIR)/include/shared 1711da177e4SLinus Torvalds @echo ' SYMLINK $@' 172fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 1738569c914SAl Viro $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/shared/sysdep-$(SUBARCH) $@ 174fd7aab9cSAl Viroelse 1758569c914SAl Viro $(Q)ln -fsn sysdep-$(SUBARCH) $@ 176fd7aab9cSAl Viroendif 1771da177e4SLinus Torvalds 1781da177e4SLinus Torvalds$(ARCH_DIR)/os: 1791da177e4SLinus Torvalds @echo ' SYMLINK $@' 180fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 1818569c914SAl Viro $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $@ 182fd7aab9cSAl Viroelse 1838569c914SAl Viro $(Q)ln -fsn os-$(OS) $@ 184fd7aab9cSAl Viroendif 1851da177e4SLinus Torvalds 1861da177e4SLinus Torvalds# Generated files 1871da177e4SLinus Torvaldsdefine filechk_umlconfig 1881da177e4SLinus Torvalds sed 's/ CONFIG/ UML_CONFIG/' 1891da177e4SLinus Torvaldsendef 1901da177e4SLinus Torvalds 1918569c914SAl Viro$(ARCH_DIR)/include/shared/uml-config.h : include/linux/autoconf.h 1924ee189a9SJeff Dike $(call filechk,umlconfig) 1934ee189a9SJeff Dike 194cb8aa3d2SPaolo 'Blaisorblade' Giarrusso$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE 195cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@ 1964ee189a9SJeff Dike 197f64a227bSSam Ravnborgdefine filechk_gen-asm-offsets 198f64a227bSSam Ravnborg (set -e; \ 199f64a227bSSam Ravnborg echo "/*"; \ 200f64a227bSSam Ravnborg echo " * DO NOT MODIFY."; \ 201f64a227bSSam Ravnborg echo " *"; \ 202f64a227bSSam Ravnborg echo " * This file was generated by arch/$(ARCH)/Makefile"; \ 203f64a227bSSam Ravnborg echo " *"; \ 204f64a227bSSam Ravnborg echo " */"; \ 205f64a227bSSam Ravnborg echo ""; \ 206f64a227bSSam Ravnborg sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ 207ecba97d4SAl Viro echo ""; ) 208f64a227bSSam Ravnborgendef 209f64a227bSSam Ravnborg 2108569c914SAl Viro$(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s 2118d0b9dc9SAl Viro $(call filechk,gen-asm-offsets) 2128d0b9dc9SAl Viro 2138569c914SAl Viro$(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared 2144ee189a9SJeff Dike @echo ' SYMLINK $@' 2158ede0bdbSAl Viro $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@ 2161da177e4SLinus Torvalds 2172b8232ceSAl Viroexport SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH 218