2019-07-21 13:24:10 +02:00
# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
# Most of this file is copied from tools/lib/bpf/Makefile
2019-07-21 13:24:11 +02:00
LIBPERF_VERSION = 0
LIBPERF_PATCHLEVEL = 0
LIBPERF_EXTRAVERSION = 1
2019-07-21 13:24:10 +02:00
MAKEFLAGS += --no-print-directory
i f e q ( $( srctree ) , )
srctree := $( patsubst %/,%,$( dir $( CURDIR) ) )
srctree := $( patsubst %/,%,$( dir $( srctree) ) )
srctree := $( patsubst %/,%,$( dir $( srctree) ) )
#$(info Determined 'srctree' to be $(srctree))
e n d i f
i n c l u d e $( srctree ) / t o o l s / s c r i p t s / M a k e f i l e . i n c l u d e
i n c l u d e $( srctree ) / t o o l s / s c r i p t s / M a k e f i l e . a r c h
i f e q ( "$(origin V)" , "command line" )
VERBOSE = $( V)
e n d i f
i f n d e f V E R B O S E
VERBOSE = 0
e n d i f
i f e q ( $( VERBOSE ) , 1 )
Q =
e l s e
Q = @
e n d i f
# Set compile option CFLAGS
i f d e f E X T R A _ C F L A G S
CFLAGS := $( EXTRA_CFLAGS)
e l s e
CFLAGS := -g -Wall
e n d i f
INCLUDES = -I$( srctree) /tools/perf/lib/include -I$( srctree) /tools/include -I$( srctree) /tools/arch/$( ARCH) /include/ -I$( srctree) /tools/arch/$( ARCH) /include/uapi -I$( srctree) /tools/include/uapi
# Append required CFLAGS
o v e r r i d e CFLAGS += $( EXTRA_WARNINGS)
o v e r r i d e CFLAGS += -Werror -Wall
o v e r r i d e CFLAGS += -fPIC
o v e r r i d e CFLAGS += $( INCLUDES)
o v e r r i d e CFLAGS += -fvisibility= hidden
all :
export srctree OUTPUT CC LD CFLAGS V
i n c l u d e $( srctree ) / t o o l s / b u i l d / M a k e f i l e . i n c l u d e
2019-07-21 13:24:11 +02:00
VERSION_SCRIPT := libperf.map
PATCHLEVEL = $( LIBPERF_PATCHLEVEL)
EXTRAVERSION = $( LIBPERF_EXTRAVERSION)
VERSION = $( LIBPERF_VERSION) .$( LIBPERF_PATCHLEVEL) .$( LIBPERF_EXTRAVERSION)
LIBPERF_SO := $( OUTPUT) libperf.so.$( VERSION)
2019-07-21 13:24:10 +02:00
LIBPERF_A := $( OUTPUT) libperf.a
LIBPERF_IN := $( OUTPUT) libperf-in.o
$(LIBPERF_IN) : FORCE
$( Q) $( MAKE) $( build) = libperf
$(LIBPERF_A) : $( LIBPERF_IN )
$( QUIET_AR) $( RM) $@ && $( AR) rcs $@ $( LIBPERF_IN)
$(LIBPERF_SO) : $( LIBPERF_IN )
2019-07-21 13:24:11 +02:00
$( QUIET_LINK) $( CC) --shared -Wl,-soname,libperf.so \
-Wl,--version-script= $( VERSION_SCRIPT) $^ -o $@
@ln -sf $( @F) $( OUTPUT) libperf.so
@ln -sf $( @F) $( OUTPUT) libperf.so.$( LIBPERF_VERSION)
2019-07-21 13:24:10 +02:00
libs : $( LIBPERF_A ) $( LIBPERF_SO )
all : fixdep
$( Q) $( MAKE) libs
clean :
$( call QUIET_CLEAN, libperf) $( RM) $( LIBPERF_A) \
2019-07-21 13:24:11 +02:00
*.o *~ *.a *.so *.so.$( VERSION) *.so.$( LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS
2019-07-21 13:24:10 +02:00
FORCE :
.PHONY : all install clean FORCE