Blame view

arch/um/Makefile 4.76 KB
4f1933620   Paul Smith   kbuild: change kb...
1
2
3
4
  #
  # This file is included by the global makefile so that you can add your own
  # architecture-specific flags and dependencies.
  #
4c9e13851   Jeff Dike   uml: style fixes ...
5
  # Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
7
8
9
10
11
12
13
14
15
16
17
18
19
  # Licensed under the GPL
  #
  
  ARCH_DIR := arch/um
  OS := $(shell uname -s)
  # We require bash because the vmlinux link and loader script cpp use bash
  # features.
  SHELL := /bin/bash
  
  filechk_gen_header = $<
  
  core-y			+= $(ARCH_DIR)/kernel/		\
  			   $(ARCH_DIR)/drivers/		\
  			   $(ARCH_DIR)/os-$(OS)/
8569c9140   Al Viro   x86, um: take arc...
20
  MODE_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/include/shared/skas
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21

7bbe7204e   Al Viro   um: merge Makefil...
22
23
24
25
26
27
28
29
30
  HEADER_ARCH 	:= $(SUBARCH)
  
  # Additional ARCH settings for x86
  ifeq ($(SUBARCH),i386)
          HEADER_ARCH := x86
  endif
  ifeq ($(SUBARCH),x86_64)
          HEADER_ARCH := x86
  endif
5c48b108e   Al Viro   um: take arch/um/...
31
  HOST_DIR := arch/$(HEADER_ARCH)
42fda6638   Jeff Dike   uml: throw out CO...
32
  include $(srctree)/$(ARCH_DIR)/Makefile-skas
5c48b108e   Al Viro   um: take arch/um/...
33
34
35
  include $(srctree)/$(HOST_DIR)/Makefile.um
  
  core-y += $(HOST_DIR)/um/
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
36

22409f9c8   Al Viro   get rid of the la...
37
38
  SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
  ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
5c48b108e   Al Viro   um: take arch/um/...
39
40
  ARCH_INCLUDE	+= -I$(srctree)/$(HOST_DIR)/um/shared
  KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
41

98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
42
43
  # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  # named - it's a common symbol in libpcap, so we get a binary which crashes.
fd7481047   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: Fix ...
44
  #
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
45
46
47
48
  # Same things for in6addr_loopback and mktime - found in libc. For these two we
  # only get link-time error, luckily.
  #
  # These apply to USER_CFLAGS to.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
49

260c0cb88   Jeff Dike   uml: fx command-l...
50
  KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
51
  	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
818f6ef40   Jeff Dike   uml: fix an IPV6 ...
52
  	-Din6addr_loopback=kernel_in6addr_loopback \
2c51a4bc0   Al Viro   um: fix strrchr()...
53
  	-Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
fd7481047   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: Fix ...
54

222d394d3   Sam Ravnborg   kbuild: enable 'm...
55
  KBUILD_AFLAGS += $(ARCH_INCLUDE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56

d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
57
  USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
58
  	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
4d45db9c4   Al Viro   um: switch to -id...
59
  	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
60

d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
61
62
  #This will adjust *FLAGS accordingly to the platform.
  include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
63

5c48b108e   Al Viro   um: take arch/um/...
64
  KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include
1de1502c9   Al Viro   x86, um: now we c...
65

ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
66
67
  # -Derrno=kernel_errno - This turns all kernel references to errno into
  # kernel_errno to separate them from the libc errno.  This allows -fno-common
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
68
  # in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
69
  # errnos.
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
70
  # These apply to kernelspace only.
f15cf5151   Jeff Dike   uml: correctly st...
71
72
73
  #
  # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  # defines more robust
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
74

f15cf5151   Jeff Dike   uml: correctly st...
75
76
  KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  			 -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
77
  KBUILD_CFLAGS += $(KERNEL_DEFINES)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78

4f1933620   Paul Smith   kbuild: change kb...
79
  PHONY += linux
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
80
81
82
83
  
  all: linux
  
  linux: vmlinux
a4b741e38   Jeff Dike   [PATCH] uml: uml-...
84
  	@echo '  LINK $@'
cb8aa3d29   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: use ...
85
  	$(Q)ln -f $< $@
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
86
87
88
89
  
  define archhelp
    echo '* linux		- Binary kernel image (./linux) - for backward'
    echo '		   compatibility only, this creates a hard link to the'
4b3f686d4   Matt LaPlante   Attack of "the th...
90
    echo '		   real kernel binary, the "vmlinux" binary you'
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
91
92
    echo '		   find in the kernel root.'
  endef
5c48b108e   Al Viro   um: take arch/um/...
93
  KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
94

4de1c5f65   Al Viro   um: take user_con...
95
  archprepare: include/generated/user_constants.h
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
96
97
98
  
  LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
275e6e1ee   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: fix ...
99
100
101
  CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  	$(call cc-option, -fno-stack-protector,) \
  	$(call cc-option, -fno-stack-protector-all,)
51b563fc9   Sam Ravnborg   arm, cris, mips, ...
102
103
104
105
  # Options used by linker script
  export LDS_START      := $(START)
  export LDS_ELF_ARCH   := $(ELF_ARCH)
  export LDS_ELF_FORMAT := $(ELF_FORMAT)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106

4c9e13851   Jeff Dike   uml: style fixes ...
107
  # The wrappers will select whether using "malloc" or the kernel allocator.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
108
  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
260c0cb88   Jeff Dike   uml: fx command-l...
109
  LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
0ba7fe03b   Jeff Dike   uml: allow LFLAGS...
110
111
  
  CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
112
113
114
115
  define cmd_vmlinux__
  	$(CC) $(CFLAGS_vmlinux) -o $@ \
  	-Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  	-Wl,--start-group $(vmlinux-main) -Wl,--end-group \
776cfebb4   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml kbuil...
116
  	-lutil \
75473c1d3   Al Viro   fallout from kbui...
117
  	$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
119
  	FORCE ,$^) ; rm -f linux
  endef
4c9e13851   Jeff Dike   uml: style fixes ...
120
121
  # When cleaning we don't include .config, so we don't include
  # TT or skas makefiles and don't clean skas_ptregs.h.
9e636452d   Al Viro   um: get rid of ke...
122
  CLEAN_FILES += linux x.i gmon.out
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
123

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
  archclean:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
125
126
  	@find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  		-o -name '*.gcov' \) -type f -print | xargs rm -f
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
127
  # Generated files
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
128

5c48b108e   Al Viro   um: take arch/um/...
129
130
  $(HOST_DIR)/um/user-offsets.s: FORCE
  	$(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
131

f64a227b6   Sam Ravnborg   kbuild: um fix so...
132
133
  define filechk_gen-asm-offsets
          (set -e; \
f64a227b6   Sam Ravnborg   kbuild: um fix so...
134
135
136
137
138
139
140
141
           echo "/*"; \
           echo " * DO NOT MODIFY."; \
           echo " *"; \
           echo " * This file was generated by arch/$(ARCH)/Makefile"; \
           echo " *"; \
           echo " */"; \
           echo ""; \
           sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
ecba97d4a   Al Viro   [PATCH] uml makef...
142
           echo ""; )
f64a227b6   Sam Ravnborg   kbuild: um fix so...
143
  endef
5c48b108e   Al Viro   um: take arch/um/...
144
  include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
8d0b9dc9b   Al Viro   [PATCH] uml: star...
145
  	$(call filechk,gen-asm-offsets)
5c48b108e   Al Viro   um: take arch/um/...
146
  export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH