upgrade to linux 2.6.10-1.12_FC2
[linux-2.6.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)/sys-$(SUBARCH)/
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
21 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
22
23 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
24         $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
25
26 GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
27
28 MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
29 MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
30
31 ifneq ($(MAKEFILE-y),)
32   include $(addprefix $(srctree)/$(ARCH_DIR)/,$(MAKEFILE-y))
33 endif
34
35 ARCH_INCLUDE    := -I$(ARCH_DIR)/include
36 SYS_DIR         := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
37
38 include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
39 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
40
41 # -Derrno=kernel_errno - This turns all kernel references to errno into
42 # kernel_errno to separate them from the libc errno.  This allows -fno-common
43 # in CFLAGS.  Otherwise, it would cause ld to complain about the two different
44 # errnos.
45
46 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
47         -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
48         -Dsigprocmask=kernel_sigprocmask $(MODE_INCLUDE)
49
50 CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
51
52 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
53
54 # These are needed for clean and mrproper, since in that case .config is not
55 # included; the values here are meaningless
56
57 CONFIG_NEST_LEVEL ?= 0
58 CONFIG_KERNEL_HALF_GIGS ?= 0
59
60 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
61
62 ifeq ($(CONFIG_MODE_SKAS), y)
63 $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h
64 endif
65
66 .PHONY: linux
67
68 all: linux
69
70 linux: vmlinux
71         ln -f $< $@
72
73 define archhelp
74   echo '* linux         - Binary kernel image (./linux) - for backward'
75   echo '                   compatibility only, this creates a hard link to the'
76   echo '                   real kernel binary, the the "vmlinux" binary you'
77   echo '                   find in the kernel root.'
78 endef
79
80 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) \
81         $(ARCH_DIR)/kernel/vmlinux.lds.S
82
83 # These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
84 # CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
85
86 LINK_TT = -static
87 LD_SCRIPT_TT := uml.lds.S
88
89 ifeq ($(CONFIG_STATIC_LINK),y)
90   LINK-y += $(LINK_TT)
91   LD_SCRIPT-y := $(LD_SCRIPT_TT)
92 else
93 ifeq ($(CONFIG_MODE_TT),y)
94   LINK-y += $(LINK_TT)
95   LD_SCRIPT-y := $(LD_SCRIPT_TT)
96 else
97 ifeq ($(CONFIG_MODE_SKAS),y)
98   LINK-y += $(LINK_SKAS)
99   LD_SCRIPT-y := $(LD_SCRIPT_SKAS)
100 endif
101 endif
102 endif
103
104 CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
105 CONFIG_KERNEL_STACK_ORDER ?= 2
106 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
107
108 ifndef START
109   START = $$(($(TOP_ADDR) - $(SIZE)))
110 endif
111
112 CPPFLAGS_vmlinux.lds = $(shell echo -U$(SUBARCH) \
113         -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
114         -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
115         -DKERNEL_STACK_SIZE=$(STACK_SIZE))
116
117 CFLAGS_vmlinux = $(LINK-y) $(LINK_WRAPS)
118 define cmd_vmlinux__
119         $(CC) $(CFLAGS_vmlinux) -o $@ \
120         -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
121         -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
122         -L/usr/lib -lutil \
123         $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \
124         FORCE ,$^) ; rm -f linux
125 endef
126
127 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
128 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
129 USER_CFLAGS := $(patsubst -Dsigprocmask=kernel_sigprocmask,,$(USER_CFLAGS))
130 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
131         $(MODE_INCLUDE)
132 USER_CFLAGS += $(ARCH_USER_CFLAGS)
133
134 # To get a definition of F_SETSIG
135 USER_CFLAGS += -D_GNU_SOURCE
136
137 #When cleaning we don't include .config, so we don't include
138 #TT or skas makefiles and don't clean skas_ptregs.h.
139 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
140         $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h
141
142 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
143         $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os
144
145 archmrproper:
146         @:
147
148 archclean:
149         $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util
150         @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
151                 -o -name '*.gcov' \) -type f -print | xargs rm -f
152
153 #We need to re-preprocess this when the symlink dest changes.
154 #So we touch it.
155 $(ARCH_DIR)/kernel/vmlinux.lds.S: FORCE
156         @echo '  SYMLINK $@'
157         $(Q)ln -sf $(LD_SCRIPT-y) $@
158         $(Q)touch $@
159
160 $(SYMLINK_HEADERS):
161         @echo '  SYMLINK $@'
162         $(Q)cd $(TOPDIR)/$(dir $@) ; \
163         ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
164
165 include/asm-um/arch:
166         @echo '  SYMLINK $@'
167         $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
168
169 $(ARCH_DIR)/include/sysdep:
170         @echo '  SYMLINK $@'
171         $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
172
173 $(ARCH_DIR)/os:
174         @echo '  SYMLINK $@'
175         $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
176
177 # Generated files
178 define filechk_umlconfig
179         sed 's/ CONFIG/ UML_CONFIG/'
180 endef
181
182 $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
183         $(call filechk,umlconfig)
184
185 $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
186         $(call filechk,gen_header)
187
188 $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
189         $(call filechk,gen_header)
190
191 $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
192         $(call filechk,gen_header)
193
194 $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/util \
195         FORCE ;
196
197 $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
198
199 $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE
200         $(Q)$(MAKE) $(build)=$@
201
202 $(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE
203         $(Q)$(MAKE) $(build)=$@
204
205 define archhelp
206     echo  '* linux      - Binary kernel image (./linux)'
207 endef