Blame view

arch/um/Makefile 5.23 KB
4f1933620   Paul Smith   kbuild: change kb...
1
2
3
4
  #
  # This file is included by the global makefile so that you can add your own
  # architecture-specific flags and dependencies.
  #
4c9e13851   Jeff Dike   uml: style fixes ...
5
  # Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
  # Licensed under the GPL
  #
e40f04d04   Ramkumar Ramachandra   arch/um: make it ...
8
9
10
11
12
13
14
15
16
17
  # 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
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
18
19
20
21
22
23
24
25
26
27
28
  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)/
8569c9140   Al Viro   x86, um: take arc...
29
  MODE_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/include/shared/skas
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
30

7bbe7204e   Al Viro   um: merge Makefil...
31
  HEADER_ARCH 	:= $(SUBARCH)
fff6540cb   Richard Weinberger   um: Build always ...
32
33
  ifneq ($(filter $(SUBARCH),x86 x86_64 i386),)
  	HEADER_ARCH := x86
7bbe7204e   Al Viro   um: merge Makefil...
34
  endif
fff6540cb   Richard Weinberger   um: Build always ...
35
36
  
  ifdef CONFIG_64BIT
12783aa07   Richard Weinberger   um: Switch to lar...
37
  	KBUILD_CFLAGS += -mcmodel=large
7bbe7204e   Al Viro   um: merge Makefil...
38
  endif
5c48b108e   Al Viro   um: take arch/um/...
39
  HOST_DIR := arch/$(HEADER_ARCH)
a436bb7b8   Masahiro Yamada   kbuild: use relat...
40
41
  include $(ARCH_DIR)/Makefile-skas
  include $(HOST_DIR)/Makefile.um
5c48b108e   Al Viro   um: take arch/um/...
42
43
  
  core-y += $(HOST_DIR)/um/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
44

22409f9c8   Al Viro   get rid of the la...
45
46
  SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
  ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
5c48b108e   Al Viro   um: take arch/um/...
47
48
  ARCH_INCLUDE	+= -I$(srctree)/$(HOST_DIR)/um/shared
  KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49

98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
50
51
  # -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.
fd7481047   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: Fix ...
52
  #
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
53
54
55
  # Same things for in6addr_loopback and mktime - found in libc. For these two we
  # only get link-time error, luckily.
  #
f44f1e7da   Florian Fainelli   um: Avoid longjmp...
56
57
58
  # -Dlongjmp=kernel_longjmp prevents anything from referencing the libpthread.a
  # embedded copy of longjmp, same thing for setjmp.
  #
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
59
  # These apply to USER_CFLAGS to.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
60

dc5be20a6   Al Viro   um: most of the S...
61
  KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ \
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
62
  	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
f44f1e7da   Florian Fainelli   um: Avoid longjmp...
63
  	-Dlongjmp=kernel_longjmp -Dsetjmp=kernel_setjmp \
818f6ef40   Jeff Dike   uml: fix an IPV6 ...
64
  	-Din6addr_loopback=kernel_in6addr_loopback \
2c51a4bc0   Al Viro   um: fix strrchr()...
65
  	-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
fd7481047   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: Fix ...
66

222d394d3   Sam Ravnborg   kbuild: enable 'm...
67
  KBUILD_AFLAGS += $(ARCH_INCLUDE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68

298e20ba8   Richard Weinberger   um: Stop abusing ...
69
70
  USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -I%,,$(KBUILD_CFLAGS))) \
  		$(ARCH_INCLUDE) $(MODE_INCLUDE) $(filter -I%,$(CFLAGS)) \
0b5aedfe0   Richard Weinberger   um: Fix out-of-tr...
71
72
  		-D_FILE_OFFSET_BITS=64 -idirafter $(srctree)/include \
  		-idirafter $(obj)/include -D__KERNEL__ -D__UM_HOST__
d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
73

d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
74
  #This will adjust *FLAGS accordingly to the platform.
a436bb7b8   Masahiro Yamada   kbuild: use relat...
75
  include $(ARCH_DIR)/Makefile-os-$(OS)
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
76

c9b284b20   H. Peter Anvin   um: Run host arch...
77
  KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
abbf1590d   David Howells   UAPI: Partition t...
78
  		   -I$(srctree)/$(HOST_DIR)/include/uapi \
58ab5e0c2   Arnd Bergmann   Kbuild: arch: loo...
79
80
  		   -I$(objtree)/$(HOST_DIR)/include/generated \
  		   -I$(objtree)/$(HOST_DIR)/include/generated/uapi
1de1502c9   Al Viro   x86, um: now we c...
81

ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
82
83
  # -Derrno=kernel_errno - This turns all kernel references to errno into
  # kernel_errno to separate them from the libc errno.  This allows -fno-common
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
84
  # in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
85
  # errnos.
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
86
  # These apply to kernelspace only.
f15cf5151   Jeff Dike   uml: correctly st...
87
88
89
  #
  # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  # defines more robust
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
90

f15cf5151   Jeff Dike   uml: correctly st...
91
92
  KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  			 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
93
  KBUILD_CFLAGS += $(KERNEL_DEFINES)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94

4f1933620   Paul Smith   kbuild: change kb...
95
  PHONY += linux
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
99
  
  all: linux
  
  linux: vmlinux
a4b741e38   Jeff Dike   [PATCH] uml: uml-...
100
  	@echo '  LINK $@'
cb8aa3d29   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: use ...
101
  	$(Q)ln -f $< $@
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
102
103
104
105
  
  define archhelp
    echo '* linux		- Binary kernel image (./linux) - for backward'
    echo '		   compatibility only, this creates a hard link to the'
4b3f686d4   Matt LaPlante   Attack of "the th...
106
    echo '		   real kernel binary, the "vmlinux" binary you'
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
107
108
    echo '		   find in the kernel root.'
  endef
5c48b108e   Al Viro   um: take arch/um/...
109
  KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110

c9b284b20   H. Peter Anvin   um: Run host arch...
111
  archheaders:
d4bc590f8   Michal Marek   um: Fix for relat...
112
  	$(Q)$(MAKE) KBUILD_SRC= ARCH=$(HEADER_ARCH) archheaders
c9b284b20   H. Peter Anvin   um: Run host arch...
113

4de1c5f65   Al Viro   um: take user_con...
114
  archprepare: include/generated/user_constants.h
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
115
116
  
  LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
883354afb   Thomas Meyer   um: link vmlinux ...
117
  LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib $(call cc-option, -no-pie)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118

275e6e1ee   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: fix ...
119
120
121
  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,)
51b563fc9   Sam Ravnborg   arm, cris, mips, ...
122
123
124
125
  # Options used by linker script
  export LDS_START      := $(START)
  export LDS_ELF_ARCH   := $(ELF_ARCH)
  export LDS_ELF_FORMAT := $(ELF_FORMAT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
126

4c9e13851   Jeff Dike   uml: style fixes ...
127
  # The wrappers will select whether using "malloc" or the kernel allocator.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
128
  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
fb1770aa7   Lorenzo Colitti   arch: um: fix err...
129
  LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
0ba7fe03b   Jeff Dike   uml: allow LFLAGS...
130

1f2bfbd00   Sam Ravnborg   kbuild: link of v...
131
132
  # Used by link-vmlinux.sh which has special support for um link
  export CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
133

4c9e13851   Jeff Dike   uml: style fixes ...
134
135
  # When cleaning we don't include .config, so we don't include
  # TT or skas makefiles and don't clean skas_ptregs.h.
9e636452d   Al Viro   um: get rid of ke...
136
  CLEAN_FILES += linux x.i gmon.out
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
137

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
138
  archclean:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
139
140
  	@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  		-o -name '*.gcov' \) -type f -print | xargs rm -f
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
141
  # Generated files
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
142

392f4b7db   H. Peter Anvin   um: Generate head...
143
  $(HOST_DIR)/um/user-offsets.s: __headers FORCE
5c48b108e   Al Viro   um: take arch/um/...
144
  	$(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
145

f64a227b6   Sam Ravnborg   kbuild: um fix so...
146
147
  define filechk_gen-asm-offsets
          (set -e; \
f64a227b6   Sam Ravnborg   kbuild: um fix so...
148
149
150
151
152
153
154
155
           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;}"; \
ecba97d4a   Al Viro   [PATCH] uml makef...
156
           echo ""; )
f64a227b6   Sam Ravnborg   kbuild: um fix so...
157
  endef
5c48b108e   Al Viro   um: take arch/um/...
158
  include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
8d0b9dc9b   Al Viro   [PATCH] uml: star...
159
  	$(call filechk,gen-asm-offsets)
5c48b108e   Al Viro   um: take arch/um/...
160
  export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH