- patches.fixes/patch-2.6.11-rc1: 2.6.11-rc1.
[linux-flexiantxendom0-3.2.10.git] / arch / um / Makefile
1
2 # Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 # Licensed under the GPL
4 #
5
6 ARCH_DIR := arch/um
7 OS := $(shell uname -s)
8 # We require bash because the vmlinux link and loader script cpp use bash
9 # features.
10 SHELL := /bin/bash
11
12 filechk_gen_header = $<
13
14 core-y                  += $(ARCH_DIR)/kernel/          \
15                            $(ARCH_DIR)/drivers/         \
16                            $(ARCH_DIR)/os-$(OS)/
17
18 # Have to precede the include because the included Makefiles reference them.
19 SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \
20         arch-signal.h module.h vm-flags.h
21 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
22
23 # The "os" symlink is only used by arch/um/include/os.h, which includes
24 # ../os/include/file.h
25 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
26         $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
27
28 GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
29
30 um-modes-$(CONFIG_MODE_TT) += tt
31 um-modes-$(CONFIG_MODE_SKAS) += skas
32
33 MODE_INCLUDE    += $(foreach mode,$(um-modes-y),\
34                    -I$(srctree)/$(ARCH_DIR)/kernel/$(mode)/include)
35
36 MAKEFILES-INCL  += $(foreach mode,$(um-modes-y),\
37                    $(srctree)/$(ARCH_DIR)/Makefile-$(mode))
38
39 ifneq ($(MAKEFILE-INCL),)
40   include $(MAKEFILE-INCL)
41 endif
42
43 ARCH_INCLUDE    := -I$(ARCH_DIR)/include
44 SYS_DIR         := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
45
46 include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
47
48 core-y += $(SUBARCH_CORE)
49 libs-y += $(SUBARCH_LIBS)
50
51 # -Derrno=kernel_errno - This turns all kernel references to errno into
52 # kernel_errno to separate them from the libc errno.  This allows -fno-common
53 # in CFLAGS.  Otherwise, it would cause ld to complain about the two different
54 # errnos.
55
56 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
57         $(ARCH_INCLUDE) $(MODE_INCLUDE)
58
59 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
60 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
61         $(MODE_INCLUDE)
62 CFLAGS += -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask
63 CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
64
65 #This will adjust *FLAGS accordingly to the platform.
66 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
67
68 # These are needed for clean and mrproper, since in that case .config is not
69 # included; the values here are meaningless
70
71 CONFIG_NEST_LEVEL ?= 0
72 CONFIG_KERNEL_HALF_GIGS ?= 0
73
74 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
75
76 ifeq ($(CONFIG_MODE_SKAS), y)
77 $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h
78 endif
79
80 .PHONY: linux
81
82 all: linux
83
84 linux: vmlinux
85         ln -f $< $@
86
87 define archhelp
88   echo '* linux         - Binary kernel image (./linux) - for backward'
89   echo '                   compatibility only, this creates a hard link to the'
90   echo '                   real kernel binary, the the "vmlinux" binary you'
91   echo '                   find in the kernel root.'
92 endef
93
94 $(shell cd $(ARCH_DIR) && ln -sf Kconfig_$(SUBARCH) Kconfig_arch)
95
96 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) \
97         $(ARCH_DIR)/kernel/vmlinux.lds.S
98
99 LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
100 LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
101
102 LD_SCRIPT-$(CONFIG_LD_SCRIPT_STATIC) := uml.lds.S
103 LD_SCRIPT-$(CONFIG_LD_SCRIPT_DYN) := dyn.lds.S
104
105 CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT
106 CONFIG_KERNEL_STACK_ORDER ?= 2
107 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
108
109 ifndef START
110   START = $$(($(TOP_ADDR) - $(SIZE)))
111 endif
112
113 CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \
114         -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
115         -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE-y) \
116         -DKERNEL_STACK_SIZE=$(STACK_SIZE))
117
118 #The wrappers will select whether using "malloc" or the kernel allocator.
119 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
120
121 CFLAGS_vmlinux = $(LINK-y) $(LINK_WRAPS)
122 define cmd_vmlinux__
123         $(CC) $(CFLAGS_vmlinux) -o $@ \
124         -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
125         -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
126         -L/usr/lib -lutil \
127         $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \
128         FORCE ,$^) ; rm -f linux
129 endef
130
131 #When cleaning we don't include .config, so we don't include
132 #TT or skas makefiles and don't clean skas_ptregs.h.
133 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
134         $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h
135
136 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
137         $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os
138
139 archclean:
140         $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
141         @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
142                 -o -name '*.gcov' \) -type f -print | xargs rm -f
143
144 #We need to re-preprocess this when the symlink dest changes.
145 #So we touch it when needed.
146 $(ARCH_DIR)/kernel/vmlinux.lds.S: FORCE
147         $(Q)if [ "$(shell readlink $@)" != "$(LD_SCRIPT-y)" ]; then \
148                 echo '  SYMLINK $@'; \
149                 ln -sf $(LD_SCRIPT-y) $@; \
150                 touch $@; \
151         fi;
152
153 $(SYMLINK_HEADERS):
154         @echo '  SYMLINK $@'
155         $(Q)cd $(TOPDIR)/$(dir $@) ; \
156         ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
157
158 include/asm-um/arch:
159         @echo '  SYMLINK $@'
160         $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
161
162 $(ARCH_DIR)/include/sysdep:
163         @echo '  SYMLINK $@'
164         $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
165
166 $(ARCH_DIR)/os:
167         @echo '  SYMLINK $@'
168         $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
169
170 # Generated files
171 define filechk_umlconfig
172         sed 's/ CONFIG/ UML_CONFIG/'
173 endef
174
175 $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
176         $(call filechk,umlconfig)
177
178 $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
179         $(call filechk,gen_header)
180
181 $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
182         $(call filechk,gen_header)
183
184 $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
185         $(call filechk,gen_header)
186
187 $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/util \
188         FORCE ;
189
190 $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
191
192 $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE
193         $(Q)$(MAKE) $(build)=$@
194
195 $(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE
196         $(Q)$(MAKE) $(build)=$@
197
198 export SUBARCH USER_CFLAGS OS