Makefile 4.9 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 31 32
HEADER_ARCH 	:= $(SUBARCH)

# Additional ARCH settings for x86
ifeq ($(SUBARCH),i386)
        HEADER_ARCH := x86
endif
ifeq ($(SUBARCH),x86_64)
        HEADER_ARCH := x86
endif

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

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

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

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

45 46
# -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.
47
#
48 49 50 51
# 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 已提交
52

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

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

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

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

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

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

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

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

all: linux

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

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

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

100 101 102 103
archheaders:
	$(Q)$(MAKE) -C '$(KBUILD_SRC)' KBUILD_SRC= \
		ARCH=$(SUBARCH) O='$(objtree)' archheaders

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

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

109 110 111 112
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,)

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

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

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

CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
L
Linus Torvalds 已提交
124 125 126 127
define cmd_vmlinux__
	$(CC) $(CFLAGS_vmlinux) -o $@ \
	-Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
	-Wl,--start-group $(vmlinux-main) -Wl,--end-group \
128
	-lutil \
A
Al Viro 已提交
129
	$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
L
Linus Torvalds 已提交
130 131 132
	FORCE ,$^) ; rm -f linux
endef

J
Jeff Dike 已提交
133 134
# 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 已提交
135
CLEAN_FILES += linux x.i gmon.out
L
Linus Torvalds 已提交
136 137 138 139 140 141

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

# Generated files
142

A
Al Viro 已提交
143 144
$(HOST_DIR)/um/user-offsets.s: FORCE
	$(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
145

146 147 148 149 150 151 152 153 154 155
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 已提交
156
         echo ""; )
157 158
endef

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

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