ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 = include/asm-um/archparam.h include/asm-um/system.h \
26         include/asm-um/sigcontext.h include/asm-um/processor.h \
27         include/asm-um/ptrace.h include/asm-um/arch-signal.h
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 include $(ARCH_DIR)/Makefile-$(SUBARCH)
35 include $(ARCH_DIR)/Makefile-os-$(OS)
36
37 MAKEFILE-$(CONFIG_MODE_TT) += Makefile-tt
38 MAKEFILE-$(CONFIG_MODE_SKAS) += Makefile-skas
39
40 ifneq ($(MAKEFILE-y),)
41   include $(addprefix $(ARCH_DIR)/,$(MAKEFILE-y))
42 endif
43
44 EXTRAVERSION := $(EXTRAVERSION)-1um
45
46 ARCH_INCLUDE = -I$(ARCH_DIR)/include
47
48 # -Derrno=kernel_errno - This turns all kernel references to errno into
49 # kernel_errno to separate them from the libc errno.  This allows -fno-common
50 # in CFLAGS.  Otherwise, it would cause ld to complain about the two different
51 # errnos.
52
53 CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
54         -D_LARGEFILE64_SOURCE $(ARCH_INCLUDE) -Derrno=kernel_errno \
55         $(MODE_INCLUDE)
56
57 LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
58
59 SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
60
61 ifeq ($(CONFIG_MODE_SKAS), y)
62 $(SYS_HEADERS) : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h
63 endif
64
65 include/linux/version.h: arch/$(ARCH)/Makefile
66
67 $(ARCH_DIR)/vmlinux.lds.S :
68         touch $@
69
70 prepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS)
71
72 LDFLAGS_vmlinux = -r
73
74 vmlinux: $(ARCH_DIR)/main.o 
75
76 # These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
77 # CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
78
79 LINK_TT = -static
80 LD_SCRIPT_TT := uml.lds.s
81
82 ifeq ($(CONFIG_STATIC_LINK),y)
83   LINK-y += $(LINK_TT)
84   LD_SCRIPT-y := $(LD_SCRIPT_TT)
85 else
86 ifeq ($(CONFIG_MODE_TT),y)
87   LINK-y += $(LINK_TT)
88   LD_SCRIPT-y := $(LD_SCRIPT_TT)
89 else
90 ifeq ($(CONFIG_MODE_SKAS),y)
91   LINK-y += $(LINK_SKAS)
92   LD_SCRIPT-y := $(LD_SCRIPT_SKAS)
93 endif
94 endif
95 endif
96
97 CPP_MODE_TT := $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo -DMODE_TT)
98 CONFIG_KERNEL_STACK_ORDER ?= 2
99 STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
100
101 AFLAGS_vmlinux.lds.o = -U$(SUBARCH) \
102         -DSTART=$$(($(TOP_ADDR) - $(SIZE))) -DELF_ARCH=$(ELF_ARCH) \
103         -DELF_FORMAT=\"$(ELF_FORMAT)\" $(CPP_MODE_TT) \
104         -DKERNEL_STACK_SIZE=$(STACK_SIZE)
105
106 AFLAGS_$(LD_SCRIPT-y:.s=).o = $(AFLAGS_vmlinux.lds.o) -P -C -Uum
107
108 LD_SCRIPT-y := $(ARCH_DIR)/$(LD_SCRIPT-y)
109
110 $(LD_SCRIPT-y) : $(LD_SCRIPT-y:.s=.S) scripts FORCE
111         $(call if_changed_dep,as_s_S)
112
113 linux: vmlinux $(LD_SCRIPT-y)
114         $(CC) -Wl,-T,$(LD_SCRIPT-y) $(LINK-y) $(LINK_WRAPS) \
115                 -o linux $(ARCH_DIR)/main.o vmlinux -L/usr/lib -lutil
116
117 USER_CFLAGS := $(patsubst -I%,,$(CFLAGS))
118 USER_CFLAGS := $(patsubst -Derrno=kernel_errno,,$(USER_CFLAGS))
119 USER_CFLAGS := $(patsubst -D__KERNEL__,,$(USER_CFLAGS)) $(ARCH_INCLUDE) \
120         $(MODE_INCLUDE)
121
122 # To get a definition of F_SETSIG
123 USER_CFLAGS += -D_GNU_SOURCE
124
125 CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/uml.lds.s \
126         $(ARCH_DIR)/dyn_link.ld.s $(GEN_HEADERS)
127
128 $(ARCH_DIR)/main.o: $(ARCH_DIR)/main.c
129         $(CC) $(USER_CFLAGS) $(EXTRA_CFLAGS) -c -o $@ $<
130
131 archmrproper:
132         for d in $(ARCH_SUBDIRS) $(ARCH_DIR)/util; \
133         do \
134                 $(MAKE) -C $$d archmrproper; \
135         done
136         rm -f $(CLEAN_FILES) $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) include/asm \
137                 $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS))
138
139 archclean: sysclean
140         for d in $(ARCH_SUBDIRS) $(ARCH_DIR)/util; \
141         do \
142                 $(MAKE) -C $$d clean; \
143         done
144         find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
145                 -o -name '*.gcov' \) -type f -print | xargs rm -f
146         rm -f linux x.i gmon.out $(ARCH_DIR)/link.ld $(GEN_HEADERS)
147
148 archdep: 
149         for d in $(ARCH_SUBDIRS); do $(MAKE) -C $$d fastdep; done
150
151 $(SYMLINK_HEADERS):
152         cd $(TOPDIR)/$(dir $@) ; \
153         ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
154
155 include/asm-um/arch:
156         cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
157
158 $(ARCH_DIR)/include/sysdep:
159         cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
160
161 $(ARCH_DIR)/os:
162         cd $(ARCH_DIR) && ln -sf os-$(OS) os
163
164 $(ARCH_DIR)/include/uml-config.h :
165         sed 's/ CONFIG/ UML_CONFIG/' $(TOPDIR)/include/linux/autoconf.h > $@
166
167 $(ARCH_DIR)/include/task.h : $(ARCH_DIR)/util/mk_task
168         $< > $@
169
170 $(ARCH_DIR)/include/kern_constants.h : $(ARCH_DIR)/util/mk_constants
171         $< > $@
172
173 $(ARCH_DIR)/util/mk_task : $(ARCH_DIR)/kernel/skas/include/skas_ptregs.h \
174         $(ARCH_DIR)/util FORCE ;
175
176 $(ARCH_DIR)/util: FORCE
177         @$(call descend,$@,)
178
179 export SUBARCH USER_CFLAGS OS