Makefile 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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 Jeff Dike (jdike@karaya.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. um-modes-$(CONFIG_MODE_TT) += tt
  29. um-modes-$(CONFIG_MODE_SKAS) += skas
  30. MODE_INCLUDE += $(foreach mode,$(um-modes-y),\
  31. -I$(srctree)/$(ARCH_DIR)/include/$(mode))
  32. MAKEFILES-INCL += $(foreach mode,$(um-modes-y),\
  33. $(srctree)/$(ARCH_DIR)/Makefile-$(mode))
  34. ifneq ($(MAKEFILES-INCL),)
  35. include $(MAKEFILES-INCL)
  36. endif
  37. ARCH_INCLUDE := -I$(ARCH_DIR)/include
  38. ifneq ($(KBUILD_SRC),)
  39. ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include
  40. endif
  41. SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH)
  42. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  43. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  44. #
  45. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  46. # only get link-time error, luckily.
  47. #
  48. # These apply to USER_CFLAGS to.
  49. CFLAGS += $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  50. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  51. -Din6addr_loopback=kernel_in6addr_loopback
  52. AFLAGS += $(ARCH_INCLUDE)
  53. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  54. $(patsubst -I%,,$(CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  55. -D_FILE_OFFSET_BITS=64
  56. include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
  57. #This will adjust *FLAGS accordingly to the platform.
  58. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
  59. # -Derrno=kernel_errno - This turns all kernel references to errno into
  60. # kernel_errno to separate them from the libc errno. This allows -fno-common
  61. # in CFLAGS. Otherwise, it would cause ld to complain about the two different
  62. # errnos.
  63. # These apply to kernelspace only.
  64. KERNEL_DEFINES = -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  65. -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES)
  66. CFLAGS += $(KERNEL_DEFINES)
  67. CFLAGS += $(call cc-option,-fno-unit-at-a-time,)
  68. # These are needed for clean and mrproper, since in that case .config is not
  69. # included; the values here are meaningless
  70. CONFIG_NEST_LEVEL ?= 0
  71. CONFIG_KERNEL_HALF_GIGS ?= 0
  72. SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
  73. PHONY += linux
  74. all: linux
  75. linux: vmlinux
  76. @echo ' LINK $@'
  77. $(Q)ln -f $< $@
  78. define archhelp
  79. echo '* linux - Binary kernel image (./linux) - for backward'
  80. echo ' compatibility only, this creates a hard link to the'
  81. echo ' real kernel binary, the "vmlinux" binary you'
  82. echo ' find in the kernel root.'
  83. endef
  84. ifneq ($(KBUILD_SRC),)
  85. $(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch)
  86. else
  87. $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch)
  88. endif
  89. archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h
  90. prepare: $(ARCH_DIR)/include/kern_constants.h
  91. LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  92. LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
  93. CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  94. $(call cc-option, -fno-stack-protector,) \
  95. $(call cc-option, -fno-stack-protector-all,)
  96. CPP_MODE-$(CONFIG_MODE_TT) := -DMODE_TT
  97. CONFIG_KERNEL_STACK_ORDER ?= 2
  98. STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
  99. ifndef START
  100. START = $(shell echo $$[ $(TOP_ADDR) - $(SIZE) ] )
  101. endif
  102. CPPFLAGS_vmlinux.lds = -U$(SUBARCH) \
  103. -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
  104. -DELF_FORMAT="$(ELF_FORMAT)" $(CPP_MODE-y) \
  105. -DKERNEL_STACK_SIZE=$(STACK_SIZE) \
  106. -DUNMAP_PATH=arch/um/sys-$(SUBARCH)/unmap.o
  107. #The wrappers will select whether using "malloc" or the kernel allocator.
  108. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  109. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS)
  110. define cmd_vmlinux__
  111. $(CC) $(CFLAGS_vmlinux) -o $@ \
  112. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  113. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  114. -lutil \
  115. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) \
  116. FORCE ,$^) ; rm -f linux
  117. endef
  118. #When cleaning we don't include .config, so we don't include
  119. #TT or skas makefiles and don't clean skas_ptregs.h.
  120. CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \
  121. $(ARCH_DIR)/include/user_constants.h \
  122. $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch
  123. MRPROPER_FILES += $(ARCH_SYMLINKS)
  124. archclean:
  125. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  126. -o -name '*.gcov' \) -type f -print | xargs rm -f
  127. $(SYMLINK_HEADERS):
  128. @echo ' SYMLINK $@'
  129. ifneq ($(KBUILD_SRC),)
  130. $(Q)mkdir -p $(objtree)/include/asm-um
  131. $(Q)ln -fsn $(srctree)/include/asm-um/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
  132. else
  133. $(Q)cd $(TOPDIR)/$(dir $@) ; \
  134. ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $(notdir $@)
  135. endif
  136. include/asm-um/arch:
  137. @echo ' SYMLINK $@'
  138. ifneq ($(KBUILD_SRC),)
  139. $(Q)mkdir -p $(objtree)/include/asm-um
  140. $(Q)ln -fsn $(srctree)/include/asm-$(SUBARCH) include/asm-um/arch
  141. else
  142. $(Q)cd $(TOPDIR)/include/asm-um && ln -sf ../asm-$(SUBARCH) arch
  143. endif
  144. $(objtree)/$(ARCH_DIR)/include:
  145. @echo ' MKDIR $@'
  146. $(Q)mkdir -p $@
  147. $(ARCH_DIR)/include/sysdep: $(objtree)/$(ARCH_DIR)/include
  148. @echo ' SYMLINK $@'
  149. ifneq ($(KBUILD_SRC),)
  150. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep
  151. else
  152. $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep
  153. endif
  154. $(ARCH_DIR)/os:
  155. @echo ' SYMLINK $@'
  156. ifneq ($(KBUILD_SRC),)
  157. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $(ARCH_DIR)/os
  158. else
  159. $(Q)cd $(ARCH_DIR) && ln -sf os-$(OS) os
  160. endif
  161. # Generated files
  162. define filechk_umlconfig
  163. sed 's/ CONFIG/ UML_CONFIG/'
  164. endef
  165. $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
  166. $(call filechk,umlconfig)
  167. $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
  168. $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
  169. define filechk_gen-asm-offsets
  170. (set -e; \
  171. echo "/*"; \
  172. echo " * DO NOT MODIFY."; \
  173. echo " *"; \
  174. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  175. echo " *"; \
  176. echo " */"; \
  177. echo ""; \
  178. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  179. echo ""; )
  180. endef
  181. $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
  182. $(call filechk,gen-asm-offsets)
  183. $(ARCH_DIR)/include/kern_constants.h: $(objtree)/$(ARCH_DIR)/include
  184. @echo ' SYMLINK $@'
  185. $(Q)ln -sf ../../../include/asm-um/asm-offsets.h $@
  186. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS