Blame view

arch/um/Makefile 4.89 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

42fda6638   Jeff Dike   uml: throw out CO...
22
  include $(srctree)/$(ARCH_DIR)/Makefile-skas
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23

22409f9c8   Al Viro   get rid of the la...
24
25
  SHARED_HEADERS	:= $(ARCH_DIR)/include/shared
  ARCH_INCLUDE	:= -I$(srctree)/$(SHARED_HEADERS)
aa7bd9424   Al Viro   x86, um: get rid ...
26
  ARCH_INCLUDE	+= -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared
fd7aab9c1   Al Viro   [PATCH] uml: fini...
27
  ifneq ($(KBUILD_SRC),)
22409f9c8   Al Viro   get rid of the la...
28
  ARCH_INCLUDE	+= -I$(SHARED_HEADERS)
fd7aab9c1   Al Viro   [PATCH] uml: fini...
29
  endif
aa7bd9424   Al Viro   x86, um: get rid ...
30
  KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
31

98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
32
33
  # -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 ...
34
  #
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
35
36
37
38
  # 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
39

260c0cb88   Jeff Dike   uml: fx command-l...
40
  KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
41
  	$(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap	\
818f6ef40   Jeff Dike   uml: fix an IPV6 ...
42
43
  	-Din6addr_loopback=kernel_in6addr_loopback \
  	-Din6addr_any=kernel_in6addr_any
fd7481047   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: Fix ...
44

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

d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
47
  USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
a0f97e06a   Sam Ravnborg   kbuild: enable 'm...
48
  	$(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
260c0cb88   Jeff Dike   uml: fx command-l...
49
  	$(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
d45e44d4b   Andrew Morton   [PATCH] uml: fix ...
50
51
52
53
54
  
  include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
  
  #This will adjust *FLAGS accordingly to the platform.
  include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
55

1de1502c9   Al Viro   x86, um: now we c...
56
  KBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
57
58
  # -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...
59
  # in KBUILD_CFLAGS.  Otherwise, it would cause ld to complain about the two different
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
60
  # errnos.
98105d47d   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: comm...
61
  # These apply to kernelspace only.
f15cf5151   Jeff Dike   uml: correctly st...
62
63
64
  #
  # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  # defines more robust
ecc354a90   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: rein...
65

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

4f1933620   Paul Smith   kbuild: change kb...
70
  PHONY += linux
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
74
  
  all: linux
  
  linux: vmlinux
a4b741e38   Jeff Dike   [PATCH] uml: uml-...
75
  	@echo '  LINK $@'
cb8aa3d29   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: use ...
76
  	$(Q)ln -f $< $@
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
77
78
79
80
  
  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...
81
    echo '		   real kernel binary, the "vmlinux" binary you'
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
82
83
    echo '		   find in the kernel root.'
  endef
61bee2044   Al Viro   x86, um: get rid ...
84
  KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
85

22409f9c8   Al Viro   get rid of the la...
86
87
  archprepare: $(SHARED_HEADERS)/user_constants.h
  archprepare: $(SHARED_HEADERS)/kern_constants.h
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
88
89
90
  
  LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
275e6e1ee   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: fix ...
91
92
93
  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, ...
94
95
96
97
  # 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
98

4c9e13851   Jeff Dike   uml: style fixes ...
99
  # The wrappers will select whether using "malloc" or the kernel allocator.
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
100
  LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
260c0cb88   Jeff Dike   uml: fx command-l...
101
  LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
0ba7fe03b   Jeff Dike   uml: allow LFLAGS...
102
103
  
  CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
105
106
107
  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...
108
  	-lutil \
75473c1d3   Al Viro   fallout from kbui...
109
  	$(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
110
111
  	FORCE ,$^) ; rm -f linux
  endef
4c9e13851   Jeff Dike   uml: style fixes ...
112
113
  # When cleaning we don't include .config, so we don't include
  # TT or skas makefiles and don't clean skas_ptregs.h.
87e299e5c   Al Viro   x86, um: get rid ...
114
  CLEAN_FILES += linux x.i gmon.out \
22409f9c8   Al Viro   get rid of the la...
115
116
  	$(SHARED_HEADERS)/user_constants.h \
  	$(SHARED_HEADERS)/kern_constants.h
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
117

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
118
  archclean:
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
120
  	@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
121
  # Generated files
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
122

cb8aa3d29   Paolo 'Blaisorblade' Giarrusso   [PATCH] uml: use ...
123
124
  $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
  	$(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
4ee189a92   Jeff Dike   [PATCH] uml: fix ...
125

f64a227b6   Sam Ravnborg   kbuild: um fix so...
126
127
  define filechk_gen-asm-offsets
          (set -e; \
f64a227b6   Sam Ravnborg   kbuild: um fix so...
128
129
130
131
132
133
134
135
           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...
136
           echo ""; )
f64a227b6   Sam Ravnborg   kbuild: um fix so...
137
  endef
22409f9c8   Al Viro   get rid of the la...
138
  $(SHARED_HEADERS)/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
8d0b9dc9b   Al Viro   [PATCH] uml: star...
139
  	$(call filechk,gen-asm-offsets)
22409f9c8   Al Viro   get rid of the la...
140
141
  $(SHARED_HEADERS)/kern_constants.h:
  	$(Q)mkdir -p $(dir $@)
559df2e02   Sam Ravnborg   kbuild: move asm-...
142
  	$(Q)echo '#include "../../../../include/generated/asm-offsets.h"' >$@
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
143

ec82c32d4   Al Viro   x86, um: get rid ...
144
  export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH