2 # Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 # Licensed under the GPL
7 OS
:= $(shell uname
-s
)
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
14 MODLIB
:= $(INSTALL_MOD_PATH
)/lib
/modules
/$(KERNELRELEASE
)
16 ifeq ($(CONFIG_DEBUGSYM
),y
)
17 CFLAGS
:= $(subst -fomit-frame-pointer
,,$(CFLAGS
))
20 CFLAGS-
$(CONFIG_DEBUGSYM
) += -g
22 core-y
+= $(ARCH_DIR
)/kernel
/ \
23 $(ARCH_DIR
)/drivers
/ \
24 $(ARCH_DIR
)/sys-
$(SUBARCH
)/
26 # Have to precede the include because the included Makefiles reference them.
27 SYMLINK_HEADERS
= include/asm-um
/archparam.h
include/asm-um
/system.h \
28 include/asm-um
/sigcontext.h
include/asm-um
/processor.h \
29 include/asm-um
/ptrace.h
include/asm-um
/arch-signal.h
31 ARCH_SYMLINKS
= include/asm-um
/arch
$(ARCH_DIR
)/include/sysdep
$(ARCH_DIR
)/os \
32 $(SYMLINK_HEADERS
) $(ARCH_DIR
)/include/uml-config.h
34 GEN_HEADERS
+= $(ARCH_DIR
)/include/task.h
$(ARCH_DIR
)/include/kern_constants.h
36 include $(ARCH_DIR
)/Makefile-
$(SUBARCH
)
37 include $(ARCH_DIR
)/Makefile-os-
$(OS
)
39 MAKEFILE-
$(CONFIG_MODE_TT
) += Makefile-tt
40 MAKEFILE-
$(CONFIG_MODE_SKAS
) += Makefile-skas
42 ifneq ($(MAKEFILE-y
),)
43 include $(addprefix $(ARCH_DIR
)/,$(MAKEFILE-y
))
46 EXTRAVERSION
:= $(EXTRAVERSION
)-1um
48 ARCH_INCLUDE
= -I
$(ARCH_DIR
)/include
50 # -Derrno=kernel_errno - This turns all kernel references to errno into
51 # kernel_errno to separate them from the libc errno. This allows -fno-common
52 # in CFLAGS. Otherwise, it would cause ld to complain about the two different
55 CFLAGS
+= $(CFLAGS-y
) -D__arch_um__
-DSUBARCH
=\"$(SUBARCH
)\" \
56 -D_LARGEFILE64_SOURCE
$(ARCH_INCLUDE
) -Derrno
=kernel_errno \
59 LINK_WRAPS
= -Wl
,--wrap
,malloc
-Wl
,--wrap
,free
-Wl
,--wrap
,calloc
61 SIZE
= (($(CONFIG_NEST_LEVEL
) + $(CONFIG_KERNEL_HALF_GIGS
)) * 0x20000000)
63 ifeq ($(CONFIG_MODE_SKAS
), y
)
64 $(SYS_HEADERS
) : $(ARCH_DIR
)/kernel
/skas
/include/skas_ptregs.h
67 include/linux
/version.h
: arch
/$(ARCH
)/Makefile
69 $(ARCH_DIR
)/vmlinux.lds.S
:
72 prepare
: $(ARCH_SYMLINKS
) $(SYS_HEADERS
) $(GEN_HEADERS
)
76 vmlinux
: $(ARCH_DIR
)/main.o
78 # These aren't in Makefile-tt because they are needed in the !CONFIG_MODE_TT +
79 # CONFIG_MODE_SKAS + CONFIG_STATIC_LINK case.
82 LD_SCRIPT_TT
:= uml.lds.s
84 ifeq ($(CONFIG_STATIC_LINK
),y
)
86 LD_SCRIPT-y
:= $(LD_SCRIPT_TT
)
88 ifeq ($(CONFIG_MODE_TT
),y
)
90 LD_SCRIPT-y
:= $(LD_SCRIPT_TT
)
92 ifeq ($(CONFIG_MODE_SKAS
),y
)
93 LINK-y
+= $(LINK_SKAS
)
94 LD_SCRIPT-y
:= $(LD_SCRIPT_SKAS
)
99 CPP_MODE_TT
:= $(shell [ "$(CONFIG_MODE_TT)" = "y" ] && echo
-DMODE_TT
)
100 CONFIG_KERNEL_STACK_ORDER ?
= 2
101 STACK_SIZE
:= $(shell echo
$$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER
)) ] )
103 AFLAGS_vmlinux.lds.o
= -U
$(SUBARCH
) \
104 -DSTART
=$$(($(TOP_ADDR
) - $(SIZE
))) -DELF_ARCH
=$(ELF_ARCH
) \
105 -DELF_FORMAT
=\"$(ELF_FORMAT
)\" $(CPP_MODE_TT
) \
106 -DKERNEL_STACK_SIZE
=$(STACK_SIZE
)
108 AFLAGS_
$(LD_SCRIPT-y
:.s
=).o
= $(AFLAGS_vmlinux.lds.o
) -P
-C
-Uum
110 LD_SCRIPT-y
:= $(ARCH_DIR
)/$(LD_SCRIPT-y
)
112 $(LD_SCRIPT-y
) : $(LD_SCRIPT-y
:.s
=.S
) scripts FORCE
113 $(call if_changed_dep
,as_s_S
)
115 linux
: vmlinux
$(LD_SCRIPT-y
)
116 $(CC
) -Wl
,-T
,$(LD_SCRIPT-y
) $(LINK-y
) $(LINK_WRAPS
) \
117 -o linux
$(ARCH_DIR
)/main.o vmlinux
-L
/usr
/lib
-lutil
119 USER_CFLAGS
:= $(patsubst -I
%,,$(CFLAGS
))
120 USER_CFLAGS
:= $(patsubst -Derrno
=kernel_errno
,,$(USER_CFLAGS
))
121 USER_CFLAGS
:= $(patsubst -D__KERNEL__
,,$(USER_CFLAGS
)) $(ARCH_INCLUDE
) \
124 # To get a definition of F_SETSIG
125 USER_CFLAGS
+= -D_GNU_SOURCE
127 CLEAN_FILES
+= linux x.i gmon.out
$(ARCH_DIR
)/uml.lds.s \
128 $(ARCH_DIR
)/dyn_link.
ld.s
$(GEN_HEADERS
)
130 $(ARCH_DIR
)/main.o
: $(ARCH_DIR
)/main.c
131 $(CC
) $(USER_CFLAGS
) $(EXTRA_CFLAGS
) -c
-o
$@
$<
134 for d in
$(ARCH_SUBDIRS
) $(ARCH_DIR
)/util
; \
136 $(MAKE
) -C
$$d archmrproper
; \
138 rm -f
$(CLEAN_FILES
) $(SYMLINK_HEADERS
) $(ARCH_SYMLINKS
) include/asm \
139 $(addprefix $(ARCH_DIR
)/kernel
/,$(KERN_SYMLINKS
))
142 for d in
$(ARCH_SUBDIRS
) $(ARCH_DIR
)/util
; \
144 $(MAKE
) -C
$$d clean; \
146 find . \
( -name
'*.bb' -o
-name
'*.bbg' -o
-name
'*.da' \
147 -o
-name
'*.gcov' \
) -type f
-print | xargs
rm -f
148 rm -f linux x.i gmon.out
$(ARCH_DIR
)/link.
ld $(GEN_HEADERS
)
151 for d in
$(ARCH_SUBDIRS
); do
$(MAKE
) -C
$$d fastdep
; done
154 cd
$(TOPDIR
)/$(dir $@
) ; \
155 ln
-sf
$(basename $(notdir $@
))-$(SUBARCH
)$(suffix $@
) $(notdir $@
)
158 cd
$(TOPDIR
)/include/asm-um
&& ln
-sf ..
/asm-
$(SUBARCH
) arch
160 $(ARCH_DIR
)/include/sysdep
:
161 cd
$(ARCH_DIR
)/include && ln
-sf sysdep-
$(SUBARCH
) sysdep
164 cd
$(ARCH_DIR
) && ln
-sf os-
$(OS
) os
166 $(ARCH_DIR
)/include/uml-config.h
:
167 sed
's/ CONFIG/ UML_CONFIG/' $(TOPDIR
)/include/linux
/autoconf.h
> $@
169 $(ARCH_DIR
)/include/task.h
: $(ARCH_DIR
)/util
/mk_task
172 $(ARCH_DIR
)/include/kern_constants.h
: $(ARCH_DIR
)/util
/mk_constants
175 $(ARCH_DIR
)/util
/mk_task
: $(ARCH_DIR
)/kernel
/skas
/include/skas_ptregs.h \
176 $(ARCH_DIR
)/util FORCE
;
178 $(ARCH_DIR
)/util
: FORCE
181 export SUBARCH USER_CFLAGS OS