27f1fe25d09ebb97440167d452111bd49a24dfb5
[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
9 # Recalculate MODLIB to reflect the EXTRAVERSION changes (via KERNELRELEASE)
10 # The way the toplevel Makefile is written EXTRAVERSION is not supposed
11 # to be changed outside the toplevel Makefile, but recalculating MODLIB is
12 # a sufficient workaround until we no longer need architecture dependent
13 # EXTRAVERSION...
14 MODLIB := $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
15
16 ifeq ($(CONFIG_DEBUG_INFO),y)
17 CFLAGS := $(subst -fomit-frame-pointer,,$(CFLAGS))
18 endif
19
20 core-y                  += $(ARCH_DIR)/kernel/           \
21                            $(ARCH_DIR)/drivers/          \
22                            $(ARCH_DIR)/sys-$(SUBARCH)/
23
24 # Have to precede the include because the included Makefiles reference them.
25 SYMLINK_HEADERS = archparam.h system.h sigcontext.h processor.h ptrace.h \
26         arch-signal.h module.h
27 SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
28
29 ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
30         $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
31
32 GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h
33
34 # This target adds dependencies to "prepare". They are defined in the included
35 # Makefiles (see Makefile-i386).
36
37 .PHONY: sys_prepare
38 sys_prepare:
39         @:
40
41 MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
42 MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
43
44 ifneq ($(MAKEFILE-y),)
45   include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
46 endif
47
48 include $(ARCH_DIR)/Makefile-$(SUBARCH)
49 include $(ARCH_DIR)/Makefile-os-$(OS)
50
51 EXTRAVERSION := $(EXTRAVERSION)-1um
52
53 ARCH_INCLUDE = -I$(ARCH_DIR)/include
54
55 # -Derrno=kernel_errno - This turns all kernel references to errno into
56 # kernel_errno to separate them from the libc errno.  This allows -fno-common
57 # in CFLAGS.  Otherwise, it would cause ld to complain about the two different
58 # errnos.
59
60 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
61         -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
62         -Dsigprocmask=kernel_sigprocmask $(MODE_INCLUDE)
63
64 CFLAGS += $(call check_gcc,-fno-unit-at-a-time,)
65
66 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
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) : $(TOPDIR)/$(ARCH_DIR)/include/skas_ptregs.h
78 endif
79
80 include/linux/version.h: arch/$(ARCH)/Makefile
81
82 $(ARCH_DIR)/vmlinux.lds.S :
83         touch $@
84
85 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
86
87 LDFLAGS_vmlinux = -r
88
89 vmlinux: $(ARCH_DIR)/main.o 
90
91 # These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
92 # CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
93
94 LINK_TT = -static
95 LD_SCRIPT_TT := uml.lds.s
96
97 ifeq ($(CONFIG_STATIC_LINK),y)
98   LINK-y += $(LINK_TT)
99   LD_SCRIPT-y := $(LD_SCRIPT_TT)
100 else
101 ifeq ($(CONFIG_MODE_TT),y)
102   LINK-y += $(LINK_TT)
103   LD_SCRIPT-y := $(LD_SCRIPT_TT)
104 else
105 ifeq ($(CONFIG_MODE_SKAS),y)
106   LINK-y += $(LINK_SKAS)
107   LD_SCRIPT-y := $(LD_SCRIPT_SKAS)
108 endif
109 endif
110 endif
111
112 CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
113 CONFIG_KERNEL_STACK_ORDER ?= 2
114 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
115
116 AFLAGS_vmlinux.lds.o = $(shell echo -U$(SUBARCH) \
117         -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
118         -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
119         -DKERNEL_STACK_SIZE=$(STACK_SIZE))
120
121 export AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
122
123 LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
124
125 #$(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
126 #       $(call if_changed_dep,as_s_S)
127
128 linux: vmlinux $(LD_SCRIPT-y)
129         $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
130                 -o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil
131
132 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
133 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
134 USER_CFLAGS := $(patsubst -Dsigprocmask=kernel_sigprocmask,,$(USER_CFLAGS))
135 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
136         $(MODE_INCLUDE)
137
138 # To get a definition of F_SETSIG
139 USER_CFLAGS += -D_GNU_SOURCE
140
141 # From main Makefile, these options are set after including the ARCH makefile.
142 # So copy them here.
143
144 ifdef CONFIG_CC_OPTIMIZE_FOR_SIZE
145 USER_CFLAGS             += -Os
146 else
147 USER_CFLAGS             += -O2
148 endif
149
150 ifndef CONFIG_FRAME_POINTER
151 USER_CFLAGS             += -fomit-frame-pointer
152 endif
153
154 ifdef CONFIG_DEBUG_INFO
155 USER_CFLAGS             += -g
156 endif
157
158 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/uml.lds.s \
159         $(ARCH_DIR)/dyn_link.ld.s $(ARCH_DIR)/include/uml-config.h \
160         $(GEN_HEADERS)
161
162 MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \
163         $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
164
165 $(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c sys_prepare
166         @ echo '  MAIN    $@'
167         @ $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
168
169 archmrproper:
170         @:
171
172 archclean:
173         @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
174                 -o -name '*.gcov' \) -type f -print | xargs rm -f
175
176 $(SYMLINK_HEADERS):
177         cd $(TOPDIR)/$(dir $@) ; \
178         ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
179
180 include/asm-um/arch:
181         cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
182
183 $(ARCH_DIR)/include/sysdep:
184         cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
185
186 $(ARCH_DIR)/os:
187         cd $(ARCH_DIR) && ln -sf os-$(OS) os
188
189 # Generated files
190 define filechk_umlconfig
191         sed 's/ CONFIG/ UML_CONFIG/'
192 endef
193
194 $(ARCH_DIR)/include/uml-config.h : $(TOPDIR)/include/linux/autoconf.h
195         $(call filechk,umlconfig)
196
197 filechk_gen_header = $<
198
199 $(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
200         $(call filechk,gen_header)
201
202 $(ARCH_DIR)/include/kern_constants.h : $(ARCH_DIR)/util/mk_constants
203         $(call filechk,gen_header)
204
205 $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants : $(ARCH_DIR)/util \
206         sys_prepare FORCE ;
207
208 $(ARCH_DIR)/util: FORCE
209         $(Q)$(MAKE) $(build)=$@
210
211 export SUBARCH USER_CFLAGS OS 
212
213 all: linux
214
215 define archhelp
216   echo  '* linux        - Binary kernel image (./linux)'
217 endef