Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  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 processor.h ptrace.h \
  19. module.h vm-flags.h elf.h
  20. SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),$(ARCH_DIR)/include/asm/$(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 = $(ARCH_DIR)/include/shared/sysdep $(ARCH_DIR)/os \
  27. $(SYMLINK_HEADERS) $(ARCH_DIR)/include/shared/uml-config.h
  28. MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas
  29. include $(srctree)/$(ARCH_DIR)/Makefile-skas
  30. ARCH_INCLUDE := -I$(ARCH_DIR)/include/shared
  31. ifneq ($(KBUILD_SRC),)
  32. ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared
  33. KBUILD_CPPFLAGS += -I$(ARCH_DIR)/include # for SYMLINK_HEADERS
  34. endif
  35. SYS_DIR := $(ARCH_DIR)/include/shared/sysdep-$(SUBARCH)
  36. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  37. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  38. #
  39. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  40. # only get link-time error, luckily.
  41. #
  42. # These apply to USER_CFLAGS to.
  43. KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  44. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  45. -Din6addr_loopback=kernel_in6addr_loopback \
  46. -Din6addr_any=kernel_in6addr_any
  47. KBUILD_AFLAGS += $(ARCH_INCLUDE)
  48. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  49. $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  50. $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
  51. include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
  52. #This will adjust *FLAGS accordingly to the platform.
  53. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
  54. KBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include
  55. # -Derrno=kernel_errno - This turns all kernel references to errno into
  56. # kernel_errno to separate them from the libc errno. This allows -fno-common
  57. # in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different
  58. # errnos.
  59. # These apply to kernelspace only.
  60. #
  61. # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  62. # defines more robust
  63. KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  64. -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
  65. KBUILD_CFLAGS += $(KERNEL_DEFINES)
  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 ln -fsn Kconfig.$(SUBARCH) $(ARCH_DIR)/Kconfig.arch)
  81. endif
  82. archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/shared/user_constants.h
  83. prepare: $(ARCH_DIR)/include/shared/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. CPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
  92. -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE)
  93. # The wrappers will select whether using "malloc" or the kernel allocator.
  94. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  95. LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
  96. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
  97. define cmd_vmlinux__
  98. $(CC) $(CFLAGS_vmlinux) -o $@ \
  99. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  100. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  101. -lutil \
  102. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
  103. FORCE ,$^) ; rm -f linux
  104. endef
  105. # When cleaning we don't include .config, so we don't include
  106. # TT or skas makefiles and don't clean skas_ptregs.h.
  107. CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/shared/uml-config.h \
  108. $(ARCH_DIR)/include/shared/user_constants.h \
  109. $(ARCH_DIR)/include/shared/kern_constants.h $(ARCH_DIR)/Kconfig.arch
  110. MRPROPER_FILES += $(ARCH_SYMLINKS)
  111. archclean:
  112. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  113. -o -name '*.gcov' \) -type f -print | xargs rm -f
  114. $(SYMLINK_HEADERS):
  115. @echo ' SYMLINK $@'
  116. ifneq ($(KBUILD_SRC),)
  117. $(Q)mkdir -p $(objtree)/$(ARCH_DIR)/include/asm
  118. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/asm/$(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
  119. else
  120. $(Q)ln -sf $(basename $(notdir $@))-$(SUBARCH)$(suffix $@) $@
  121. endif
  122. $(objtree)/$(ARCH_DIR)/include/shared:
  123. @echo ' MKDIR $@'
  124. $(Q)mkdir -p $@
  125. $(ARCH_DIR)/include/shared/sysdep: $(objtree)/$(ARCH_DIR)/include/shared
  126. @echo ' SYMLINK $@'
  127. ifneq ($(KBUILD_SRC),)
  128. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/shared/sysdep-$(SUBARCH) $@
  129. else
  130. $(Q)ln -fsn sysdep-$(SUBARCH) $@
  131. endif
  132. $(ARCH_DIR)/os:
  133. @echo ' SYMLINK $@'
  134. ifneq ($(KBUILD_SRC),)
  135. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $@
  136. else
  137. $(Q)ln -fsn os-$(OS) $@
  138. endif
  139. # Generated files
  140. define filechk_umlconfig
  141. sed 's/ CONFIG/ UML_CONFIG/'
  142. endef
  143. $(ARCH_DIR)/include/shared/uml-config.h : include/linux/autoconf.h
  144. $(call filechk,umlconfig)
  145. $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
  146. $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
  147. define filechk_gen-asm-offsets
  148. (set -e; \
  149. echo "/*"; \
  150. echo " * DO NOT MODIFY."; \
  151. echo " *"; \
  152. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  153. echo " *"; \
  154. echo " */"; \
  155. echo ""; \
  156. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  157. echo ""; )
  158. endef
  159. $(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
  160. $(call filechk,gen-asm-offsets)
  161. $(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared
  162. @echo ' SYMLINK $@'
  163. $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@
  164. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH