Makefile 4.7 KB
Newer Older
1 2 3 4
#
# This file is included by the global makefile so that you can add your own
# architecture-specific flags and dependencies.
#
J
Jeff Dike 已提交
5
# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
L
Linus Torvalds 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# Licensed under the GPL
#

ARCH_DIR := arch/um
OS := $(shell uname -s)
# We require bash because the vmlinux link and loader script cpp use bash
# features.
SHELL := /bin/bash

filechk_gen_header = $<

core-y			+= $(ARCH_DIR)/kernel/		\
			   $(ARCH_DIR)/drivers/		\
			   $(ARCH_DIR)/os-$(OS)/

21
MODE_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/include/shared/skas
L
Linus Torvalds 已提交
22

A
Al Viro 已提交
23 24 25 26 27 28 29 30
HEADER_ARCH 	:= $(SUBARCH)

# Additional ARCH settings for x86
ifeq ($(SUBARCH),i386)
        HEADER_ARCH := x86
endif
ifeq ($(SUBARCH),x86_64)
        HEADER_ARCH := x86
31
	KBUILD_CFLAGS += -mcmodel=large
A
Al Viro 已提交
32 33
endif

A
Al Viro 已提交
34 35
HOST_DIR := arch/$(HEADER_ARCH)

J
Jeff Dike 已提交
36
include $(srctree)/$(ARCH_DIR)/Makefile-skas
A
Al Viro 已提交
37 38 39
include $(srctree)/$(HOST_DIR)/Makefile.um

core-y += $(HOST_DIR)/um/
L
Linus Torvalds 已提交
40

41 42
SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
A
Al Viro 已提交
43 44
ARCH_INCLUDE	+= -I$(srctree)/$(HOST_DIR)/um/shared
KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
L
Linus Torvalds 已提交
45

46 47
# -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
# named - it's a common symbol in libpcap, so we get a binary which crashes.
48
#
49 50 51 52
# Same things for in6addr_loopback and mktime - found in libc. For these two we
# only get link-time error, luckily.
#
# These apply to USER_CFLAGS to.
L
Linus Torvalds 已提交
53

54
KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
55
	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
56
	-Din6addr_loopback=kernel_in6addr_loopback \
A
Al Viro 已提交
57
	-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
58

59
KBUILD_AFLAGS += $(ARCH_INCLUDE)
L
Linus Torvalds 已提交
60

61
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
62
	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
63
	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
64 65 66

#This will adjust *FLAGS accordingly to the platform.
include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
67

68 69
KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
		   -I$(HOST_DIR)/include/generated
70

71 72
# -Derrno=kernel_errno - This turns all kernel references to errno into
# kernel_errno to separate them from the libc errno.  This allows -fno-common
73
# in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
74
# errnos.
75
# These apply to kernelspace only.
76 77 78
#
# strip leading and trailing whitespace to make the USER_CFLAGS removal of these
# defines more robust
79

80 81
KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
			 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
82
KBUILD_CFLAGS += $(KERNEL_DEFINES)
L
Linus Torvalds 已提交
83

84
PHONY += linux
L
Linus Torvalds 已提交
85 86 87 88

all: linux

linux: vmlinux
89
	@echo '  LINK $@'
90
	$(Q)ln -f $< $@
L
Linus Torvalds 已提交
91 92 93 94

define archhelp
  echo '* linux		- Binary kernel image (./linux) - for backward'
  echo '		   compatibility only, this creates a hard link to the'
M
Matt LaPlante 已提交
95
  echo '		   real kernel binary, the "vmlinux" binary you'
L
Linus Torvalds 已提交
96 97 98
  echo '		   find in the kernel root.'
endef

A
Al Viro 已提交
99
KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
L
Linus Torvalds 已提交
100

101
archheaders:
102
	$(Q)$(MAKE) -C '$(srctree)' KBUILD_SRC= \
103
		ARCH=$(HEADER_ARCH) O='$(objtree)' archheaders
104

105
archprepare: include/generated/user_constants.h
L
Linus Torvalds 已提交
106 107 108 109

LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib

110 111 112 113
CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
	$(call cc-option, -fno-stack-protector,) \
	$(call cc-option, -fno-stack-protector-all,)

114 115 116 117
# Options used by linker script
export LDS_START      := $(START)
export LDS_ELF_ARCH   := $(ELF_ARCH)
export LDS_ELF_FORMAT := $(ELF_FORMAT)
L
Linus Torvalds 已提交
118

J
Jeff Dike 已提交
119
# The wrappers will select whether using "malloc" or the kernel allocator.
L
Linus Torvalds 已提交
120 121
LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc

122
LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
J
Jeff Dike 已提交
123

124 125
# Used by link-vmlinux.sh which has special support for um link
export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
L
Linus Torvalds 已提交
126

J
Jeff Dike 已提交
127 128
# When cleaning we don't include .config, so we don't include
# TT or skas makefiles and don't clean skas_ptregs.h.
A
Al Viro 已提交
129
CLEAN_FILES += linux x.i gmon.out
L
Linus Torvalds 已提交
130 131 132 133 134 135

archclean:
	@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
		-o -name '*.gcov' \) -type f -print | xargs rm -f

# Generated files
136

137
$(HOST_DIR)/um/user-offsets.s: __headers FORCE
A
Al Viro 已提交
138
	$(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
139

140 141 142 143 144 145 146 147 148 149
define filechk_gen-asm-offsets
        (set -e; \
         echo "/*"; \
         echo " * DO NOT MODIFY."; \
         echo " *"; \
         echo " * This file was generated by arch/$(ARCH)/Makefile"; \
         echo " *"; \
         echo " */"; \
         echo ""; \
         sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
A
Al Viro 已提交
150
         echo ""; )
151 152
endef

A
Al Viro 已提交
153
include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
154 155
	$(call filechk,gen-asm-offsets)

A
Al Viro 已提交
156
export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH