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# These are cleaned up during mrproper. Please DO NOT fix it again, this is 221da177e4SLinus Torvalds# the Correct Thing(tm) to do! 23ec82c32dSAl ViroARCH_SYMLINKS = $(ARCH_DIR)/include/shared/uml-config.h 241da177e4SLinus Torvalds 258569c914SAl ViroMODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas 261da177e4SLinus Torvalds 2742fda663SJeff Dikeinclude $(srctree)/$(ARCH_DIR)/Makefile-skas 281da177e4SLinus Torvalds 29aa7bd942SAl ViroARCH_INCLUDE := -I$(srctree)/$(ARCH_DIR)/include/shared 30aa7bd942SAl ViroARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared 31fd7aab9cSAl Viroifneq ($(KBUILD_SRC),) 32aa7bd942SAl ViroARCH_INCLUDE += -I$(ARCH_DIR)/include/shared # for three generated files 33fd7aab9cSAl Viroendif 34aa7bd942SAl ViroKBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH) 351da177e4SLinus Torvalds 3698105d47SPaolo 'Blaisorblade' Giarrusso# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so 3798105d47SPaolo 'Blaisorblade' Giarrusso# named - it's a common symbol in libpcap, so we get a binary which crashes. 38fd748104SPaolo 'Blaisorblade' Giarrusso# 3998105d47SPaolo 'Blaisorblade' Giarrusso# Same things for in6addr_loopback and mktime - found in libc. For these two we 4098105d47SPaolo 'Blaisorblade' Giarrusso# only get link-time error, luckily. 4198105d47SPaolo 'Blaisorblade' Giarrusso# 4298105d47SPaolo 'Blaisorblade' Giarrusso# These apply to USER_CFLAGS to. 43ecc354a9SPaolo 'Blaisorblade' Giarrusso 44260c0cb8SJeff DikeKBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \ 45fd748104SPaolo 'Blaisorblade' Giarrusso $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \ 46818f6ef4SJeff Dike -Din6addr_loopback=kernel_in6addr_loopback \ 47818f6ef4SJeff Dike -Din6addr_any=kernel_in6addr_any 48fd748104SPaolo 'Blaisorblade' Giarrusso 49222d394dSSam RavnborgKBUILD_AFLAGS += $(ARCH_INCLUDE) 50ecc354a9SPaolo 'Blaisorblade' Giarrusso 51d45e44d4Sakpm@osdl.orgUSER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\ 52a0f97e06SSam Ravnborg $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \ 53260c0cb8SJeff Dike $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 54d45e44d4Sakpm@osdl.org 55d45e44d4Sakpm@osdl.orginclude $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH) 56d45e44d4Sakpm@osdl.org 57d45e44d4Sakpm@osdl.org#This will adjust *FLAGS accordingly to the platform. 58d45e44d4Sakpm@osdl.orginclude $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS) 59ecc354a9SPaolo 'Blaisorblade' Giarrusso 601de1502cSAl ViroKBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include 611de1502cSAl Viro 621da177e4SLinus Torvalds# -Derrno=kernel_errno - This turns all kernel references to errno into 631da177e4SLinus Torvalds# kernel_errno to separate them from the libc errno. This allows -fno-common 64a0f97e06SSam Ravnborg# in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different 651da177e4SLinus Torvalds# errnos. 6698105d47SPaolo 'Blaisorblade' Giarrusso# These apply to kernelspace only. 67f15cf515SJeff Dike# 68f15cf515SJeff Dike# strip leading and trailing whitespace to make the USER_CFLAGS removal of these 69f15cf515SJeff Dike# defines more robust 701da177e4SLinus Torvalds 71f15cf515SJeff DikeKERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \ 72f15cf515SJeff Dike -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)) 73a0f97e06SSam RavnborgKBUILD_CFLAGS += $(KERNEL_DEFINES) 741da177e4SLinus Torvalds 754f193362SPaul SmithPHONY += linux 761da177e4SLinus Torvalds 771da177e4SLinus Torvaldsall: linux 781da177e4SLinus Torvalds 791da177e4SLinus Torvaldslinux: vmlinux 80a4b741e3SJeff Dike @echo ' LINK $@' 81cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)ln -f $< $@ 821da177e4SLinus Torvalds 831da177e4SLinus Torvaldsdefine archhelp 841da177e4SLinus Torvalds echo '* linux - Binary kernel image (./linux) - for backward' 851da177e4SLinus Torvalds echo ' compatibility only, this creates a hard link to the' 864b3f686dSMatt LaPlante echo ' real kernel binary, the "vmlinux" binary you' 871da177e4SLinus Torvalds echo ' find in the kernel root.' 881da177e4SLinus Torvaldsendef 891da177e4SLinus Torvalds 90*61bee204SAl ViroKBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH) 911da177e4SLinus Torvalds 928569c914SAl Viroarchprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/shared/user_constants.h 938569c914SAl Viroprepare: $(ARCH_DIR)/include/shared/kern_constants.h 941da177e4SLinus Torvalds 951da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_STATIC) += -static 961da177e4SLinus TorvaldsLINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib 971da177e4SLinus Torvalds 98275e6e1eSPaolo 'Blaisorblade' GiarrussoCFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \ 99275e6e1eSPaolo 'Blaisorblade' Giarrusso $(call cc-option, -fno-stack-protector,) \ 100275e6e1eSPaolo 'Blaisorblade' Giarrusso $(call cc-option, -fno-stack-protector-all,) 101275e6e1eSPaolo 'Blaisorblade' Giarrusso 1021da177e4SLinus TorvaldsCONFIG_KERNEL_STACK_ORDER ?= 2 1031da177e4SLinus TorvaldsSTACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] ) 1041da177e4SLinus Torvalds 10542fda663SJeff DikeCPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \ 10642fda663SJeff Dike -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE) 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvalds# The wrappers will select whether using "malloc" or the kernel allocator. 1091da177e4SLinus TorvaldsLINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc 1101da177e4SLinus Torvalds 111260c0cb8SJeff DikeLD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt)) 1120ba7fe03SJeff Dike 1130ba7fe03SJeff DikeCFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE) 1141da177e4SLinus Torvaldsdefine cmd_vmlinux__ 1151da177e4SLinus Torvalds $(CC) $(CFLAGS_vmlinux) -o $@ \ 1161da177e4SLinus Torvalds -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \ 1171da177e4SLinus Torvalds -Wl,--start-group $(vmlinux-main) -Wl,--end-group \ 118776cfebbSPaolo 'Blaisorblade' Giarrusso -lutil \ 11975473c1dSAl Viro $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \ 1201da177e4SLinus Torvalds FORCE ,$^) ; rm -f linux 1211da177e4SLinus Torvaldsendef 1221da177e4SLinus Torvalds 1231da177e4SLinus Torvalds# When cleaning we don't include .config, so we don't include 1241da177e4SLinus Torvalds# TT or skas makefiles and don't clean skas_ptregs.h. 1258569c914SAl ViroCLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/shared/uml-config.h \ 1268569c914SAl Viro $(ARCH_DIR)/include/shared/user_constants.h \ 127*61bee204SAl Viro $(ARCH_DIR)/include/shared/kern_constants.h 1281da177e4SLinus Torvalds 129cc70a40bSAl ViroMRPROPER_FILES += $(ARCH_SYMLINKS) 1301da177e4SLinus Torvalds 1311da177e4SLinus Torvaldsarchclean: 1321da177e4SLinus Torvalds @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ 1331da177e4SLinus Torvalds -o -name '*.gcov' \) -type f -print | xargs rm -f 1341da177e4SLinus Torvalds 1358569c914SAl Viro$(objtree)/$(ARCH_DIR)/include/shared: 136c6b7a1edSJeff Dike @echo ' MKDIR $@' 137c6b7a1edSJeff Dike $(Q)mkdir -p $@ 138c6b7a1edSJeff Dike 1391da177e4SLinus Torvalds# Generated files 1401da177e4SLinus Torvaldsdefine filechk_umlconfig 1411da177e4SLinus Torvalds sed 's/ CONFIG/ UML_CONFIG/' 1421da177e4SLinus Torvaldsendef 1431da177e4SLinus Torvalds 1448569c914SAl Viro$(ARCH_DIR)/include/shared/uml-config.h : include/linux/autoconf.h 1454ee189a9SJeff Dike $(call filechk,umlconfig) 1464ee189a9SJeff Dike 147cb8aa3d2SPaolo 'Blaisorblade' Giarrusso$(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE 148cb8aa3d2SPaolo 'Blaisorblade' Giarrusso $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@ 1494ee189a9SJeff Dike 150f64a227bSSam Ravnborgdefine filechk_gen-asm-offsets 151f64a227bSSam Ravnborg (set -e; \ 152f64a227bSSam Ravnborg echo "/*"; \ 153f64a227bSSam Ravnborg echo " * DO NOT MODIFY."; \ 154f64a227bSSam Ravnborg echo " *"; \ 155f64a227bSSam Ravnborg echo " * This file was generated by arch/$(ARCH)/Makefile"; \ 156f64a227bSSam Ravnborg echo " *"; \ 157f64a227bSSam Ravnborg echo " */"; \ 158f64a227bSSam Ravnborg echo ""; \ 159f64a227bSSam Ravnborg sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ 160ecba97d4SAl Viro echo ""; ) 161f64a227bSSam Ravnborgendef 162f64a227bSSam Ravnborg 1638569c914SAl Viro$(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s 1648d0b9dc9SAl Viro $(call filechk,gen-asm-offsets) 1658d0b9dc9SAl Viro 1668569c914SAl Viro$(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared 1674ee189a9SJeff Dike @echo ' SYMLINK $@' 1688ede0bdbSAl Viro $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@ 1691da177e4SLinus Torvalds 170ec82c32dSAl Viroexport SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH 171