Makefile 5.5 KB

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