OSDN Git Service

4ffe5a7cc04158cdeff844880d6a948def001df5
[immortalwrt/immortalwrt.git] / package / kernel / bpf-headers / Makefile
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
9 override QUILT:=
10 override HOST_QUILT:=
11
12 include $(INCLUDE_DIR)/kernel.mk
13
14
15 PKG_NAME:=linux
16 PKG_PATCHVER:=5.15
17 # Manually include kernel version and hash from kernel details file
18 include $(INCLUDE_DIR)/kernel-$(PKG_PATCHVER)
19
20 PKG_VERSION:=$(PKG_PATCHVER)$(strip $(LINUX_VERSION-$(PKG_PATCHVER)))
21 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
22 PKG_SOURCE_URL:=$(LINUX_SITE)
23 PKG_HASH:=$(LINUX_KERNEL_HASH-$(strip $(PKG_VERSION)))
24 PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/bpf-headers/$(PKG_NAME)-$(PKG_VERSION)
25
26 GENERIC_PLATFORM_DIR := $(CURDIR)/../../../target/linux/generic
27 GENERIC_BACKPORT_DIR := $(GENERIC_PLATFORM_DIR)/backport$(if $(wildcard $(GENERIC_PLATFORM_DIR)/backport-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
28 GENERIC_PATCH_DIR := $(GENERIC_PLATFORM_DIR)/pending$(if $(wildcard $(GENERIC_PLATFORM_DIR)/pending-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
29 GENERIC_HACK_DIR := $(GENERIC_PLATFORM_DIR)/hack$(if $(wildcard $(GENERIC_PLATFORM_DIR)/hack-$(PKG_PATCHVER)),-$(PKG_PATCHVER))
30 GENERIC_FILES_DIR := $(foreach dir,$(wildcard $(GENERIC_PLATFORM_DIR)/files $(GENERIC_PLATFORM_DIR)/files-$(PKG_PATCHVER)),"$(dir)")
31 PATCH_DIR := $(CURDIR)/patches
32 FILES_DIR :=
33
34 REAL_LINUX_DIR := $(LINUX_DIR)
35 LINUX_DIR := $(PKG_BUILD_DIR)
36
37 include $(INCLUDE_DIR)/bpf.mk
38 include $(INCLUDE_DIR)/package.mk
39
40 define Package/bpf-headers
41   SECTION:=kernel
42   CATEGORY:=Kernel
43   TITLE:=eBPF kernel headers
44   BUILDONLY:=1
45   HIDDEN:=1
46 endef
47
48 PKG_CONFIG_PATH:=
49
50 export HOST_EXTRACFLAGS=-I$(STAGING_DIR_HOST)/include
51
52 KERNEL_MAKE := \
53         $(MAKE) -C $(PKG_BUILD_DIR) \
54                 ARCH=$(BPF_KARCH) \
55                 CROSS_COMPILE=$(BPF_ARCH)-linux- \
56                 LLVM=1 CC="$(CLANG)" LD="$(TARGET_CROSS)ld" \
57                 HOSTCC="$(HOSTCC)" \
58                 HOSTCXX="$(HOSTCXX)" \
59                 HOST_LOADLIBES="-L$(STAGING_DIR_HOST)/lib" \
60                 KBUILD_HOSTLDLIBS="-L$(STAGING_DIR_HOST)/lib" \
61                 CONFIG_SHELL="$(BASH)" \
62                 INSTALL_HDR_PATH="$(PKG_BUILD_DIR)/user_headers"
63
64 define Build/Patch
65         $(Kernel/Patch/Default)
66 endef
67
68 BPF_DOC = $(PKG_BUILD_DIR)/scripts/bpf_doc.py
69
70 define Build/Configure/64
71         echo 'CONFIG_CPU_MIPS64_R2=y' >> $(PKG_BUILD_DIR)/.config
72         echo 'CONFIG_64BIT=y' >> $(PKG_BUILD_DIR)/.config
73 endef
74
75 define Build/Configure
76         grep -vE 'CONFIG_(CPU_.*ENDIAN|HZ)' $(PKG_BUILD_DIR)/arch/mips/configs/generic_defconfig > $(PKG_BUILD_DIR)/.config
77         echo 'CONFIG_CPU_$(if $(CONFIG_BIG_ENDIAN),BIG,LITTLE)_ENDIAN=y' >> $(PKG_BUILD_DIR)/.config
78         $(if $(CONFIG_ARCH_64BIT),$(Build/Configure/64))
79         grep CONFIG_HZ $(REAL_LINUX_DIR)/.config >> $(PKG_BUILD_DIR)/.config
80         yes '' | $(KERNEL_MAKE) oldconfig
81         grep 'CONFIG_HZ=' $(REAL_LINUX_DIR)/.config | \
82                 cut -d= -f2 | \
83                 bc -q $(LINUX_DIR)/kernel/time/timeconst.bc \
84                 > $(LINUX_DIR)/include/generated/timeconst.h
85         $(BPF_DOC) --header \
86                 --file $(LINUX_DIR)/tools/include/uapi/linux/bpf.h \
87                 > $(PKG_BUILD_DIR)/tools/lib/bpf/bpf_helper_defs.h
88 endef
89
90 define Build/Compile
91         $(KERNEL_MAKE) archprepare headers_install
92 endef
93
94 define Build/InstallDev
95         mkdir -p $(1)/bpf-headers/arch $(1)/bpf-headers/tools
96         $(CP) \
97                 $(PKG_BUILD_DIR)/arch/$(BPF_KARCH) \
98                 $(1)/bpf-headers/arch/
99         $(CP) \
100                 $(PKG_BUILD_DIR)/tools/lib \
101                 $(PKG_BUILD_DIR)/tools/testing \
102                 $(1)/bpf-headers/tools/
103         $(CP) \
104                 $(PKG_BUILD_DIR)/include \
105                 $(PKG_BUILD_DIR)/samples \
106                 $(PKG_BUILD_DIR)/scripts \
107                 $(PKG_BUILD_DIR)/user_headers \
108                 $(1)/bpf-headers
109         $(CP) \
110                 $(CURDIR)/files/stdarg.h \
111                 $(1)/bpf-headers/include
112 endef
113
114 $(eval $(call BuildPackage,bpf-headers))