18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
28c2ecf20Sopenharmony_ci# Most of this file is copied from tools/lib/traceevent/Makefile
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ciRM ?= rm
58c2ecf20Sopenharmony_cisrctree = $(abs_srctree)
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciVERSION_SCRIPT := libbpf.map
88c2ecf20Sopenharmony_ciLIBBPF_VERSION := $(shell \
98c2ecf20Sopenharmony_ci	grep -oE '^LIBBPF_([0-9.]+)' $(VERSION_SCRIPT) | \
108c2ecf20Sopenharmony_ci	sort -rV | head -n1 | cut -d'_' -f2)
118c2ecf20Sopenharmony_ciLIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ciMAKEFLAGS += --no-print-directory
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci# This will work when bpf is built in tools env. where srctree
168c2ecf20Sopenharmony_ci# isn't set and when invoked from selftests build, where srctree
178c2ecf20Sopenharmony_ci# is a ".". building_out_of_srctree is undefined for in srctree
188c2ecf20Sopenharmony_ci# builds
198c2ecf20Sopenharmony_ciifndef building_out_of_srctree
208c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
218c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
228c2ecf20Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
238c2ecf20Sopenharmony_ci#$(info Determined 'srctree' to be $(srctree))
248c2ecf20Sopenharmony_ciendif
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ciINSTALL = install
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci# Use DESTDIR for installing into a different root directory.
298c2ecf20Sopenharmony_ci# This is useful for building a package. The program will be
308c2ecf20Sopenharmony_ci# installed in this directory as if it was the root directory.
318c2ecf20Sopenharmony_ci# Then the build tool can move it later.
328c2ecf20Sopenharmony_ciDESTDIR ?=
338c2ecf20Sopenharmony_ciDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.arch
368c2ecf20Sopenharmony_ci
378c2ecf20Sopenharmony_ciifeq ($(LP64), 1)
388c2ecf20Sopenharmony_ci  libdir_relative = lib64
398c2ecf20Sopenharmony_cielse
408c2ecf20Sopenharmony_ci  libdir_relative = lib
418c2ecf20Sopenharmony_ciendif
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ciprefix ?= /usr/local
448c2ecf20Sopenharmony_cilibdir = $(prefix)/$(libdir_relative)
458c2ecf20Sopenharmony_ciman_dir = $(prefix)/share/man
468c2ecf20Sopenharmony_ciman_dir_SQ = '$(subst ','\'',$(man_dir))'
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciexport man_dir man_dir_SQ INSTALL
498c2ecf20Sopenharmony_ciexport DESTDIR DESTDIR_SQ
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.include
528c2ecf20Sopenharmony_ci
538c2ecf20Sopenharmony_ci# copy a bit from Linux kbuild
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciifeq ("$(origin V)", "command line")
568c2ecf20Sopenharmony_ci  VERBOSE = $(V)
578c2ecf20Sopenharmony_ciendif
588c2ecf20Sopenharmony_ciifndef VERBOSE
598c2ecf20Sopenharmony_ci  VERBOSE = 0
608c2ecf20Sopenharmony_ciendif
618c2ecf20Sopenharmony_ci
628c2ecf20Sopenharmony_ciFEATURE_USER = .libbpf
638c2ecf20Sopenharmony_ciFEATURE_TESTS = libelf zlib bpf
648c2ecf20Sopenharmony_ciFEATURE_DISPLAY = libelf zlib bpf
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciINCLUDES = -I. -I$(srctree)/tools/include -I$(srctree)/tools/include/uapi
678c2ecf20Sopenharmony_ciFEATURE_CHECK_CFLAGS-bpf = $(INCLUDES)
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_cicheck_feat := 1
708c2ecf20Sopenharmony_ciNON_CHECK_FEAT_TARGETS := clean TAGS tags cscope help
718c2ecf20Sopenharmony_ciifdef MAKECMDGOALS
728c2ecf20Sopenharmony_ciifeq ($(filter-out $(NON_CHECK_FEAT_TARGETS),$(MAKECMDGOALS)),)
738c2ecf20Sopenharmony_ci  check_feat := 0
748c2ecf20Sopenharmony_ciendif
758c2ecf20Sopenharmony_ciendif
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ciifeq ($(check_feat),1)
788c2ecf20Sopenharmony_ciifeq ($(FEATURES_DUMP),)
798c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.feature
808c2ecf20Sopenharmony_cielse
818c2ecf20Sopenharmony_ciinclude $(FEATURES_DUMP)
828c2ecf20Sopenharmony_ciendif
838c2ecf20Sopenharmony_ciendif
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ciexport prefix libdir src obj
868c2ecf20Sopenharmony_ci
878c2ecf20Sopenharmony_ci# Shell quotes
888c2ecf20Sopenharmony_cilibdir_SQ = $(subst ','\'',$(libdir))
898c2ecf20Sopenharmony_cilibdir_relative_SQ = $(subst ','\'',$(libdir_relative))
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciOBJ		= $@
928c2ecf20Sopenharmony_ciN		=
938c2ecf20Sopenharmony_ci
948c2ecf20Sopenharmony_ciLIB_TARGET	= libbpf.a libbpf.so.$(LIBBPF_VERSION)
958c2ecf20Sopenharmony_ciLIB_FILE	= libbpf.a libbpf.so*
968c2ecf20Sopenharmony_ciPC_FILE		= libbpf.pc
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci# Set compile option CFLAGS
998c2ecf20Sopenharmony_ciifdef EXTRA_CFLAGS
1008c2ecf20Sopenharmony_ci  CFLAGS := $(EXTRA_CFLAGS)
1018c2ecf20Sopenharmony_cielse
1028c2ecf20Sopenharmony_ci  CFLAGS := -g -O2
1038c2ecf20Sopenharmony_ciendif
1048c2ecf20Sopenharmony_ci
1058c2ecf20Sopenharmony_ci# Append required CFLAGS
1068c2ecf20Sopenharmony_cioverride CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
1078c2ecf20Sopenharmony_cioverride CFLAGS += -Werror -Wall
1088c2ecf20Sopenharmony_cioverride CFLAGS += $(INCLUDES)
1098c2ecf20Sopenharmony_cioverride CFLAGS += -fvisibility=hidden
1108c2ecf20Sopenharmony_cioverride CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
1118c2ecf20Sopenharmony_ci
1128c2ecf20Sopenharmony_ci# flags specific for shared library
1138c2ecf20Sopenharmony_ciSHLIB_FLAGS := -DSHARED -fPIC
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciifeq ($(VERBOSE),1)
1168c2ecf20Sopenharmony_ci  Q =
1178c2ecf20Sopenharmony_cielse
1188c2ecf20Sopenharmony_ci  Q = @
1198c2ecf20Sopenharmony_ciendif
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ci# Disable command line variables (CFLAGS) override from top
1228c2ecf20Sopenharmony_ci# level Makefile (perf), otherwise build Makefile will get
1238c2ecf20Sopenharmony_ci# the same command line setup.
1248c2ecf20Sopenharmony_ciMAKEOVERRIDES=
1258c2ecf20Sopenharmony_ci
1268c2ecf20Sopenharmony_ciall:
1278c2ecf20Sopenharmony_ci
1288c2ecf20Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS V
1298c2ecf20Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
1308c2ecf20Sopenharmony_ci
1318c2ecf20Sopenharmony_ciSHARED_OBJDIR	:= $(OUTPUT)sharedobjs/
1328c2ecf20Sopenharmony_ciSTATIC_OBJDIR	:= $(OUTPUT)staticobjs/
1338c2ecf20Sopenharmony_ciBPF_IN_SHARED	:= $(SHARED_OBJDIR)libbpf-in.o
1348c2ecf20Sopenharmony_ciBPF_IN_STATIC	:= $(STATIC_OBJDIR)libbpf-in.o
1358c2ecf20Sopenharmony_ciBPF_HELPER_DEFS	:= $(OUTPUT)bpf_helper_defs.h
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ciLIB_TARGET	:= $(addprefix $(OUTPUT),$(LIB_TARGET))
1388c2ecf20Sopenharmony_ciLIB_FILE	:= $(addprefix $(OUTPUT),$(LIB_FILE))
1398c2ecf20Sopenharmony_ciPC_FILE		:= $(addprefix $(OUTPUT),$(PC_FILE))
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ciTAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags)
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ciGLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
1448c2ecf20Sopenharmony_ci			   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
1458c2ecf20Sopenharmony_ci			   sed 's/\[.*\]//' | \
1468c2ecf20Sopenharmony_ci			   awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}' | \
1478c2ecf20Sopenharmony_ci			   sort -u | wc -l)
1488c2ecf20Sopenharmony_ciVERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
1498c2ecf20Sopenharmony_ci			      sed 's/\[.*\]//' | \
1508c2ecf20Sopenharmony_ci			      awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
1518c2ecf20Sopenharmony_ci			      grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l)
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciCMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ciall: fixdep
1568c2ecf20Sopenharmony_ci	$(Q)$(MAKE) all_cmd
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ciall_cmd: $(CMD_TARGETS) check
1598c2ecf20Sopenharmony_ci
1608c2ecf20Sopenharmony_ci$(BPF_IN_SHARED): force elfdep zdep bpfdep $(BPF_HELPER_DEFS)
1618c2ecf20Sopenharmony_ci	@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
1628c2ecf20Sopenharmony_ci	(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
1638c2ecf20Sopenharmony_ci	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf.h' differs from latest version at 'include/uapi/linux/bpf.h'" >&2 )) || true
1648c2ecf20Sopenharmony_ci	@(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
1658c2ecf20Sopenharmony_ci	(diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \
1668c2ecf20Sopenharmony_ci	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/bpf_common.h' differs from latest version at 'include/uapi/linux/bpf_common.h'" >&2 )) || true
1678c2ecf20Sopenharmony_ci	@(test -f ../../include/uapi/linux/netlink.h -a -f ../../../include/uapi/linux/netlink.h && ( \
1688c2ecf20Sopenharmony_ci	(diff -B ../../include/uapi/linux/netlink.h ../../../include/uapi/linux/netlink.h >/dev/null) || \
1698c2ecf20Sopenharmony_ci	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/netlink.h' differs from latest version at 'include/uapi/linux/netlink.h'" >&2 )) || true
1708c2ecf20Sopenharmony_ci	@(test -f ../../include/uapi/linux/if_link.h -a -f ../../../include/uapi/linux/if_link.h && ( \
1718c2ecf20Sopenharmony_ci	(diff -B ../../include/uapi/linux/if_link.h ../../../include/uapi/linux/if_link.h >/dev/null) || \
1728c2ecf20Sopenharmony_ci	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_link.h' differs from latest version at 'include/uapi/linux/if_link.h'" >&2 )) || true
1738c2ecf20Sopenharmony_ci	@(test -f ../../include/uapi/linux/if_xdp.h -a -f ../../../include/uapi/linux/if_xdp.h && ( \
1748c2ecf20Sopenharmony_ci	(diff -B ../../include/uapi/linux/if_xdp.h ../../../include/uapi/linux/if_xdp.h >/dev/null) || \
1758c2ecf20Sopenharmony_ci	echo "Warning: Kernel ABI header at 'tools/include/uapi/linux/if_xdp.h' differs from latest version at 'include/uapi/linux/if_xdp.h'" >&2 )) || true
1768c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)"
1778c2ecf20Sopenharmony_ci
1788c2ecf20Sopenharmony_ci$(BPF_IN_STATIC): force elfdep zdep bpfdep $(BPF_HELPER_DEFS)
1798c2ecf20Sopenharmony_ci	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR)
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci$(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h
1828c2ecf20Sopenharmony_ci	$(QUIET_GEN)$(srctree)/scripts/bpf_helpers_doc.py --header \
1838c2ecf20Sopenharmony_ci		--file $(srctree)/tools/include/uapi/linux/bpf.h > $(BPF_HELPER_DEFS)
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ci$(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION)
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ci$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN_SHARED) $(VERSION_SCRIPT)
1888c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(CC) $(LDFLAGS) \
1898c2ecf20Sopenharmony_ci		--shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \
1908c2ecf20Sopenharmony_ci		-Wl,--version-script=$(VERSION_SCRIPT) $< -lelf -lz -o $@
1918c2ecf20Sopenharmony_ci	@ln -sf $(@F) $(OUTPUT)libbpf.so
1928c2ecf20Sopenharmony_ci	@ln -sf $(@F) $(OUTPUT)libbpf.so.$(LIBBPF_MAJOR_VERSION)
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ci$(OUTPUT)libbpf.a: $(BPF_IN_STATIC)
1958c2ecf20Sopenharmony_ci	$(QUIET_LINK)$(RM) -f $@; $(AR) rcs $@ $^
1968c2ecf20Sopenharmony_ci
1978c2ecf20Sopenharmony_ci$(OUTPUT)libbpf.pc:
1988c2ecf20Sopenharmony_ci	$(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
1998c2ecf20Sopenharmony_ci		-e "s|@LIBDIR@|$(libdir_SQ)|" \
2008c2ecf20Sopenharmony_ci		-e "s|@VERSION@|$(LIBBPF_VERSION)|" \
2018c2ecf20Sopenharmony_ci		< libbpf.pc.template > $@
2028c2ecf20Sopenharmony_ci
2038c2ecf20Sopenharmony_cicheck: check_abi
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cicheck_abi: $(OUTPUT)libbpf.so $(VERSION_SCRIPT)
2068c2ecf20Sopenharmony_ci	@if [ "$(GLOBAL_SYM_COUNT)" != "$(VERSIONED_SYM_COUNT)" ]; then	 \
2078c2ecf20Sopenharmony_ci		echo "Warning: Num of global symbols in $(BPF_IN_SHARED)"	 \
2088c2ecf20Sopenharmony_ci		     "($(GLOBAL_SYM_COUNT)) does NOT match with num of"	 \
2098c2ecf20Sopenharmony_ci		     "versioned symbols in $^ ($(VERSIONED_SYM_COUNT))." \
2108c2ecf20Sopenharmony_ci		     "Please make sure all LIBBPF_API symbols are"	 \
2118c2ecf20Sopenharmony_ci		     "versioned in $(VERSION_SCRIPT)." >&2;		 \
2128c2ecf20Sopenharmony_ci		readelf -s --wide $(BPF_IN_SHARED) |			 \
2138c2ecf20Sopenharmony_ci		    cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' |	 \
2148c2ecf20Sopenharmony_ci		    sed 's/\[.*\]//' |					 \
2158c2ecf20Sopenharmony_ci		    awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
2168c2ecf20Sopenharmony_ci		    sort -u > $(OUTPUT)libbpf_global_syms.tmp;		 \
2178c2ecf20Sopenharmony_ci		readelf --dyn-syms --wide $(OUTPUT)libbpf.so |		 \
2188c2ecf20Sopenharmony_ci		    sed 's/\[.*\]//' |					 \
2198c2ecf20Sopenharmony_ci		    awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}'|  \
2208c2ecf20Sopenharmony_ci		    grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 |		 \
2218c2ecf20Sopenharmony_ci		    sort -u > $(OUTPUT)libbpf_versioned_syms.tmp; 	 \
2228c2ecf20Sopenharmony_ci		diff -u $(OUTPUT)libbpf_global_syms.tmp			 \
2238c2ecf20Sopenharmony_ci		     $(OUTPUT)libbpf_versioned_syms.tmp;		 \
2248c2ecf20Sopenharmony_ci		rm $(OUTPUT)libbpf_global_syms.tmp			 \
2258c2ecf20Sopenharmony_ci		   $(OUTPUT)libbpf_versioned_syms.tmp;			 \
2268c2ecf20Sopenharmony_ci		exit 1;							 \
2278c2ecf20Sopenharmony_ci	fi
2288c2ecf20Sopenharmony_ci
2298c2ecf20Sopenharmony_cidefine do_install_mkdir
2308c2ecf20Sopenharmony_ci	if [ ! -d '$(DESTDIR_SQ)$1' ]; then		\
2318c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1';	\
2328c2ecf20Sopenharmony_ci	fi
2338c2ecf20Sopenharmony_ciendef
2348c2ecf20Sopenharmony_ci
2358c2ecf20Sopenharmony_cidefine do_install
2368c2ecf20Sopenharmony_ci	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
2378c2ecf20Sopenharmony_ci		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
2388c2ecf20Sopenharmony_ci	fi;						\
2398c2ecf20Sopenharmony_ci	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
2408c2ecf20Sopenharmony_ciendef
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ciinstall_lib: all_cmd
2438c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, $(LIB_TARGET)) \
2448c2ecf20Sopenharmony_ci		$(call do_install_mkdir,$(libdir_SQ)); \
2458c2ecf20Sopenharmony_ci		cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
2468c2ecf20Sopenharmony_ci
2478c2ecf20Sopenharmony_ciinstall_headers: $(BPF_HELPER_DEFS)
2488c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, headers) \
2498c2ecf20Sopenharmony_ci		$(call do_install,bpf.h,$(prefix)/include/bpf,644); \
2508c2ecf20Sopenharmony_ci		$(call do_install,libbpf.h,$(prefix)/include/bpf,644); \
2518c2ecf20Sopenharmony_ci		$(call do_install,btf.h,$(prefix)/include/bpf,644); \
2528c2ecf20Sopenharmony_ci		$(call do_install,libbpf_util.h,$(prefix)/include/bpf,644); \
2538c2ecf20Sopenharmony_ci		$(call do_install,libbpf_common.h,$(prefix)/include/bpf,644); \
2548c2ecf20Sopenharmony_ci		$(call do_install,xsk.h,$(prefix)/include/bpf,644); \
2558c2ecf20Sopenharmony_ci		$(call do_install,bpf_helpers.h,$(prefix)/include/bpf,644); \
2568c2ecf20Sopenharmony_ci		$(call do_install,$(BPF_HELPER_DEFS),$(prefix)/include/bpf,644); \
2578c2ecf20Sopenharmony_ci		$(call do_install,bpf_tracing.h,$(prefix)/include/bpf,644); \
2588c2ecf20Sopenharmony_ci		$(call do_install,bpf_endian.h,$(prefix)/include/bpf,644); \
2598c2ecf20Sopenharmony_ci		$(call do_install,bpf_core_read.h,$(prefix)/include/bpf,644);
2608c2ecf20Sopenharmony_ci
2618c2ecf20Sopenharmony_ciinstall_pkgconfig: $(PC_FILE)
2628c2ecf20Sopenharmony_ci	$(call QUIET_INSTALL, $(PC_FILE)) \
2638c2ecf20Sopenharmony_ci		$(call do_install,$(PC_FILE),$(libdir_SQ)/pkgconfig,644)
2648c2ecf20Sopenharmony_ci
2658c2ecf20Sopenharmony_ciinstall: install_lib install_pkgconfig install_headers
2668c2ecf20Sopenharmony_ci
2678c2ecf20Sopenharmony_ci### Cleaning rules
2688c2ecf20Sopenharmony_ci
2698c2ecf20Sopenharmony_ciconfig-clean:
2708c2ecf20Sopenharmony_ci	$(call QUIET_CLEAN, feature-detect)
2718c2ecf20Sopenharmony_ci	$(Q)$(MAKE) -C $(srctree)/tools/build/feature/ clean >/dev/null
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ciclean: config-clean
2748c2ecf20Sopenharmony_ci	$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS)		     \
2758c2ecf20Sopenharmony_ci		*~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_HELPER_DEFS)		     \
2768c2ecf20Sopenharmony_ci		$(SHARED_OBJDIR) $(STATIC_OBJDIR)			     \
2778c2ecf20Sopenharmony_ci		$(addprefix $(OUTPUT),					     \
2788c2ecf20Sopenharmony_ci			    *.o *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) *.pc)
2798c2ecf20Sopenharmony_ci	$(call QUIET_CLEAN, core-gen) $(RM) $(OUTPUT)FEATURE-DUMP.libbpf
2808c2ecf20Sopenharmony_ci
2818c2ecf20Sopenharmony_ci
2828c2ecf20Sopenharmony_ci
2838c2ecf20Sopenharmony_ciPHONY += force elfdep zdep bpfdep cscope tags
2848c2ecf20Sopenharmony_ciforce:
2858c2ecf20Sopenharmony_ci
2868c2ecf20Sopenharmony_cielfdep:
2878c2ecf20Sopenharmony_ci	@if [ "$(feature-libelf)" != "1" ]; then echo "No libelf found"; exit 1 ; fi
2888c2ecf20Sopenharmony_ci
2898c2ecf20Sopenharmony_cizdep:
2908c2ecf20Sopenharmony_ci	@if [ "$(feature-zlib)" != "1" ]; then echo "No zlib found"; exit 1 ; fi
2918c2ecf20Sopenharmony_ci
2928c2ecf20Sopenharmony_cibpfdep:
2938c2ecf20Sopenharmony_ci	@if [ "$(feature-bpf)" != "1" ]; then echo "BPF API too old"; exit 1 ; fi
2948c2ecf20Sopenharmony_ci
2958c2ecf20Sopenharmony_cicscope:
2968c2ecf20Sopenharmony_ci	ls *.c *.h > cscope.files
2978c2ecf20Sopenharmony_ci	cscope -b -q -I $(srctree)/include -f cscope.out
2988c2ecf20Sopenharmony_ci
2998c2ecf20Sopenharmony_citags:
3008c2ecf20Sopenharmony_ci	$(RM) -f TAGS tags
3018c2ecf20Sopenharmony_ci	ls *.c *.h | xargs $(TAGS_PROG) -a
3028c2ecf20Sopenharmony_ci
3038c2ecf20Sopenharmony_ci# Declare the contents of the .PHONY variable as phony.  We keep that
3048c2ecf20Sopenharmony_ci# information in a variable so we can use it in if_changed and friends.
3058c2ecf20Sopenharmony_ci.PHONY: $(PHONY)
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ci# Delete partially updated (corrupted) files on error
3088c2ecf20Sopenharmony_ci.DELETE_ON_ERROR:
309