Makefile 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. # XXX: The "os" symlink is only used by arch/um/include/os.h, which includes
  18. # ../os/include/file.h
  19. #
  20. # These are cleaned up during mrproper. Please DO NOT fix it again, this is
  21. # the Correct Thing(tm) to do!
  22. ARCH_SYMLINKS = $(ARCH_DIR)/os $(ARCH_DIR)/include/shared/uml-config.h
  23. MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas
  24. include $(srctree)/$(ARCH_DIR)/Makefile-skas
  25. ARCH_INCLUDE := -I$(srctree)/$(ARCH_DIR)/include/shared
  26. ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)/shared
  27. ifneq ($(KBUILD_SRC),)
  28. ARCH_INCLUDE += -I$(ARCH_DIR)/include/shared # for three generated files
  29. endif
  30. KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(SUBARCH)
  31. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  32. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  33. #
  34. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  35. # only get link-time error, luckily.
  36. #
  37. # These apply to USER_CFLAGS to.
  38. KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  39. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  40. -Din6addr_loopback=kernel_in6addr_loopback \
  41. -Din6addr_any=kernel_in6addr_any
  42. KBUILD_AFLAGS += $(ARCH_INCLUDE)
  43. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  44. $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  45. $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64
  46. include $(srctree)/$(ARCH_DIR)/Makefile-$(SUBARCH)
  47. #This will adjust *FLAGS accordingly to the platform.
  48. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
  49. KBUILD_CPPFLAGS += -I$(srctree)/arch/$(HEADER_ARCH)/include
  50. # -Derrno=kernel_errno - This turns all kernel references to errno into
  51. # kernel_errno to separate them from the libc errno. This allows -fno-common
  52. # in KBUILD_CFLAGS. Otherwise, it would cause ld to complain about the two different
  53. # errnos.
  54. # These apply to kernelspace only.
  55. #
  56. # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  57. # defines more robust
  58. KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  59. -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
  60. KBUILD_CFLAGS += $(KERNEL_DEFINES)
  61. PHONY += linux
  62. all: linux
  63. linux: vmlinux
  64. @echo ' LINK $@'
  65. $(Q)ln -f $< $@
  66. define archhelp
  67. echo '* linux - Binary kernel image (./linux) - for backward'
  68. echo ' compatibility only, this creates a hard link to the'
  69. echo ' real kernel binary, the "vmlinux" binary you'
  70. echo ' find in the kernel root.'
  71. endef
  72. ifneq ($(KBUILD_SRC),)
  73. $(shell mkdir -p $(ARCH_DIR) && ln -fsn $(srctree)/$(ARCH_DIR)/Kconfig.$(HEADER_ARCH) $(ARCH_DIR)/Kconfig.arch)
  74. else
  75. $(shell ln -fsn Kconfig.$(HEADER_ARCH) $(ARCH_DIR)/Kconfig.arch)
  76. endif
  77. archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/shared/user_constants.h
  78. prepare: $(ARCH_DIR)/include/shared/kern_constants.h
  79. LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  80. LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
  81. CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  82. $(call cc-option, -fno-stack-protector,) \
  83. $(call cc-option, -fno-stack-protector-all,)
  84. CONFIG_KERNEL_STACK_ORDER ?= 2
  85. STACK_SIZE := $(shell echo $$[ 4096 * (1 << $(CONFIG_KERNEL_STACK_ORDER)) ] )
  86. CPPFLAGS_vmlinux.lds = -U$(SUBARCH) -DSTART=$(START) -DELF_ARCH=$(ELF_ARCH) \
  87. -DELF_FORMAT="$(ELF_FORMAT)" -DKERNEL_STACK_SIZE=$(STACK_SIZE)
  88. # The wrappers will select whether using "malloc" or the kernel allocator.
  89. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  90. LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
  91. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
  92. define cmd_vmlinux__
  93. $(CC) $(CFLAGS_vmlinux) -o $@ \
  94. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  95. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  96. -lutil \
  97. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
  98. FORCE ,$^) ; rm -f linux
  99. endef
  100. # When cleaning we don't include .config, so we don't include
  101. # TT or skas makefiles and don't clean skas_ptregs.h.
  102. CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/shared/uml-config.h \
  103. $(ARCH_DIR)/include/shared/user_constants.h \
  104. $(ARCH_DIR)/include/shared/kern_constants.h $(ARCH_DIR)/Kconfig.arch
  105. MRPROPER_FILES += $(ARCH_SYMLINKS)
  106. archclean:
  107. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  108. -o -name '*.gcov' \) -type f -print | xargs rm -f
  109. $(objtree)/$(ARCH_DIR)/include/shared:
  110. @echo ' MKDIR $@'
  111. $(Q)mkdir -p $@
  112. $(ARCH_DIR)/os:
  113. @echo ' SYMLINK $@'
  114. ifneq ($(KBUILD_SRC),)
  115. $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/os-$(OS) $@
  116. else
  117. $(Q)ln -fsn os-$(OS) $@
  118. endif
  119. # Generated files
  120. define filechk_umlconfig
  121. sed 's/ CONFIG/ UML_CONFIG/'
  122. endef
  123. $(ARCH_DIR)/include/shared/uml-config.h : include/linux/autoconf.h
  124. $(call filechk,umlconfig)
  125. $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s: FORCE
  126. $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(SUBARCH) $@
  127. define filechk_gen-asm-offsets
  128. (set -e; \
  129. echo "/*"; \
  130. echo " * DO NOT MODIFY."; \
  131. echo " *"; \
  132. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  133. echo " *"; \
  134. echo " */"; \
  135. echo ""; \
  136. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  137. echo ""; )
  138. endef
  139. $(ARCH_DIR)/include/shared/user_constants.h: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.s
  140. $(call filechk,gen-asm-offsets)
  141. $(ARCH_DIR)/include/shared/kern_constants.h: $(objtree)/$(ARCH_DIR)/include/shared
  142. @echo ' SYMLINK $@'
  143. $(Q)ln -sf ../../../../include/asm/asm-offsets.h $@
  144. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH