Makefile 5.0 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
# Licensed under the GPL
#

9 10 11 12 13 14 15 16 17 18 19
# select defconfig based on actual architecture
ifeq ($(SUBARCH),x86)
  ifeq ($(shell uname -m),x86_64)
        KBUILD_DEFCONFIG := x86_64_defconfig
  else
        KBUILD_DEFCONFIG := i386_defconfig
  endif
else
        KBUILD_DEFCONFIG := $(SUBARCH)_defconfig
endif

L
Linus Torvalds 已提交
20 21 22 23 24 25 26 27 28 29 30 31
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)/

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

A
Al Viro 已提交
34 35
HEADER_ARCH 	:= $(SUBARCH)

36 37
ifneq ($(filter $(SUBARCH),x86 x86_64 i386),)
	HEADER_ARCH := x86
A
Al Viro 已提交
38
endif
39 40

ifdef CONFIG_64BIT
41
	KBUILD_CFLAGS += -mcmodel=large
A
Al Viro 已提交
42 43
endif

A
Al Viro 已提交
44 45
HOST_DIR := arch/$(HEADER_ARCH)

46 47
include $(ARCH_DIR)/Makefile-skas
include $(HOST_DIR)/Makefile.um
A
Al Viro 已提交
48 49

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

51 52
SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
A
Al Viro 已提交
53 54
ARCH_INCLUDE	+= -I$(srctree)/$(HOST_DIR)/um/shared
KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
L
Linus Torvalds 已提交
55

56 57
# -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.
58
#
59 60 61 62
# 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 已提交
63

64
KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
65
	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
66
	-Din6addr_loopback=kernel_in6addr_loopback \
A
Al Viro 已提交
67
	-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
68

69
KBUILD_AFLAGS += $(ARCH_INCLUDE)
L
Linus Torvalds 已提交
70

R
Richard Weinberger 已提交
71 72
USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
		$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
R
Richard Weinberger 已提交
73 74
		-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
		-idirafter $(obj)/include -D__KERNEL__ -D__UM_HOST__
75 76

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

79
KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
80 81 82
		   -I$(srctree)/$(HOST_DIR)/include/uapi \
		   -I$(HOST_DIR)/include/generated \
		   -I$(HOST_DIR)/include/generated/uapi
83

84 85
# -Derrno=kernel_errno - This turns all kernel references to errno into
# kernel_errno to separate them from the libc errno.  This allows -fno-common
86
# in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
87
# errnos.
88
# These apply to kernelspace only.
89 90 91
#
# strip leading and trailing whitespace to make the USER_CFLAGS removal of these
# defines more robust
92

93 94
KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
			 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
95
KBUILD_CFLAGS += $(KERNEL_DEFINES)
L
Linus Torvalds 已提交
96

97
PHONY += linux
L
Linus Torvalds 已提交
98 99 100 101

all: linux

linux: vmlinux
102
	@echo '  LINK $@'
103
	$(Q)ln -f $< $@
L
Linus Torvalds 已提交
104 105 106 107

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

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

114
archheaders:
115
	$(Q)$(MAKE) KBUILD_SRC= ARCH=$(HEADER_ARCH) archheaders
116

117
archprepare: include/generated/user_constants.h
L
Linus Torvalds 已提交
118 119 120 121

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

122 123 124 125
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,)

126 127 128 129
# Options used by linker script
export LDS_START      := $(START)
export LDS_ELF_ARCH   := $(ELF_ARCH)
export LDS_ELF_FORMAT := $(ELF_FORMAT)
L
Linus Torvalds 已提交
130

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

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

136 137
# 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 已提交
138

J
Jeff Dike 已提交
139 140
# 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 已提交
141
CLEAN_FILES += linux x.i gmon.out
L
Linus Torvalds 已提交
142 143 144 145 146 147

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

# Generated files
148

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

152 153 154 155 156 157 158 159 160 161
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 已提交
162
         echo ""; )
163 164
endef

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

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