Back to home page

LXR

 
 

    


0001 #
0002 # This file is included by the global makefile so that you can add your own
0003 # architecture-specific flags and dependencies.
0004 #
0005 # Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
0006 # Licensed under the GPL
0007 #
0008 
0009 # select defconfig based on actual architecture
0010 ifeq ($(SUBARCH),x86)
0011   ifeq ($(shell uname -m),x86_64)
0012         KBUILD_DEFCONFIG := x86_64_defconfig
0013   else
0014         KBUILD_DEFCONFIG := i386_defconfig
0015   endif
0016 else
0017         KBUILD_DEFCONFIG := $(SUBARCH)_defconfig
0018 endif
0019 
0020 ARCH_DIR := arch/um
0021 OS := $(shell uname -s)
0022 # We require bash because the vmlinux link and loader script cpp use bash
0023 # features.
0024 SHELL := /bin/bash
0025 
0026 filechk_gen_header = $<
0027 
0028 core-y                  += $(ARCH_DIR)/kernel/          \
0029                            $(ARCH_DIR)/drivers/         \
0030                            $(ARCH_DIR)/os-$(OS)/
0031 
0032 MODE_INCLUDE    += -I$(srctree)/$(ARCH_DIR)/include/shared/skas
0033 
0034 HEADER_ARCH     := $(SUBARCH)
0035 
0036 ifneq ($(filter $(SUBARCH),x86 x86_64 i386),)
0037         HEADER_ARCH := x86
0038 endif
0039 
0040 ifdef CONFIG_64BIT
0041         KBUILD_CFLAGS += -mcmodel=large
0042 endif
0043 
0044 HOST_DIR := arch/$(HEADER_ARCH)
0045 
0046 include $(ARCH_DIR)/Makefile-skas
0047 include $(HOST_DIR)/Makefile.um
0048 
0049 core-y += $(HOST_DIR)/um/
0050 
0051 SHARED_HEADERS  := $(ARCH_DIR)/include/shared
0052 ARCH_INCLUDE    := -I$(srctree)/$(SHARED_HEADERS)
0053 ARCH_INCLUDE    += -I$(srctree)/$(HOST_DIR)/um/shared
0054 KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
0055 
0056 # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
0057 # named - it's a common symbol in libpcap, so we get a binary which crashes.
0058 #
0059 # Same things for in6addr_loopback and mktime - found in libc. For these two we
0060 # only get link-time error, luckily.
0061 #
0062 # These apply to USER_CFLAGS to.
0063 
0064 KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
0065         $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap      \
0066         -Din6addr_loopback=kernel_in6addr_loopback \
0067         -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
0068 
0069 KBUILD_AFLAGS += $(ARCH_INCLUDE)
0070 
0071 USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
0072                 $(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
0073                 -D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
0074                 -idirafter $(obj)/include -D__KERNEL__ -D__UM_HOST__ 
0075 
0076 #This will adjust *FLAGS accordingly to the platform.
0077 include $(ARCH_DIR)/Makefile-os-$(OS)
0078 
0079 KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
0080                    -I$(srctree)/$(HOST_DIR)/include/uapi \
0081                    -I$(objtree)/$(HOST_DIR)/include/generated \
0082                    -I$(objtree)/$(HOST_DIR)/include/generated/uapi
0083 
0084 # -Derrno=kernel_errno - This turns all kernel references to errno into
0085 # kernel_errno to separate them from the libc errno.  This allows -fno-common
0086 # in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
0087 # errnos.
0088 # These apply to kernelspace only.
0089 #
0090 # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
0091 # defines more robust
0092 
0093 KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
0094                          -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
0095 KBUILD_CFLAGS += $(KERNEL_DEFINES)
0096 
0097 PHONY += linux
0098 
0099 all: linux
0100 
0101 linux: vmlinux
0102         @echo '  LINK $@'
0103         $(Q)ln -f $< $@
0104 
0105 define archhelp
0106   echo '* linux         - Binary kernel image (./linux) - for backward'
0107   echo '                   compatibility only, this creates a hard link to the'
0108   echo '                   real kernel binary, the "vmlinux" binary you'
0109   echo '                   find in the kernel root.'
0110 endef
0111 
0112 KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
0113 
0114 archheaders:
0115         $(Q)$(MAKE) KBUILD_SRC= ARCH=$(HEADER_ARCH) archheaders
0116 
0117 archprepare: include/generated/user_constants.h
0118 
0119 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
0120 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
0121 
0122 CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
0123         $(call cc-option, -fno-stack-protector,) \
0124         $(call cc-option, -fno-stack-protector-all,)
0125 
0126 # Options used by linker script
0127 export LDS_START      := $(START)
0128 export LDS_ELF_ARCH   := $(ELF_ARCH)
0129 export LDS_ELF_FORMAT := $(ELF_FORMAT)
0130 
0131 # The wrappers will select whether using "malloc" or the kernel allocator.
0132 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
0133 
0134 LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
0135 
0136 # Used by link-vmlinux.sh which has special support for um link
0137 export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
0138 
0139 # When cleaning we don't include .config, so we don't include
0140 # TT or skas makefiles and don't clean skas_ptregs.h.
0141 CLEAN_FILES += linux x.i gmon.out
0142 
0143 archclean:
0144         @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
0145                 -o -name '*.gcov' \) -type f -print | xargs rm -f
0146 
0147 # Generated files
0148 
0149 $(HOST_DIR)/um/user-offsets.s: __headers FORCE
0150         $(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
0151 
0152 define filechk_gen-asm-offsets
0153         (set -e; \
0154          echo "/*"; \
0155          echo " * DO NOT MODIFY."; \
0156          echo " *"; \
0157          echo " * This file was generated by arch/$(ARCH)/Makefile"; \
0158          echo " *"; \
0159          echo " */"; \
0160          echo ""; \
0161          sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
0162          echo ""; )
0163 endef
0164 
0165 include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
0166         $(call filechk,gen-asm-offsets)
0167 
0168 export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH