162306a36Sopenharmony_ci# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
262306a36Sopenharmony_ci# Most of this file is copied from tools/lib/traceevent/Makefile
362306a36Sopenharmony_ci
462306a36Sopenharmony_ciRM ?= rm
562306a36Sopenharmony_cisrctree = $(abs_srctree)
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciVERSION_SCRIPT := libbpf.map
862306a36Sopenharmony_ciLIBBPF_VERSION := $(shell \
962306a36Sopenharmony_ci	grep -oE '^LIBBPF_([0-9.]+)' $(VERSION_SCRIPT) | \
1062306a36Sopenharmony_ci	sort -rV | head -n1 | cut -d'_' -f2)
1162306a36Sopenharmony_ciLIBBPF_MAJOR_VERSION := $(word 1,$(subst ., ,$(LIBBPF_VERSION)))
1262306a36Sopenharmony_ciLIBBPF_MINOR_VERSION := $(word 2,$(subst ., ,$(LIBBPF_VERSION)))
1362306a36Sopenharmony_ci
1462306a36Sopenharmony_ciMAKEFLAGS += --no-print-directory
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci# This will work when bpf is built in tools env. where srctree
1762306a36Sopenharmony_ci# isn't set and when invoked from selftests build, where srctree
1862306a36Sopenharmony_ci# is a ".". building_out_of_srctree is undefined for in srctree
1962306a36Sopenharmony_ci# builds
2062306a36Sopenharmony_ciifndef building_out_of_srctree
2162306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(CURDIR)))
2262306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
2362306a36Sopenharmony_cisrctree := $(patsubst %/,%,$(dir $(srctree)))
2462306a36Sopenharmony_ci#$(info Determined 'srctree' to be $(srctree))
2562306a36Sopenharmony_ciendif
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ciINSTALL = install
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ci# Use DESTDIR for installing into a different root directory.
3062306a36Sopenharmony_ci# This is useful for building a package. The program will be
3162306a36Sopenharmony_ci# installed in this directory as if it was the root directory.
3262306a36Sopenharmony_ci# Then the build tool can move it later.
3362306a36Sopenharmony_ciDESTDIR ?=
3462306a36Sopenharmony_ciDESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
3562306a36Sopenharmony_ci
3662306a36Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.arch
3762306a36Sopenharmony_ci
3862306a36Sopenharmony_ciifeq ($(LP64), 1)
3962306a36Sopenharmony_ci  libdir_relative = lib64
4062306a36Sopenharmony_cielse
4162306a36Sopenharmony_ci  libdir_relative = lib
4262306a36Sopenharmony_ciendif
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ciprefix ?= /usr/local
4562306a36Sopenharmony_cilibdir = $(prefix)/$(libdir_relative)
4662306a36Sopenharmony_ciman_dir = $(prefix)/share/man
4762306a36Sopenharmony_ciman_dir_SQ = '$(subst ','\'',$(man_dir))'
4862306a36Sopenharmony_ci
4962306a36Sopenharmony_ciexport man_dir man_dir_SQ INSTALL
5062306a36Sopenharmony_ciexport DESTDIR DESTDIR_SQ
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ciinclude $(srctree)/tools/scripts/Makefile.include
5362306a36Sopenharmony_ci
5462306a36Sopenharmony_ci# copy a bit from Linux kbuild
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciifeq ("$(origin V)", "command line")
5762306a36Sopenharmony_ci  VERBOSE = $(V)
5862306a36Sopenharmony_ciendif
5962306a36Sopenharmony_ciifndef VERBOSE
6062306a36Sopenharmony_ci  VERBOSE = 0
6162306a36Sopenharmony_ciendif
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ciINCLUDES = -I$(or $(OUTPUT),.) \
6462306a36Sopenharmony_ci	   -I$(srctree)/tools/include -I$(srctree)/tools/include/uapi
6562306a36Sopenharmony_ci
6662306a36Sopenharmony_ciexport prefix libdir src obj
6762306a36Sopenharmony_ci
6862306a36Sopenharmony_ci# Shell quotes
6962306a36Sopenharmony_cilibdir_SQ = $(subst ','\'',$(libdir))
7062306a36Sopenharmony_cilibdir_relative_SQ = $(subst ','\'',$(libdir_relative))
7162306a36Sopenharmony_ci
7262306a36Sopenharmony_ciOBJ		= $@
7362306a36Sopenharmony_ciN		=
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciLIB_TARGET	= libbpf.a libbpf.so.$(LIBBPF_VERSION)
7662306a36Sopenharmony_ciLIB_FILE	= libbpf.a libbpf.so*
7762306a36Sopenharmony_ciPC_FILE		= libbpf.pc
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci# Set compile option CFLAGS
8062306a36Sopenharmony_ciifdef EXTRA_CFLAGS
8162306a36Sopenharmony_ci  CFLAGS := $(EXTRA_CFLAGS)
8262306a36Sopenharmony_cielse
8362306a36Sopenharmony_ci  CFLAGS := -g -O2
8462306a36Sopenharmony_ciendif
8562306a36Sopenharmony_ci
8662306a36Sopenharmony_ci# Append required CFLAGS
8762306a36Sopenharmony_cioverride CFLAGS += -std=gnu89
8862306a36Sopenharmony_cioverride CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
8962306a36Sopenharmony_cioverride CFLAGS += -Werror -Wall
9062306a36Sopenharmony_cioverride CFLAGS += $(INCLUDES)
9162306a36Sopenharmony_cioverride CFLAGS += -fvisibility=hidden
9262306a36Sopenharmony_cioverride CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
9362306a36Sopenharmony_cioverride CFLAGS += $(CLANG_CROSS_FLAGS)
9462306a36Sopenharmony_ci
9562306a36Sopenharmony_ci# flags specific for shared library
9662306a36Sopenharmony_ciSHLIB_FLAGS := -DSHARED -fPIC
9762306a36Sopenharmony_ci
9862306a36Sopenharmony_ciifeq ($(VERBOSE),1)
9962306a36Sopenharmony_ci  Q =
10062306a36Sopenharmony_cielse
10162306a36Sopenharmony_ci  Q = @
10262306a36Sopenharmony_ciendif
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci# Disable command line variables (CFLAGS) override from top
10562306a36Sopenharmony_ci# level Makefile (perf), otherwise build Makefile will get
10662306a36Sopenharmony_ci# the same command line setup.
10762306a36Sopenharmony_ciMAKEOVERRIDES=
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciall:
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ciexport srctree OUTPUT CC LD CFLAGS V
11262306a36Sopenharmony_ciinclude $(srctree)/tools/build/Makefile.include
11362306a36Sopenharmony_ci
11462306a36Sopenharmony_ciSHARED_OBJDIR	:= $(OUTPUT)sharedobjs/
11562306a36Sopenharmony_ciSTATIC_OBJDIR	:= $(OUTPUT)staticobjs/
11662306a36Sopenharmony_ciBPF_IN_SHARED	:= $(SHARED_OBJDIR)libbpf-in.o
11762306a36Sopenharmony_ciBPF_IN_STATIC	:= $(STATIC_OBJDIR)libbpf-in.o
11862306a36Sopenharmony_ciBPF_HELPER_DEFS	:= $(OUTPUT)bpf_helper_defs.h
11962306a36Sopenharmony_ciBPF_GENERATED	:= $(BPF_HELPER_DEFS)
12062306a36Sopenharmony_ci
12162306a36Sopenharmony_ciLIB_TARGET	:= $(addprefix $(OUTPUT),$(LIB_TARGET))
12262306a36Sopenharmony_ciLIB_FILE	:= $(addprefix $(OUTPUT),$(LIB_FILE))
12362306a36Sopenharmony_ciPC_FILE		:= $(addprefix $(OUTPUT),$(PC_FILE))
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ciTAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags)
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciGLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
12862306a36Sopenharmony_ci			   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
12962306a36Sopenharmony_ci			   sed 's/\[.*\]//' | \
13062306a36Sopenharmony_ci			   awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
13162306a36Sopenharmony_ci			   sort -u | wc -l)
13262306a36Sopenharmony_ciVERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
13362306a36Sopenharmony_ci			      sed 's/\[.*\]//' | \
13462306a36Sopenharmony_ci			      awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
13562306a36Sopenharmony_ci			      grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l)
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ciCMD_TARGETS = $(LIB_TARGET) $(PC_FILE)
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ciall: fixdep
14062306a36Sopenharmony_ci	$(Q)$(MAKE) all_cmd
14162306a36Sopenharmony_ci
14262306a36Sopenharmony_ciall_cmd: $(CMD_TARGETS) check
14362306a36Sopenharmony_ci
14462306a36Sopenharmony_ci$(BPF_IN_SHARED): force $(BPF_GENERATED)
14562306a36Sopenharmony_ci	@(test -f ../../include/uapi/linux/bpf.h -a -f ../../../include/uapi/linux/bpf.h && ( \
14662306a36Sopenharmony_ci	(diff -B ../../include/uapi/linux/bpf.h ../../../include/uapi/linux/bpf.h >/dev/null) || \
14762306a36Sopenharmony_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
14862306a36Sopenharmony_ci	@(test -f ../../include/uapi/linux/bpf_common.h -a -f ../../../include/uapi/linux/bpf_common.h && ( \
14962306a36Sopenharmony_ci	(diff -B ../../include/uapi/linux/bpf_common.h ../../../include/uapi/linux/bpf_common.h >/dev/null) || \
15062306a36Sopenharmony_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
15162306a36Sopenharmony_ci	@(test -f ../../include/uapi/linux/if_xdp.h -a -f ../../../include/uapi/linux/if_xdp.h && ( \
15262306a36Sopenharmony_ci	(diff -B ../../include/uapi/linux/if_xdp.h ../../../include/uapi/linux/if_xdp.h >/dev/null) || \
15362306a36Sopenharmony_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
15462306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(SHARED_OBJDIR) CFLAGS="$(CFLAGS) $(SHLIB_FLAGS)"
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci$(BPF_IN_STATIC): force $(BPF_GENERATED)
15762306a36Sopenharmony_ci	$(Q)$(MAKE) $(build)=libbpf OUTPUT=$(STATIC_OBJDIR)
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ci$(BPF_HELPER_DEFS): $(srctree)/tools/include/uapi/linux/bpf.h
16062306a36Sopenharmony_ci	$(QUIET_GEN)$(srctree)/scripts/bpf_doc.py --header \
16162306a36Sopenharmony_ci		--file $(srctree)/tools/include/uapi/linux/bpf.h > $(BPF_HELPER_DEFS)
16262306a36Sopenharmony_ci
16362306a36Sopenharmony_ci$(OUTPUT)libbpf.so: $(OUTPUT)libbpf.so.$(LIBBPF_VERSION)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci$(OUTPUT)libbpf.so.$(LIBBPF_VERSION): $(BPF_IN_SHARED) $(VERSION_SCRIPT)
16662306a36Sopenharmony_ci	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) \
16762306a36Sopenharmony_ci		--shared -Wl,-soname,libbpf.so.$(LIBBPF_MAJOR_VERSION) \
16862306a36Sopenharmony_ci		-Wl,--version-script=$(VERSION_SCRIPT) $< -lelf -lz -o $@
16962306a36Sopenharmony_ci	@ln -sf $(@F) $(OUTPUT)libbpf.so
17062306a36Sopenharmony_ci	@ln -sf $(@F) $(OUTPUT)libbpf.so.$(LIBBPF_MAJOR_VERSION)
17162306a36Sopenharmony_ci
17262306a36Sopenharmony_ci$(OUTPUT)libbpf.a: $(BPF_IN_STATIC)
17362306a36Sopenharmony_ci	$(QUIET_LINK)$(RM) -f $@; $(AR) rcs $@ $^
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci$(OUTPUT)libbpf.pc:
17662306a36Sopenharmony_ci	$(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \
17762306a36Sopenharmony_ci		-e "s|@LIBDIR@|$(libdir_SQ)|" \
17862306a36Sopenharmony_ci		-e "s|@VERSION@|$(LIBBPF_VERSION)|" \
17962306a36Sopenharmony_ci		< libbpf.pc.template > $@
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_cicheck: check_abi check_version
18262306a36Sopenharmony_ci
18362306a36Sopenharmony_cicheck_abi: $(OUTPUT)libbpf.so $(VERSION_SCRIPT)
18462306a36Sopenharmony_ci	@if [ "$(GLOBAL_SYM_COUNT)" != "$(VERSIONED_SYM_COUNT)" ]; then	 \
18562306a36Sopenharmony_ci		echo "Warning: Num of global symbols in $(BPF_IN_SHARED)"	 \
18662306a36Sopenharmony_ci		     "($(GLOBAL_SYM_COUNT)) does NOT match with num of"	 \
18762306a36Sopenharmony_ci		     "versioned symbols in $^ ($(VERSIONED_SYM_COUNT))." \
18862306a36Sopenharmony_ci		     "Please make sure all LIBBPF_API symbols are"	 \
18962306a36Sopenharmony_ci		     "versioned in $(VERSION_SCRIPT)." >&2;		 \
19062306a36Sopenharmony_ci		readelf -s --wide $(BPF_IN_SHARED) |			 \
19162306a36Sopenharmony_ci		    cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' |	 \
19262306a36Sopenharmony_ci		    sed 's/\[.*\]//' |					 \
19362306a36Sopenharmony_ci		    awk '/GLOBAL/ && /DEFAULT/ && !/UND/ {print $$NF}'|  \
19462306a36Sopenharmony_ci		    sort -u > $(OUTPUT)libbpf_global_syms.tmp;		 \
19562306a36Sopenharmony_ci		readelf --dyn-syms --wide $(OUTPUT)libbpf.so |		 \
19662306a36Sopenharmony_ci		    sed 's/\[.*\]//' |					 \
19762306a36Sopenharmony_ci		    awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}'|  \
19862306a36Sopenharmony_ci		    grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 |		 \
19962306a36Sopenharmony_ci		    sort -u > $(OUTPUT)libbpf_versioned_syms.tmp; 	 \
20062306a36Sopenharmony_ci		diff -u $(OUTPUT)libbpf_global_syms.tmp			 \
20162306a36Sopenharmony_ci		     $(OUTPUT)libbpf_versioned_syms.tmp;		 \
20262306a36Sopenharmony_ci		rm $(OUTPUT)libbpf_global_syms.tmp			 \
20362306a36Sopenharmony_ci		   $(OUTPUT)libbpf_versioned_syms.tmp;			 \
20462306a36Sopenharmony_ci		exit 1;							 \
20562306a36Sopenharmony_ci	fi
20662306a36Sopenharmony_ci
20762306a36Sopenharmony_ciHDR_MAJ_VERSION := $(shell grep -oE '^$(pound)define LIBBPF_MAJOR_VERSION ([0-9]+)$$' libbpf_version.h | cut -d' ' -f3)
20862306a36Sopenharmony_ciHDR_MIN_VERSION := $(shell grep -oE '^$(pound)define LIBBPF_MINOR_VERSION ([0-9]+)$$' libbpf_version.h | cut -d' ' -f3)
20962306a36Sopenharmony_ci
21062306a36Sopenharmony_cicheck_version: $(VERSION_SCRIPT) libbpf_version.h
21162306a36Sopenharmony_ci	@if [ "$(HDR_MAJ_VERSION)" != "$(LIBBPF_MAJOR_VERSION)" ]; then        \
21262306a36Sopenharmony_ci		echo "Error: libbpf major version mismatch detected: "	       \
21362306a36Sopenharmony_ci		     "'$(HDR_MAJ_VERSION)' != '$(LIBBPF_MAJOR_VERSION)'" >&2;  \
21462306a36Sopenharmony_ci		exit 1;							       \
21562306a36Sopenharmony_ci	fi
21662306a36Sopenharmony_ci	@if [ "$(HDR_MIN_VERSION)" != "$(LIBBPF_MINOR_VERSION)" ]; then	       \
21762306a36Sopenharmony_ci		echo "Error: libbpf minor version mismatch detected: "	       \
21862306a36Sopenharmony_ci		     "'$(HDR_MIN_VERSION)' != '$(LIBBPF_MINOR_VERSION)'" >&2;  \
21962306a36Sopenharmony_ci		exit 1;							       \
22062306a36Sopenharmony_ci	fi
22162306a36Sopenharmony_ci
22262306a36Sopenharmony_cidefine do_install_mkdir
22362306a36Sopenharmony_ci	if [ ! -d '$(DESTDIR_SQ)$1' ]; then		\
22462306a36Sopenharmony_ci		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1';	\
22562306a36Sopenharmony_ci	fi
22662306a36Sopenharmony_ciendef
22762306a36Sopenharmony_ci
22862306a36Sopenharmony_cidefine do_install
22962306a36Sopenharmony_ci	if [ ! -d '$(DESTDIR_SQ)$2' ]; then		\
23062306a36Sopenharmony_ci		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2';	\
23162306a36Sopenharmony_ci	fi;						\
23262306a36Sopenharmony_ci	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
23362306a36Sopenharmony_ciendef
23462306a36Sopenharmony_ci
23562306a36Sopenharmony_ciinstall_lib: all_cmd
23662306a36Sopenharmony_ci	$(call QUIET_INSTALL, $(LIB_TARGET)) \
23762306a36Sopenharmony_ci		$(call do_install_mkdir,$(libdir_SQ)); \
23862306a36Sopenharmony_ci		cp -fpR $(LIB_FILE) $(DESTDIR)$(libdir_SQ)
23962306a36Sopenharmony_ci
24062306a36Sopenharmony_ciSRC_HDRS := bpf.h libbpf.h btf.h libbpf_common.h libbpf_legacy.h	     \
24162306a36Sopenharmony_ci	    bpf_helpers.h bpf_tracing.h bpf_endian.h bpf_core_read.h	     \
24262306a36Sopenharmony_ci	    skel_internal.h libbpf_version.h usdt.bpf.h
24362306a36Sopenharmony_ciGEN_HDRS := $(BPF_GENERATED)
24462306a36Sopenharmony_ci
24562306a36Sopenharmony_ciINSTALL_PFX := $(DESTDIR)$(prefix)/include/bpf
24662306a36Sopenharmony_ciINSTALL_SRC_HDRS := $(addprefix $(INSTALL_PFX)/, $(SRC_HDRS))
24762306a36Sopenharmony_ciINSTALL_GEN_HDRS := $(addprefix $(INSTALL_PFX)/, $(notdir $(GEN_HDRS)))
24862306a36Sopenharmony_ci
24962306a36Sopenharmony_ci$(INSTALL_SRC_HDRS): $(INSTALL_PFX)/%.h: %.h
25062306a36Sopenharmony_ci	$(call QUIET_INSTALL, $@) \
25162306a36Sopenharmony_ci		$(call do_install,$<,$(prefix)/include/bpf,644)
25262306a36Sopenharmony_ci
25362306a36Sopenharmony_ci$(INSTALL_GEN_HDRS): $(INSTALL_PFX)/%.h: $(OUTPUT)%.h
25462306a36Sopenharmony_ci	$(call QUIET_INSTALL, $@) \
25562306a36Sopenharmony_ci		$(call do_install,$<,$(prefix)/include/bpf,644)
25662306a36Sopenharmony_ci
25762306a36Sopenharmony_ciinstall_headers: $(BPF_GENERATED) $(INSTALL_SRC_HDRS) $(INSTALL_GEN_HDRS)
25862306a36Sopenharmony_ci	$(call QUIET_INSTALL, libbpf_headers)
25962306a36Sopenharmony_ci
26062306a36Sopenharmony_ciinstall_pkgconfig: $(PC_FILE)
26162306a36Sopenharmony_ci	$(call QUIET_INSTALL, $(PC_FILE)) \
26262306a36Sopenharmony_ci		$(call do_install,$(PC_FILE),$(libdir_SQ)/pkgconfig,644)
26362306a36Sopenharmony_ci
26462306a36Sopenharmony_ciinstall: install_lib install_pkgconfig install_headers
26562306a36Sopenharmony_ci
26662306a36Sopenharmony_ciclean:
26762306a36Sopenharmony_ci	$(call QUIET_CLEAN, libbpf) $(RM) -rf $(CMD_TARGETS)		     \
26862306a36Sopenharmony_ci		*~ .*.d .*.cmd LIBBPF-CFLAGS $(BPF_GENERATED)		     \
26962306a36Sopenharmony_ci		$(SHARED_OBJDIR) $(STATIC_OBJDIR)			     \
27062306a36Sopenharmony_ci		$(addprefix $(OUTPUT),					     \
27162306a36Sopenharmony_ci			    *.o *.a *.so *.so.$(LIBBPF_MAJOR_VERSION) *.pc)
27262306a36Sopenharmony_ci
27362306a36Sopenharmony_ciPHONY += force cscope tags check check_abi check_version
27462306a36Sopenharmony_ciforce:
27562306a36Sopenharmony_ci
27662306a36Sopenharmony_cicscope:
27762306a36Sopenharmony_ci	ls *.c *.h > cscope.files
27862306a36Sopenharmony_ci	cscope -b -q -I $(srctree)/include -f cscope.out
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_citags:
28162306a36Sopenharmony_ci	$(RM) -f TAGS tags
28262306a36Sopenharmony_ci	ls *.c *.h | xargs $(TAGS_PROG) -a
28362306a36Sopenharmony_ci
28462306a36Sopenharmony_ci# Declare the contents of the .PHONY variable as phony.  We keep that
28562306a36Sopenharmony_ci# information in a variable so we can use it in if_changed and friends.
28662306a36Sopenharmony_ci.PHONY: $(PHONY)
28762306a36Sopenharmony_ci
28862306a36Sopenharmony_ci# Delete partially updated (corrupted) files on error
28962306a36Sopenharmony_ci.DELETE_ON_ERROR:
29062306a36Sopenharmony_ci
29162306a36Sopenharmony_cihelp:
29262306a36Sopenharmony_ci	@echo 'libbpf common targets:'
29362306a36Sopenharmony_ci	@echo '  HINT: use "V=1" to enable verbose build'
29462306a36Sopenharmony_ci	@echo '  all     - build libraries and pkgconfig'
29562306a36Sopenharmony_ci	@echo '  clean   - remove all generated files'
29662306a36Sopenharmony_ci	@echo '  check   - check ABI and version info'
29762306a36Sopenharmony_ci	@echo ''
29862306a36Sopenharmony_ci	@echo 'libbpf install targets:'
29962306a36Sopenharmony_ci	@echo '  HINT: use "prefix"(defaults to "/usr/local") or "DESTDIR" (defaults to "/")'
30062306a36Sopenharmony_ci	@echo '        to adjust target destination, e.g. "make prefix=/usr/local install"'
30162306a36Sopenharmony_ci	@echo '  install          - build and install all headers, libraries and pkgconfig'
30262306a36Sopenharmony_ci	@echo '  install_headers  - install only headers to include/bpf'
30362306a36Sopenharmony_ci	@echo ''
30462306a36Sopenharmony_ci	@echo 'libbpf make targets:'
30562306a36Sopenharmony_ci	@echo '  tags    - use ctags to make tag information for source code browsing'
30662306a36Sopenharmony_ci	@echo '  cscope  - use cscope to make interactive source code browsing database'
307