Makefile 5.1 KB

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