1
0

Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # Copyright (C) 2006-2009 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. override QUILT:=
  9. override HOST_QUILT:=
  10. include $(INCLUDE_DIR)/kernel.mk
  11. PKG_NAME:=linux
  12. PKG_PATCHVER:=5.15
  13. # Manually include kernel version and hash from kernel details file
  14. include $(INCLUDE_DIR)/kernel-$(PKG_PATCHVER)
  15. PKG_VERSION:=$(PKG_PATCHVER)$(strip $(LINUX_VERSION-$(PKG_PATCHVER)))
  16. PKG_SOURCE:=$(PKG_NAME)-libre-$(PKG_VERSION)-gnu.tar.xz
  17. PKG_SOURCE_URL:=$(LINUX_SITE)
  18. PKG_HASH:=$(LINUX_KERNEL_HASH-$(strip $(PKG_VERSION)))
  19. PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/bpf-headers/$(PKG_NAME)-$(PKG_VERSION)
  20. GENERIC_PLATFORM_DIR := $(CURDIR)/../../../target/linux/generic
  21. GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
  22. GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
  23. GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
  24. GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(PKG_PATCHVER)),"$(dir)")
  25. PATCH_DIR := $(CURDIR)/patches
  26. FILES_DIR :=
  27. REAL_LINUX_DIR := $(LINUX_DIR)
  28. LINUX_DIR := $(PKG_BUILD_DIR)
  29. include $(INCLUDE_DIR)/bpf.mk
  30. include $(INCLUDE_DIR)/package.mk
  31. define Package/bpf-headers
  32. SECTION:=kernel
  33. CATEGORY:=Kernel modules
  34. TITLE:=eBPF kernel headers
  35. BUILDONLY:=1
  36. HIDDEN:=1
  37. endef
  38. PKG_CONFIG_PATH:=
  39. export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
  40. KERNEL_MAKE := \
  41. $(MAKE) -C $(PKG_BUILD_DIR) \
  42. ARCH=$(BPF_KARCH) \
  43. CROSS_COMPILE=$(BPF_ARCH)-linux- \
  44. LLVM=1 CC="$(CLANG)" LD="$(TARGET_CROSS)ld" \
  45. HOSTCC="$(HOSTCC)" \
  46. HOSTCXX="$(HOSTCXX)" \
  47. KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \
  48. CONFIG_SHELL="$(BASH)" \
  49. INSTALL_HDR_PATH="$(PKG_BUILD_DIR)/user_headers"
  50. define Build/Patch
  51. $(Kernel/Patch/Default)
  52. endef
  53. BPF_DOC = $(PKG_BUILD_DIR)/scripts/bpf_doc.py
  54. define Build/Configure/64
  55. echo 'CONFIG_CPU_MIPS64_R2=y' >> $(PKG_BUILD_DIR)/.config
  56. echo 'CONFIG_64BIT=y' >> $(PKG_BUILD_DIR)/.config
  57. endef
  58. define Build/Configure
  59. grep -vE 'CONFIG_(CPU_.*ENDIAN|HZ)' $(PKG_BUILD_DIR)/arch/mips/configs/generic_defconfig > $(PKG_BUILD_DIR)/.config
  60. echo 'CONFIG_CPU_$(if $(CONFIG_BIG_ENDIAN),BIG,LITTLE)_ENDIAN=y' >> $(PKG_BUILD_DIR)/.config
  61. $(if $(CONFIG_ARCH_64BIT),$(Build/Configure/64))
  62. grep CONFIG_HZ $(REAL_LINUX_DIR)/.config >> $(PKG_BUILD_DIR)/.config
  63. yes '' | $(KERNEL_MAKE) oldconfig
  64. grep 'CONFIG_HZ=' $(REAL_LINUX_DIR)/.config | \
  65. cut -d= -f2 | \
  66. bc -q $(LINUX_DIR)/kernel/time/timeconst.bc \
  67. > $(LINUX_DIR)/include/generated/timeconst.h
  68. $(BPF_DOC) --header \
  69. --file $(LINUX_DIR)/tools/include/uapi/linux/bpf.h \
  70. > $(PKG_BUILD_DIR)/tools/lib/bpf/bpf_helper_defs.h
  71. endef
  72. define Build/Compile
  73. $(KERNEL_MAKE) archprepare headers_install
  74. endef
  75. define Build/InstallDev
  76. mkdir -p $(1)/bpf-headers/arch $(1)/bpf-headers/tools
  77. $(CP) \
  78. $(PKG_BUILD_DIR)/arch/$(BPF_KARCH) \
  79. $(1)/bpf-headers/arch/
  80. $(CP) \
  81. $(PKG_BUILD_DIR)/tools/lib \
  82. $(PKG_BUILD_DIR)/tools/testing \
  83. $(1)/bpf-headers/tools/
  84. $(CP) \
  85. $(PKG_BUILD_DIR)/include \
  86. $(PKG_BUILD_DIR)/samples \
  87. $(PKG_BUILD_DIR)/scripts \
  88. $(PKG_BUILD_DIR)/user_headers \
  89. $(1)/bpf-headers
  90. $(CP) \
  91. $(CURDIR)/files/stdarg.h \
  92. $(1)/bpf-headers/include
  93. endef
  94. $(eval $(call BuildPackage,bpf-headers))