Makefile 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. #
  2. # This file is included by the global makefile so that you can add your own
  3. # architecture-specific flags and dependencies.
  4. #
  5. # Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  6. # Licensed under the GPL
  7. #
  8. ARCH_DIR := arch/um
  9. OS := $(shell uname -s)
  10. # We require bash because the vmlinux link and loader script cpp use bash
  11. # features.
  12. SHELL := /bin/bash
  13. filechk_gen_header = $<
  14. core-y += $(ARCH_DIR)/kernel/ \
  15. $(ARCH_DIR)/drivers/ \
  16. $(ARCH_DIR)/os-$(OS)/
  17. # Have to precede the include because the included Makefiles reference them.
  18. SYMLINK_HEADERS := archparam.h system.h sigcontext.h processor.h ptrace.h \
  19. module.h vm-flags.h elf.h host_ldt.h
  20. SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header))
  21. # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
  22. # ../os/include/file.h
  23. #
  24. # These are cleaned up during mrproper. Please DO NOT fix it again, this is
  25. # the Correct Thing(tm) to do!
  26. ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \
  27. $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h
  28. MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/skas
  29. include $(srctree)/$(ARCH_DIR)/Makefile-skas
  30. ARCH_INCLUDE := -I$(ARCH_DIR)/include
  31. ifneq ($(KBUILD_SRC),)
  32. ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include
  33. endif
  34. SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
  35. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  36. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  37. #
  38. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  39. # only get link-time error, luckily.
  40. #
  41. # These apply to USER_CFLAGS to.
  42. KBUILD_CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  43. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  44. -Din6addr_loopback=kernel_in6addr_loopback \
  45. -Din6addr_any=kernel_in6addr_any
  46. KBUILD_AFLAGS += $(ARCH_INCLUDE)
  47. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  48. $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  49. -D_FILE_OFFSET_BITS=64
  50. include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
  51. #This will adjust *FLAGS accordingly to the platform.
  52. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
  53. # -Derrno=kernel_errno - This turns all kernel references to errno into
  54. # kernel_errno to separate them from the libc errno. This allows -fno-common
  55. # in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different
  56. # errnos.
  57. # These apply to kernelspace only.
  58. KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  59. -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
  60. KBUILD_CFLAGS += $(KERNEL_DEFINES)
  61. KBUILD_CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
  62. # These are needed for clean and mrproper, since in that case .config is not
  63. # included; the values here are meaningless
  64. CONFIG_NEST_LEVEL ?= 0
  65. SIZE = ($(CONFIG_NEST_LEVEL) * 0x20000000)
  66. PHONY += linux
  67. all: linux
  68. linux: vmlinux
  69. @echo ' LINK $@'
  70. $(Q)ln -f $< $@
  71. define archhelp
  72. echo '* linux - Binary kernel image (./linux) - for backward'
  73. echo ' compatibility only, this creates a hard link to the'
  74. echo ' real kernel binary, the "vmlinux" binary you'
  75. echo ' find in the kernel root.'
  76. endef
  77. ifneq ($(KBUILD_SRC),)
  78. $(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch)
  79. else
  80. $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
  81. endif
  82. archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h
  83. prepare: $(ARCH_DIR)/include/kern_constants.h
  84. LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  85. LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
  86. CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  87. $(call cc-option, -fno-stack-protector,) \
  88. $(call cc-option, -fno-stack-protector-all,)
  89. CONFIG_KERNEL_STACK_ORDER ?= 2
  90. STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
  91. ifndef START
  92. START = $(shell echo $$[ $(TOP_ADDR) - $(SIZE) ] )
  93. endif
  94. CPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
  95. -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE)
  96. # The wrappers will select whether using "malloc" or the kernel allocator.
  97. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  98. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS)
  99. define cmd_vmlinux__
  100. $(CC) $(CFLAGS_vmlinux) -o $@ \
  101. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  102. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  103. -lutil \
  104. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
  105. FORCE ,$^) ; rm -f linux
  106. endef
  107. # When cleaning we don't include .config, so we don't include
  108. # TT or skas makefiles and don't clean skas_ptregs.h.
  109. CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
  110. $(ARCH_DIR)/include/user_constants.h \
  111. $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch
  112. MRPROPER_FILES += $(ARCH_SYMLINKS)
  113. archclean:
  114. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  115. -o -name '*.gcov' \) -type f -print | xargs rm -f
  116. $(SYMLINK_HEADERS):
  117. @echo ' SYMLINK $@'
  118. ifneq ($(KBUILD_SRC),)
  119. $(Q)mkdir -p $(objtree)/include/asm-um
  120. $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
  121. else
  122. $(Q)cd $(TOPDIR)/$(dir $@) ; \
  123. ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
  124. endif
  125. include/asm-um/arch:
  126. @echo ' SYMLINK $@'
  127. ifneq ($(KBUILD_SRC),)
  128. $(Q)mkdir -p $(objtree)/include/asm-um
  129. $(Q)ln -fsn $(srctree)/include/asm-$(HEADER_ARCH) include/asm-um/arch
  130. else
  131. $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(HEADER_ARCH) arch
  132. endif
  133. $(objtree)/$(ARCH_DIR)/include:
  134. @echo ' MKDIR $@'
  135. $(Q)mkdir -p $@
  136. $(ARCH_DIR)/include/sysdep: $(objtree)/$(ARCH_DIR)/include
  137. @echo ' SYMLINK $@'
  138. ifneq ($(KBUILD_SRC),)
  139. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
  140. else
  141. $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
  142. endif
  143. $(ARCH_DIR)/os:
  144. @echo ' SYMLINK $@'
  145. ifneq ($(KBUILD_SRC),)
  146. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $(ARCH_DIR)/os
  147. else
  148. $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
  149. endif
  150. # Generated files
  151. define filechk_umlconfig
  152. sed 's/ CONFIG/ UML_CONFIG/'
  153. endef
  154. $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
  155. $(call filechk,umlconfig)
  156. $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
  157. $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
  158. define filechk_gen-asm-offsets
  159. (set -e; \
  160. echo "/*"; \
  161. echo " * DO NOT MODIFY."; \
  162. echo " *"; \
  163. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  164. echo " *"; \
  165. echo " */"; \
  166. echo ""; \
  167. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  168. echo ""; )
  169. endef
  170. $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
  171. $(call filechk,gen-asm-offsets)
  172. $(ARCH_DIR)/include/kern_constants.h: $(objtree)/$(ARCH_DIR)/include
  173. @echo ' SYMLINK $@'
  174. $(Q)ln -sf ../../../include/asm-um/asm-offsets.h $@
  175. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH