Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5880160ybi; Sun, 21 Jul 2019 04:33:54 -0700 (PDT) X-Google-Smtp-Source: APXvYqyr7LwC4n9ufat4xAocdNzwxdhLuJcbgIPZI8kvx1d22SLAeG+Ttu72Y3u3b/YYDkfcXLaQ X-Received: by 2002:a17:902:f01:: with SMTP id 1mr69010225ply.170.1563708834540; Sun, 21 Jul 2019 04:33:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563708834; cv=none; d=google.com; s=arc-20160816; b=yr4cRf80rZSui44H6iIdUeWTinNtUjRSjA/RKcmnbU0CZ0CtEmJ6DdKDaGwedMYnu5 7shc80pagNN9KxeRXMSOi+Pf6KSCcc8cG2yy1QywLYAEukRsx+HR9BMHQqWRVZsDJm4G 3w1bm9qKxQ6KJPTAwk0rM+QpFmyk5lpLuP7Z7kJj4bx1SzEeORThrO4vT/q6/Odtdlqt ZD7gId+LaupLZTi2C11OWu8mpqRrOCVPVEwZkUDdD2tnCzYCOsoPZvfj9fSJIQk0Qjzb r2BSROcp5IjxJJNezB6Cox0wvhYl2FNDnit4kdR/7ar8A8gNzKf9qwjaZuRT1YLNSuAJ 1GXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=PQpSJ9Ks6LKAao+qxxcqVK3STaFTK8kCwkqbrpux7BY=; b=Fm2ByQH/OroIUnzU7GB/f6S1OughRSgnK2DiuR8ctdpnzYK6cKqh0jUSnKohtuKdCc OoY0Y+4Fk2yrQnuFThxRKua8HVNZv4moNPst2GIJIfh+t08SpRNbaqQGsUQm03EIPo6M kF4tb6c/FjKG/GasO1lxHsSV2HPmRwUtwZ5qN/kuLR6+HreI8AysXohz2pO02S8EJmoP ii9Ysn50tQpiOEfWSoRe3n9MAqMDx+tTsrP7N5I+O3FY7icW8pmV1cWRg0sMxtczU32S UYqzthMd5dFoc3bckX2bSHOniqayxRuiw+QO+KN+o4HIeae0yBzfrEhAY1dbvVa+PaSE 1tmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s29si7361548pfd.147.2019.07.21.04.33.38; Sun, 21 Jul 2019 04:33:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727233AbfGULch (ORCPT + 99 others); Sun, 21 Jul 2019 07:32:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:39970 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726390AbfGULch (ORCPT ); Sun, 21 Jul 2019 07:32:37 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 447913082DDD; Sun, 21 Jul 2019 11:32:36 +0000 (UTC) Received: from krava.redhat.com (ovpn-204-23.brq.redhat.com [10.40.204.23]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6C2825D9D3; Sun, 21 Jul 2019 11:32:32 +0000 (UTC) From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Andi Kleen , Alexey Budankov , Michael Petlan Subject: [PATCH 71/79] libperf: Add install targets Date: Sun, 21 Jul 2019 13:24:58 +0200 Message-Id: <20190721112506.12306-72-jolsa@kernel.org> In-Reply-To: <20190721112506.12306-1-jolsa@kernel.org> References: <20190721112506.12306-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sun, 21 Jul 2019 11:32:36 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add install targets (mostly copied from lib/bpf), it's now possible to install libperf with: $ make DESTDIR=/tmp/krava install INSTALL libperf.a INSTALL libperf.so INSTALL libperf.so.0 INSTALL libperf.so.0.0.1 INSTALL headers INSTALL libperf.pc $ find /tmp/krava/ /tmp/krava/ /tmp/krava/include /tmp/krava/include/perf /tmp/krava/include/perf/evsel.h /tmp/krava/include/perf/evlist.h /tmp/krava/include/perf/threadmap.h /tmp/krava/include/perf/cpumap.h /tmp/krava/include/perf/core.h /tmp/krava/lib64 /tmp/krava/lib64/pkgconfig /tmp/krava/lib64/pkgconfig/libperf.pc /tmp/krava/lib64/libperf.so.0.0.1 /tmp/krava/lib64/libperf.so.0 /tmp/krava/lib64/libperf.so /tmp/krava/lib64/libperf.a Link: http://lkml.kernel.org/n/tip-gz16baafdkv6irfkywache2i@git.kernel.org Signed-off-by: Jiri Olsa --- tools/perf/lib/Makefile | 69 +++++++++++++++++++++++++++++- tools/perf/lib/libperf.pc.template | 11 +++++ 2 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 tools/perf/lib/libperf.pc.template diff --git a/tools/perf/lib/Makefile b/tools/perf/lib/Makefile index 25a6476f8b12..e69014a76971 100644 --- a/tools/perf/lib/Makefile +++ b/tools/perf/lib/Makefile @@ -14,9 +14,31 @@ 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.include include $(srctree)/tools/scripts/Makefile.arch +ifeq ($(LP64), 1) + libdir_relative = lib64 +else + libdir_relative = lib +endif + +prefix ?= +libdir = $(prefix)/$(libdir_relative) + +# Shell quotes +libdir_SQ = $(subst ','\'',$(libdir)) +libdir_relative_SQ = $(subst ','\'',$(libdir_relative)) + ifeq ("$(origin V)", "command line") VERBOSE = $(V) endif @@ -49,6 +71,8 @@ override CFLAGS += -fvisibility=hidden all: export srctree OUTPUT CC LD CFLAGS V +export DESTDIR DESTDIR_SQ + include $(srctree)/tools/build/Makefile.include VERSION_SCRIPT := libperf.map @@ -60,6 +84,9 @@ VERSION = $(LIBPERF_VERSION).$(LIBPERF_PATCHLEVEL).$(LIBPERF_EXTRAVERSION) LIBPERF_SO := $(OUTPUT)libperf.so.$(VERSION) LIBPERF_A := $(OUTPUT)libperf.a LIBPERF_IN := $(OUTPUT)libperf-in.o +LIBPERF_PC := $(OUTPUT)libperf.pc + +LIBPERF_ALL := $(LIBPERF_A) $(OUTPUT)libperf.so* $(LIBPERF_IN): FORCE $(Q)$(MAKE) $(build)=libperf @@ -74,14 +101,52 @@ $(LIBPERF_SO): $(LIBPERF_IN) @ln -sf $(@F) $(OUTPUT)libperf.so.$(LIBPERF_VERSION) -libs: $(LIBPERF_A) $(LIBPERF_SO) +libs: $(LIBPERF_A) $(LIBPERF_SO) $(LIBPERF_PC) all: fixdep $(Q)$(MAKE) libs clean: $(call QUIET_CLEAN, libperf) $(RM) $(LIBPERF_A) \ - *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS + *.o *~ *.a *.so *.so.$(VERSION) *.so.$(LIBPERF_VERSION) .*.d .*.cmd LIBPERF-CFLAGS $(LIBPERF_PC) + +$(LIBPERF_PC): + $(QUIET_GEN)sed -e "s|@PREFIX@|$(prefix)|" \ + -e "s|@LIBDIR@|$(libdir_SQ)|" \ + -e "s|@VERSION@|$(VERSION)|" \ + < libperf.pc.template > $@ + +define do_install_mkdir + if [ ! -d '$(DESTDIR_SQ)$1' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$1'; \ + fi +endef + +define do_install + if [ ! -d '$(DESTDIR_SQ)$2' ]; then \ + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$2'; \ + fi; \ + $(INSTALL) $1 $(if $3,-m $3,) '$(DESTDIR_SQ)$2' +endef + +install_lib: libs + $(call QUIET_INSTALL, $(LIBPERF_ALL)) \ + $(call do_install_mkdir,$(libdir_SQ)); \ + cp -fpR $(LIBPERF_ALL) $(DESTDIR)$(libdir_SQ) + +install_headers: + $(call QUIET_INSTALL, headers) \ + $(call do_install,include/perf/core.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/cpumap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/threadmap.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evlist.h,$(prefix)/include/perf,644); \ + $(call do_install,include/perf/evsel.h,$(prefix)/include/perf,644); + +install_pkgconfig: $(LIBPERF_PC) + $(call QUIET_INSTALL, $(LIBPERF_PC)) \ + $(call do_install,$(LIBPERF_PC),$(libdir_SQ)/pkgconfig,644) + +install: install_lib install_headers install_pkgconfig FORCE: diff --git a/tools/perf/lib/libperf.pc.template b/tools/perf/lib/libperf.pc.template new file mode 100644 index 000000000000..117e4a237b55 --- /dev/null +++ b/tools/perf/lib/libperf.pc.template @@ -0,0 +1,11 @@ +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) + +prefix=@PREFIX@ +libdir=@LIBDIR@ +includedir=${prefix}/include + +Name: libperf +Description: perf library +Version: @VERSION@ +Libs: -L${libdir} -lperf +Cflags: -I${includedir} -- 2.21.0