2018-11-30 15:49:17

by Steven Rostedt

[permalink] [raw]
Subject: [PATCH 2/9] tools/lib/traceevent: Added support for pkg-config

From: Tzvetomir Stoyanov <[email protected]>

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 <[email protected]>
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
---
tools/lib/traceevent/Makefile | 26 ++++++++++++++++---
.../lib/traceevent/libtraceevent.pc.template | 10 +++++++
2 files changed, 33 insertions(+), 3 deletions(-)
create mode 100644 tools/lib/traceevent/libtraceevent.pc.template

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 0b4e833088a4..adb16f845ab3 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -25,6 +25,7 @@ endef
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,NM,$(CROSS_COMPILE)nm)
+$(call allow-override,PKG_CONFIG,pkg-config)

EXT = -std=gnu99
INSTALL = install
@@ -47,6 +48,8 @@ prefix ?= /usr/local
libdir = $(prefix)/$(libdir_relative)
man_dir = $(prefix)/share/man
man_dir_SQ = '$(subst ','\'',$(man_dir))'
+pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \
+ --variable pc_path pkg-config | tr ":" " "))

export man_dir man_dir_SQ INSTALL
export DESTDIR DESTDIR_SQ
@@ -270,7 +273,19 @@ define do_generate_dynamic_list_file
fi
endef

-install_lib: all_cmd install_plugins
+PKG_CONFIG_FILE = libtraceevent.pc
+define do_install_pkgconfig_file
+ if [ -n "${pkgconfig_dir}" ]; then \
+ cp -f ${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; \
+ sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \
+ sed -i "s|LIB_VERSION|${EVENT_PARSE_VERSION}|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
+
+install_lib: all_cmd install_plugins install_pkgconfig
$(call QUIET_INSTALL, $(LIB_TARGET)) \
$(call do_install_mkdir,$(libdir_SQ)); \
cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
@@ -279,6 +294,10 @@ install_plugins: $(PLUGINS)
$(call QUIET_INSTALL, trace_plugins) \
$(call do_install_plugins, $(PLUGINS))

+install_pkgconfig:
+ $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
+ $(call do_install_pkgconfig_file,$(prefix))
+
install_headers:
$(call QUIET_INSTALL, headers) \
$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
@@ -289,8 +308,9 @@ install: install_lib

clean:
$(call QUIET_CLEAN, libtraceevent) \
- $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \
- $(RM) TRACEEVENT-CFLAGS tags TAGS
+ $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \
+ $(RM) TRACEEVENT-CFLAGS tags TAGS; \
+ $(RM) $(PKG_CONFIG_FILE)

PHONY += force plugins
force:
diff --git a/tools/lib/traceevent/libtraceevent.pc.template b/tools/lib/traceevent/libtraceevent.pc.template
new file mode 100644
index 000000000000..42e4d6cb6b9e
--- /dev/null
+++ b/tools/lib/traceevent/libtraceevent.pc.template
@@ -0,0 +1,10 @@
+prefix=INSTALL_PREFIX
+libdir=${prefix}/lib64
+includedir=${prefix}/include/traceevent
+
+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.1




2018-12-04 07:33:46

by Namhyung Kim

[permalink] [raw]
Subject: Re: [PATCH 2/9] tools/lib/traceevent: Added support for pkg-config

Hi Steve,

On Fri, Nov 30, 2018 at 10:44:05AM -0500, Steven Rostedt wrote:
> From: Tzvetomir Stoyanov <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Steven Rostedt (VMware) <[email protected]>
> ---

[SNIP]
> diff --git a/tools/lib/traceevent/libtraceevent.pc.template b/tools/lib/traceevent/libtraceevent.pc.template
> new file mode 100644
> index 000000000000..42e4d6cb6b9e
> --- /dev/null
> +++ b/tools/lib/traceevent/libtraceevent.pc.template
> @@ -0,0 +1,10 @@
> +prefix=INSTALL_PREFIX
> +libdir=${prefix}/lib64

Don't we care 32-bit systems anymore? :)

Thanks,
Namhyung


> +includedir=${prefix}/include/traceevent
> +
> +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.1
>
>

2018-12-04 08:52:23

by Tzvetomir Stoyanov

[permalink] [raw]
Subject: Re: [PATCH 2/9] tools/lib/traceevent: Added support for pkg-config

Hi Namhyung,

On Tue, Dec 4, 2018 at 9:32 AM Namhyung Kim <[email protected]> wrote:
>
> Hi Steve,
>
> On Fri, Nov 30, 2018 at 10:44:05AM -0500, Steven Rostedt wrote:
> > From: Tzvetomir Stoyanov <[email protected]>
> >
> > 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 <[email protected]>
> > Signed-off-by: Steven Rostedt (VMware) <[email protected]>
> > ---
>
> [SNIP]
> > diff --git a/tools/lib/traceevent/libtraceevent.pc.template b/tools/lib/traceevent/libtraceevent.pc.template
> > new file mode 100644
> > index 000000000000..42e4d6cb6b9e
> > --- /dev/null
> > +++ b/tools/lib/traceevent/libtraceevent.pc.template
> > @@ -0,0 +1,10 @@
> > +prefix=INSTALL_PREFIX
> > +libdir=${prefix}/lib64
>
> Don't we care 32-bit systems anymore? :)
>

It is my fault, going to submit a patch to parameterized it.

> Thanks,
> Namhyung
>
>
> > +includedir=${prefix}/include/traceevent
> > +
> > +Name: libtraceevent
> > +URL: https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgit.kernel.org%2Fpub%2Fscm%2Flinux%2Fkernel%2Fgit%2Ftorvalds%2Flinux.git&amp;data=02%7C01%7Ctstoyanov%40vmware.com%7Cbf86381418da46f7712108d659baaa20%7Cb39138ca3cee4b4aa4d6cd83d9dd62f0%7C0%7C0%7C636795055608012046&amp;sdata=r6iXSffCrEzO0hRhpiIctdP2jcfbESaJxOZVrHLnAfw%3D&amp;reserved=0
> > +Description: Linux kernel trace event library
> > +Version: LIB_VERSION
> > +Cflags: -I${includedir}
> > +Libs: -L${libdir} -ltraceevent
> > --
> > 2.19.1
> >
> >

--
Tzvetomir (Ceco) Stoyanov
VMware Open Source Technology Center

2018-12-04 17:30:00

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH 2/9] tools/lib/traceevent: Added support for pkg-config

On Tue, 4 Dec 2018 16:32:35 +0900
Namhyung Kim <[email protected]> wrote:

> > +++ b/tools/lib/traceevent/libtraceevent.pc.template
> > @@ -0,0 +1,10 @@
> > +prefix=INSTALL_PREFIX
> > +libdir=${prefix}/lib64
>
> Don't we care 32-bit systems anymore? :)

No we don't ;-)

But, I guess because some people still do, we need to fix it.

Thanks for reviewing!

-- Steve

Subject: [tip:perf/core] tools lib traceevent: Added support for pkg-config

Commit-ID: cadb29db628d761b190875e54e9d5b65a30b1925
Gitweb: https://git.kernel.org/tip/cadb29db628d761b190875e54e9d5b65a30b1925
Author: Tzvetomir Stoyanov <[email protected]>
AuthorDate: Fri, 30 Nov 2018 10:44:05 -0500
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Fri, 30 Nov 2018 17:14:53 -0300

tools lib traceevent: Added support for pkg-config

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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/Makefile | 26 +++++++++++++++++++++++---
tools/lib/traceevent/libtraceevent.pc.template | 10 ++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 0b4e833088a4..adb16f845ab3 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -25,6 +25,7 @@ endef
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,NM,$(CROSS_COMPILE)nm)
+$(call allow-override,PKG_CONFIG,pkg-config)

EXT = -std=gnu99
INSTALL = install
@@ -47,6 +48,8 @@ prefix ?= /usr/local
libdir = $(prefix)/$(libdir_relative)
man_dir = $(prefix)/share/man
man_dir_SQ = '$(subst ','\'',$(man_dir))'
+pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \
+ --variable pc_path pkg-config | tr ":" " "))

export man_dir man_dir_SQ INSTALL
export DESTDIR DESTDIR_SQ
@@ -270,7 +273,19 @@ define do_generate_dynamic_list_file
fi
endef

-install_lib: all_cmd install_plugins
+PKG_CONFIG_FILE = libtraceevent.pc
+define do_install_pkgconfig_file
+ if [ -n "${pkgconfig_dir}" ]; then \
+ cp -f ${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; \
+ sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \
+ sed -i "s|LIB_VERSION|${EVENT_PARSE_VERSION}|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
+
+install_lib: all_cmd install_plugins install_pkgconfig
$(call QUIET_INSTALL, $(LIB_TARGET)) \
$(call do_install_mkdir,$(libdir_SQ)); \
cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
@@ -279,6 +294,10 @@ install_plugins: $(PLUGINS)
$(call QUIET_INSTALL, trace_plugins) \
$(call do_install_plugins, $(PLUGINS))

+install_pkgconfig:
+ $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
+ $(call do_install_pkgconfig_file,$(prefix))
+
install_headers:
$(call QUIET_INSTALL, headers) \
$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
@@ -289,8 +308,9 @@ install: install_lib

clean:
$(call QUIET_CLEAN, libtraceevent) \
- $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \
- $(RM) TRACEEVENT-CFLAGS tags TAGS
+ $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \
+ $(RM) TRACEEVENT-CFLAGS tags TAGS; \
+ $(RM) $(PKG_CONFIG_FILE)

PHONY += force plugins
force:
diff --git a/tools/lib/traceevent/libtraceevent.pc.template b/tools/lib/traceevent/libtraceevent.pc.template
new file mode 100644
index 000000000000..42e4d6cb6b9e
--- /dev/null
+++ b/tools/lib/traceevent/libtraceevent.pc.template
@@ -0,0 +1,10 @@
+prefix=INSTALL_PREFIX
+libdir=${prefix}/lib64
+includedir=${prefix}/include/traceevent
+
+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

Subject: [tip:perf/core] tools lib traceevent: Added support for pkg-config

Commit-ID: cc03e1a8f82dff36fb329469c28cbfe7d2e6156a
Gitweb: https://git.kernel.org/tip/cc03e1a8f82dff36fb329469c28cbfe7d2e6156a
Author: Tzvetomir Stoyanov <[email protected]>
AuthorDate: Fri, 30 Nov 2018 10:44:05 -0500
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Mon, 17 Dec 2018 14:55:55 -0300

tools lib traceevent: Added support for pkg-config

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 <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/Makefile | 26 +++++++++++++++++++++++---
tools/lib/traceevent/libtraceevent.pc.template | 10 ++++++++++
2 files changed, 33 insertions(+), 3 deletions(-)

diff --git a/tools/lib/traceevent/Makefile b/tools/lib/traceevent/Makefile
index 0b4e833088a4..adb16f845ab3 100644
--- a/tools/lib/traceevent/Makefile
+++ b/tools/lib/traceevent/Makefile
@@ -25,6 +25,7 @@ endef
$(call allow-override,CC,$(CROSS_COMPILE)gcc)
$(call allow-override,AR,$(CROSS_COMPILE)ar)
$(call allow-override,NM,$(CROSS_COMPILE)nm)
+$(call allow-override,PKG_CONFIG,pkg-config)

EXT = -std=gnu99
INSTALL = install
@@ -47,6 +48,8 @@ prefix ?= /usr/local
libdir = $(prefix)/$(libdir_relative)
man_dir = $(prefix)/share/man
man_dir_SQ = '$(subst ','\'',$(man_dir))'
+pkgconfig_dir ?= $(word 1,$(shell $(PKG_CONFIG) \
+ --variable pc_path pkg-config | tr ":" " "))

export man_dir man_dir_SQ INSTALL
export DESTDIR DESTDIR_SQ
@@ -270,7 +273,19 @@ define do_generate_dynamic_list_file
fi
endef

-install_lib: all_cmd install_plugins
+PKG_CONFIG_FILE = libtraceevent.pc
+define do_install_pkgconfig_file
+ if [ -n "${pkgconfig_dir}" ]; then \
+ cp -f ${PKG_CONFIG_FILE}.template ${PKG_CONFIG_FILE}; \
+ sed -i "s|INSTALL_PREFIX|${1}|g" ${PKG_CONFIG_FILE}; \
+ sed -i "s|LIB_VERSION|${EVENT_PARSE_VERSION}|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
+
+install_lib: all_cmd install_plugins install_pkgconfig
$(call QUIET_INSTALL, $(LIB_TARGET)) \
$(call do_install_mkdir,$(libdir_SQ)); \
cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
@@ -279,6 +294,10 @@ install_plugins: $(PLUGINS)
$(call QUIET_INSTALL, trace_plugins) \
$(call do_install_plugins, $(PLUGINS))

+install_pkgconfig:
+ $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
+ $(call do_install_pkgconfig_file,$(prefix))
+
install_headers:
$(call QUIET_INSTALL, headers) \
$(call do_install,event-parse.h,$(prefix)/include/traceevent,644); \
@@ -289,8 +308,9 @@ install: install_lib

clean:
$(call QUIET_CLEAN, libtraceevent) \
- $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd \
- $(RM) TRACEEVENT-CFLAGS tags TAGS
+ $(RM) *.o *~ $(TARGETS) *.a *.so $(VERSION_FILES) .*.d .*.cmd; \
+ $(RM) TRACEEVENT-CFLAGS tags TAGS; \
+ $(RM) $(PKG_CONFIG_FILE)

PHONY += force plugins
force:
diff --git a/tools/lib/traceevent/libtraceevent.pc.template b/tools/lib/traceevent/libtraceevent.pc.template
new file mode 100644
index 000000000000..42e4d6cb6b9e
--- /dev/null
+++ b/tools/lib/traceevent/libtraceevent.pc.template
@@ -0,0 +1,10 @@
+prefix=INSTALL_PREFIX
+libdir=${prefix}/lib64
+includedir=${prefix}/include/traceevent
+
+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