MAJOR=4
MINOR=17
DEVNAME=tty17
      ˆl–ß=¿J	•2ÛB‚ œP@¸Ènå1hßÅ0ÀÇ  #   !ˆl–Ü4ý( ©³( 	Å€fàB¦-ÿÆ„Bà?ÁÈ +˜    !# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
# Most of this file is copied from tools/lib/traceevent/Makefile

RM ?= rm
srctree = $(abs_srctree)

VERSION_SCRIPT := libbpf.map
LIBBPF_VERSION := $(shell \
	grep -oE '^LIBBPF_([0-9.]+)' $(VERSION_SCRIPT) | \
	sort -rV | head -n1 | cut -d'_' -f2)
LIBBPF_MAJOR_VERSION := $(word 1,$(subst ., ,$(LIBBPF_VERSION)))
LIBBPF_MINOR_VERSION := $(word 2,$(subst ., ,$(LIBBPF_VERSION)))

MAKEFLAGS += --no-print-directory

# This will work when bpf is built in tools env. where srctree
# isn't set and when invoked from selftests build, where srctree
# is a ".". building_out_of_srctree is undefined for in srctree
# builds
ifndef building_out_of_srctree
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
#$(info Determined 'srctree' to be $(srctree))
endif

INSTALL = install

# Use DESTDIR for installing into a different root directory.
# This is useful for building a package. The program will be
# installed in this directory as if it was the root directory.
# Then the build tool can move it later.
DESTDIR ?=
DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'

include $(srctree)/tools/scripts/Makefile.arch

ifeq ($(LP64), 1)
  libdir_relative = lib64
else
  libdir_relative = lib
endif

prefix ?= /usr/local
libdir = $(prefix)/$(libdir_relative)
man_dir = $(prefix)/share/man
man_dir_SQ = '$(subst ','\'',$(man_dir))'

export man_dir man_dir_SQ INSTALL
export DESTDIR DESTDIR_SQ

include $(srctree)/tools/scripts/Makefile.include

# copy a bit from Linux kbuild

ifeq ("$(origin V)", "command line")
  VERBOSE = $(V)
endif
ifndef VERBOSE
  VERBOSE = 0
endif

INCLUDES = -I$(or $(OUTPUT),.) \
	   -I$(srctree)/tools/include -I$(srctree)/tools/include/uapi

export prefix libdir src obj

# Shell quotes
libdir_SQ = $(subst ','\'',$(libdir))
libdir_relative_SQ = $(subst ','\'',$(libdir_relative))

OBJ		= $@
N		=

LIB_TARGET	= libbpf.a libbpf.so.$(LIBBPF_VERSION)
LIB_FILE	= libbpf.a libbpf.so*
PC_FILE		= libbpf.pc

# Set compile option CFLAGS
ifdef EXTRA_CFLAGS
  CFLAGS := $(EXTRA_CFLAGS)
else
  CFLAGS := -g -O2
endif

# Append required CFLAGS
override CFLAGS += -std=gnu89
override CFLAGS += $(EXTRA_WARNINGS) -Wno-switch-enum
override CFLAGS += -Werror -Wall
override CFLAGS += $(INCLUDES)
override CFLAGS += -fvisibility=hidden
override CFLAGS += -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
override CFLAGS += $(CLANG_CROSS_FLAGS)

# flags specific for shared library
SHLIB_FLAGS := -DSHARED -fPIC

ifeq ($(VERBOSE),1)
  Q =
else
  Q = @
endif

# Disable command line variables (CFLAGS) override from top
# level Makefile (perf), otherwise build Makefile will get
# the same command line setup.
MAKEOVERRIDES=

all:

OUTPUT ?= ./
OUTPUT := $(abspath $(OUTPUT))/
export srctree OUTPUT CC LD CFLAGS V
include $(srctree)/tools/build/Makefile.include

SHARED_OBJDIR	:= $(OUTPUT)sharedobjs/
STATIC_OBJDIR	:= $(OUTPUT)staticobjs/
BPF_IN_SHARED	:= $(SHARED_OBJDIR)libbpf-in.o
BPF_IN_STATIC	:= $(STATIC_OBJDIR)libbpf-in.o
BPF_HELPER_DEFS	:= $(OUTPUT)bpf_helper_defs.h
BPF_GENERATED	:= $(BPF_HELPER_DEFS)

LIB_TARGET	:= $(addprefix $(OUTPUT),$(LIB_TARGET))
LIB_FILE	:= $(addprefix $(OUTPUT),$(LIB_FILE))
PC_FILE		:= $(addprefix $(OUTPUT),$(PC_FILE))

TAGS_PROG := $(if $(shell which etags 2>/dev/null),etags,ctags)

GLOBAL_SYM_COUNT = $(shell readelf -s --wide $(BPF_IN_SHARED) | \
			   cut -d "@" -f1 | sed 's/_v[0-9]_[0-9]_[0-9].*//' | \
			   sed 's/\[.*\]//' | \
			   awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
			   sort -u | wc -l)
VERSIONED_SYM_COUNT = $(shell readelf --dyn-syms --wide $(OUTPUT)libbpf.so | \
			      sed 's/\[.*\]//' | \
			      awk '/GLOBAL/ && /DEFAULT/ && !/UND|ABS/ {print $$NF}' | \
			      grep -Eo '[^ ]+@LIBBPF_' | cut -d@ -f1 | sort -u | wc -l)

CMD_TARGETS = $(LIB_TARGET) $(PC_FILE)

all: fixdep
	$(Q)$(MAKE) all_cmd

all_cmd: $(CMD_TARGETS) check

$(SHARED_OBJDIR) $(STATIC_OBJDIR):
	