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