Makefile 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. include $(srctree)/$(ARCH_DIR)/Makefile-skas
  27. include $(srctree)/$(ARCH_DIR)/Makefile-$(HEADER_ARCH)
  28. SHARED_HEADERS := $(ARCH_DIR)/include/shared
  29. ARCH_INCLUDE := -I$(srctree)/$(SHARED_HEADERS)
  30. ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/sys-$(HEADER_ARCH)/shared
  31. KBUILD_CPPFLAGS += -I$(srctree)/$(ARCH_DIR)/sys-$(HEADER_ARCH)
  32. # -Dvmap=kernel_vmap prevents anything from referencing the libpcap.o symbol so
  33. # named - it's a common symbol in libpcap, so we get a binary which crashes.
  34. #
  35. # Same things for in6addr_loopback and mktime - found in libc. For these two we
  36. # only get link-time error, luckily.
  37. #
  38. # These apply to USER_CFLAGS to.
  39. KBUILD_CFLAGS += $(CFLAGS) $(CFLAGS-y) -D__arch_um__ -DSUBARCH=\"$(SUBARCH)\" \
  40. $(ARCH_INCLUDE) $(MODE_INCLUDE) -Dvmap=kernel_vmap \
  41. -Din6addr_loopback=kernel_in6addr_loopback \
  42. -Din6addr_any=kernel_in6addr_any -Dstrrchr=kernel_strrchr
  43. KBUILD_AFLAGS += $(ARCH_INCLUDE)
  44. USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
  45. $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
  46. $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
  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. KBUILD_KCONFIG := arch/um/Kconfig.$(HEADER_ARCH)
  73. archprepare: include/generated/user_constants.h
  74. LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static
  75. LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib
  76. CFLAGS_NO_HARDENING := $(call cc-option, -fno-PIC,) $(call cc-option, -fno-pic,) \
  77. $(call cc-option, -fno-stack-protector,) \
  78. $(call cc-option, -fno-stack-protector-all,)
  79. # Options used by linker script
  80. export LDS_START := $(START)
  81. export LDS_ELF_ARCH := $(ELF_ARCH)
  82. export LDS_ELF_FORMAT := $(ELF_FORMAT)
  83. # The wrappers will select whether using "malloc" or the kernel allocator.
  84. LINK_WRAPS = -Wl,--wrap,malloc -Wl,--wrap,free -Wl,--wrap,calloc
  85. LD_FLAGS_CMDLINE = $(foreach opt,$(LDFLAGS),-Wl,$(opt))
  86. CFLAGS_vmlinux := $(LINK-y) $(LINK_WRAPS) $(LD_FLAGS_CMDLINE)
  87. define cmd_vmlinux__
  88. $(CC) $(CFLAGS_vmlinux) -o $@ \
  89. -Wl,-T,$(vmlinux-lds) $(vmlinux-init) \
  90. -Wl,--start-group $(vmlinux-main) -Wl,--end-group \
  91. -lutil \
  92. $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o \
  93. FORCE ,$^) ; rm -f linux
  94. endef
  95. # When cleaning we don't include .config, so we don't include
  96. # TT or skas makefiles and don't clean skas_ptregs.h.
  97. CLEAN_FILES += linux x.i gmon.out
  98. archclean:
  99. @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \
  100. -o -name '*.gcov' \) -type f -print | xargs rm -f
  101. # Generated files
  102. $(ARCH_DIR)/sys-$(HEADER_ARCH)/user-offsets.s: FORCE
  103. $(Q)$(MAKE) $(build)=$(ARCH_DIR)/sys-$(HEADER_ARCH) $@
  104. define filechk_gen-asm-offsets
  105. (set -e; \
  106. echo "/*"; \
  107. echo " * DO NOT MODIFY."; \
  108. echo " *"; \
  109. echo " * This file was generated by arch/$(ARCH)/Makefile"; \
  110. echo " *"; \
  111. echo " */"; \
  112. echo ""; \
  113. sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
  114. echo ""; )
  115. endef
  116. include/generated/user_constants.h: $(ARCH_DIR)/sys-$(HEADER_ARCH)/user-offsets.s
  117. $(call filechk,gen-asm-offsets)
  118. export SUBARCH USER_CFLAGS CFLAGS_NO_HARDENING OS HEADER_ARCH DEV_NULL_PATH