linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tzvetomir Stoyanov <tstoyanov@vmware.com>
To: "rostedt@goodmis.org" <rostedt@goodmis.org>
Cc: "linux-trace-devel@vger.kernel.org" <linux-trace-devel@vger.kernel.org>
Subject: [PATCH 5/6] tools lib traceevent: Added support for pkg-config
Date: Wed, 5 Dec 2018 09:21:52 +0000	[thread overview]
Message-ID: <20181205092134.2214-6-tstoyanov@vmware.com> (raw)
In-Reply-To: <20181205092134.2214-1-tstoyanov@vmware.com>

This patch implements integration with pkg-config framework.  pkg-config
can be used by the library users to determine required CFLAGS and
LDFLAGS in order to use the library

Signed-off-by: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/20181130154647.022471992@goodmis.org
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 Makefile                                 | 44 ++++++++++++++++++++----
 lib/traceevent/libtraceevent.pc.template | 10 ++++++
 2 files changed, 48 insertions(+), 6 deletions(-)
 create mode 100644 lib/traceevent/libtraceevent.pc.template

diff --git a/Makefile b/Makefile
index 7ee9e0d..8dbba58 100644
--- a/Makefile
+++ b/Makefile
@@ -29,6 +29,7 @@ endef
 # Allow setting CC and AR, or setting CROSS_COMPILE as a prefix.
 $(call allow-override,CC,$(CROSS_COMPILE)gcc)
 $(call allow-override,AR,$(CROSS_COMPILE)ar)
+$(call allow-override,PKG_CONFIG,pkg-config)
 
 EXT = -std=gnu99
 INSTALL = install
@@ -40,6 +41,13 @@ INSTALL = install
 DESTDIR ?=
 DESTDIR_SQ = '$(subst ','\'',$(DESTDIR))'
 
+LP64 := $(shell echo __LP64__ | ${CC} ${CFLAGS} -E -x c - | tail -n 1)
+ifeq ($(LP64), 1)
+  libdir_relative = lib64
+else
+  libdir_relative = lib
+endif
+
 prefix ?= /usr/local
 bindir_relative = bin
 bindir = $(prefix)/$(bindir_relative)
@@ -49,10 +57,16 @@ html_install = $(prefix)/share/kernelshark/html
 html_install_SQ = '$(subst ','\'',$(html_install))'
 img_install = $(prefix)/share/kernelshark/html/images
 img_install_SQ = '$(subst ','\'',$(img_install))'
-libdir ?= $(prefix)/lib
+libdir ?= $(prefix)/$(libdir_relative)
 libdir_SQ = '$(subst ','\'',$(libdir))'
-includedir = $(prefix)/include/trace-cmd
-includedir_SQ = '$(subst ','\'',$(includedir))'
+includedir_libtrace_relative = traceevent
+includedir_tc_relative = trace-cmd
+includedir_tc = $(prefix)/include/$(includedir_tc_relative)
+includedir_libtrace = $(prefix)/include/$(includedir_libtrace_relative)
+includedir_tc_SQ = '$(subst ','\'',$(includedir_tc))'
+includedir_libtrace_SQ = '$(subst ','\'',$(includedir_libtrace))'
+pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) 		\
+			--variable pc_path pkg-config | tr ":" " "))
 
 export man_dir man_dir_SQ html_install html_install_SQ INSTALL
 export img_install img_install_SQ
@@ -305,6 +319,20 @@ show_gui_make:
 
 PHONY += show_gui_make
 
+PKG_CONFIG_FILE = libtraceevent.pc
+define do_install_pkgconfig_file
+	if [ -n "${pkgconfig_dir}" ]; then 					\
+		cp -f lib/traceevent/${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; 		\
+		sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; 		\
+		sed -i "s|LIB_VERSION|${TRACECMD_VERSION}|g" ${PKG_CONFIG_FILE}; \
+		sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
+		sed -i "s|HEADER_DIR|$(includedir_libtrace)|g" ${PKG_CONFIG_FILE}; \
+		$(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); 	\
+	else 									\
+		(echo Failed to locate pkg-config directory) 1>&2;		\
+	fi
+endef
+
 define find_tag_files
 	find . -name '\.pc' -prune -o -name '*\.[ch]' -print -o -name '*\.[ch]pp' \
 		! -name '\.#' -print
@@ -322,6 +350,9 @@ cscope: force
 	$(RM) cscope*
 	$(call find_tag_files) | cscope -b -q
 
+install_pkgconfig:
+	$(Q)$(call do_install_pkgconfig_file,$(prefix))
+
 install_plugins: force
 	$(Q)$(MAKE) -C $(src)/plugins $@
 
@@ -341,11 +372,11 @@ install: install_cmd
 install_gui: install_cmd gui
 	$(Q)$(MAKE) $(S) -C $(kshark-dir)/build install
 
-install_libs: libs
+install_libs: libs install_pkgconfig
 	$(Q)$(call do_install,$(LIBTRACECMD_SHARED),$(libdir_SQ))
 	$(Q)$(call do_install,$(LIBTRACEEVENT_SHARED),$(libdir_SQ))
-	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_SQ))
-	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_SQ))
+	$(Q)$(call do_install,$(src)/include/traceevent/event-parse.h,$(includedir_libtrace_SQ))
+	$(Q)$(call do_install,$(src)/include/trace-cmd/trace-cmd.h,$(includedir_tc_SQ))
 
 doc:
 	$(MAKE) -C $(src)/Documentation all
@@ -359,6 +390,7 @@ install_doc:
 clean:
 	$(RM) *.o *~ *.a *.so .*.d
 	$(RM) tags TAGS cscope*
+	$(RM) -f $(PKG_CONFIG_FILE)
 	$(MAKE) -C $(src)/lib/traceevent clean
 	$(MAKE) -C $(src)/lib/trace-cmd clean
 	$(MAKE) -C $(src)/kernel-shark clean
diff --git a/lib/traceevent/libtraceevent.pc.template b/lib/traceevent/libtraceevent.pc.template
new file mode 100644
index 0000000..86384fc
--- /dev/null
+++ b/lib/traceevent/libtraceevent.pc.template
@@ -0,0 +1,10 @@
+prefix=INSTALL_PREFIX
+libdir=LIB_DIR
+includedir=HEADER_DIR
+
+Name: libtraceevent
+URL: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
+Description: Linux kernel trace event library
+Version: LIB_VERSION
+Cflags: -I${includedir}
+Libs: -L${libdir} -ltraceevent
-- 
2.19.2

  parent reply	other threads:[~2018-12-05  9:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-05  9:21 [PATCH 0/6] tools/lib/traceevent: Various changes in libtraceevent APIs Tzvetomir Stoyanov
2018-12-05  9:21 ` [PATCH 1/6] tools lib traceevent: Implement new API tep_get_ref() Tzvetomir Stoyanov
2018-12-05  9:21 ` [PATCH 2/6] tools lib traceevent, perf tools: Rename 'struct tep_event_format' to 'struct tep_event' Tzvetomir Stoyanov
2018-12-05  9:21 ` [PATCH 3/6] tools lib traceevent: Rename tep_free_format() to tep_free_event() Tzvetomir Stoyanov
2018-12-05  9:21 ` [PATCH 4/6] tools lib traceevent: traceevent API cleanup Tzvetomir Stoyanov
2018-12-05  9:21 ` Tzvetomir Stoyanov [this message]
2018-12-11 16:52   ` [PATCH 5/6] tools lib traceevent: Added support for pkg-config Steven Rostedt
2018-12-05  9:21 ` [PATCH 6/6] tools lib traceevent: Install trace-seq.h API header file Tzvetomir Stoyanov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181205092134.2214-6-tstoyanov@vmware.com \
    --to=tstoyanov@vmware.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).