Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  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. MODE_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include/shared/skas
  18. HEADER_ARCH := $(SUBARCH)
  19. # Additional ARCH settings for x86
  20. ifeq ($(SUBARCH),i386)
  21. HEADER_ARCH := x86
  22. endif
  23. ifeq ($(SUBARCH),x86_64)
  24. HEADER_ARCH := x86
  25. endif
  26. HOST_DIR := arch/$(HEADER_ARCH)
  27. include $(srctree)/$(ARCH_DIR)/Makefile-skas
  28. include $(srctree)/$(HOST_DIR)/Makefile.um
  29. core-y += $(HOST_DIR)/um/
  30. SHARED_HEADERS := $(ARCH_DIR)/include/shared
  31. ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS)
  32. ARCH_INCLUDE += -I$(srctree)/$(HOST_DIR)/um/shared
  33. KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/um
  34. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  35. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  36. #
  37. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  38. # only get link-time error, luckily.
  39. #
  40. # These apply to USER_CFLAGS to.
  41. KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  42. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  43. -Din6addr_loopback=kernel_in6addr_loopback \
  44. -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
  45. KBUILD_AFLAGS += $(ARCH_INCLUDE)
  46. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  47. $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  48. $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
  49. #This will adjust *FLAGS accordingly to the platform.
  50. include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
  51. KBUILD_CPPFLAGS += -I$(srctree)/$(HOST_DIR)/include \
  52. -I$(HOST_DIR)/include/generated
  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. #
  59. # strip leading and trailing whitespace to make the USER_CFLAGS removal of these
  60. # defines more robust
  61. KERNEL_DEFINES = $(strip -Derrno=kernel_errno -Dsigprocmask=kernel_sigprocmask \
  62. -Dmktime=kernel_mktime $(ARCH_KERNEL_DEFINES))
  63. KBUILD_CFLAGS += $(KERNEL_DEFINES)
  64. PHONY += linux
  65. all: linux
  66. linux: vmlinux
  67. @echo ' LINK $@'
  68. $(Q)ln -f $< $@
  69. define archhelp
  70. echo '* linux - Binary kernel image (./linux) - for backward'
  71. echo ' compatibility only, this creates a hard link to the'
  72. echo ' real kernel binary, the "vmlinux" binary you'
  73. echo ' find in the kernel root.'
  74. endef
  75. KBUILD_KCONFIG := $(HOST_DIR)/um/Kconfig
  76. archheaders:
  77. $(Q)$(MAKE) -C '$(srctree)' KBUILD_SRC= \
  78. ARCH=$(SUBARCH) O='$(objtree)' archheaders
  79. archprepare: include/generated/user_constants.h
  80. LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  81. LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
  82. CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  83. $(call cc-option, -fno-stack-protector,) \
  84. $(call cc-option, -fno-stack-protector-all,)
  85. # Options used by linker script
  86. export LDS_START := $(START)
  87. export LDS_ELF_ARCH := $(ELF_ARCH)
  88. export LDS_ELF_FORMAT := $(ELF_FORMAT)
  89. # The wrappers will select whether using "malloc" or the kernel allocator.
  90. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  91. LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
  92. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
  93. define cmd_vmlinux__
  94. $(CC) $(CFLAGS_vmlinux) -o $@ \
  95. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  96. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  97. -lutil \
  98. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
  99. FORCE ,$^) ; rm -f linux
  100. endef
  101. # When cleaning we don't include .config, so we don't include
  102. # TT or skas makefiles and don't clean skas_ptregs.h.
  103. CLEAN_FILES += linux x.i gmon.out
  104. archclean:
  105. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  106. -o -name '*.gcov' \) -type f -print | xargs rm -f
  107. # Generated files
  108. $(HOST_DIR)/um/user-offsets.s: __headers FORCE
  109. $(Q)$(MAKE) $(build)=$(HOST_DIR)/um $@
  110. define filechk_gen-asm-offsets
  111. (set -e; \
  112. echo "/*"; \
  113. echo " * DO NOT MODIFY."; \
  114. echo " *"; \
  115. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  116. echo " *"; \
  117. echo " */"; \
  118. echo ""; \
  119. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  120. echo ""; )
  121. endef
  122. include/generated/user_constants.h: $(HOST_DIR)/um/user-offsets.s
  123. $(call filechk,gen-asm-offsets)
  124. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS DEV_NULL_PATH