linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] libtracevent: Build libtraceevent.pc via "make" not "make install"
@ 2020-11-24 14:12 Steven Rostedt
  2020-11-24 16:21 ` Tzvetomir Stoyanov
  0 siblings, 1 reply; 2+ messages in thread
From: Steven Rostedt @ 2020-11-24 14:12 UTC (permalink / raw)
  To: Linux Trace Devel; +Cc: Tzvetomir Stoyanov

From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>

"make install" copies libtraceevent.pc.template to libtraceevent.pc and then
modifies it for the installation. This command is usually executed as root,
and when finished, it leaves behind the libtraceevent.pc file owned by root
and that may not be modified by the owner of the directory.

Instead, have the libtraceevent.pc file created via normal "make" and then
have the "make install" copy it to the system location.

Link: https://lore.kernel.org/linux-trace-devel/20201123184940.031517790@goodmis.org

Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
---
 Changes since v1:
    - Have libtraceevent.pc created by "make" and not simply remove
      it after creation from the "make install". This allows us to be
      able to debug it, if it was not created properly.
         (Tzvetomir Stoyanov)

 Makefile | 25 ++++++++++++++++---------
 1 file changed, 16 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 2a6bfcc..318ec55 100644
--- a/Makefile
+++ b/Makefile
@@ -52,6 +52,9 @@ includedir_relative = traceevent
 includedir = $(prefix)/include/$(includedir_relative)
 includedir_SQ = '$(subst ','\'',$(includedir))'
 
+PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
+PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
+
 export man_dir man_dir_SQ INSTALL
 export DESTDIR DESTDIR_SQ
 export EVENT_PARSE_VERSION
@@ -126,7 +129,7 @@ build := -f $(srctree)/build/Makefile.build dir=. obj
 TE_IN      := $(OUTPUT)libtraceevent-in.o
 LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET))
 
-CMD_TARGETS = $(LIB_TARGET)
+CMD_TARGETS = $(LIB_TARGET) $(PKG_CONFIG_FILE)
 
 TARGETS = $(CMD_TARGETS)
 
@@ -208,15 +211,19 @@ define do_install
 	$(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
 endef
 
-PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
-PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
+define do_make_pkgconfig_file
+	cp -f ${PKG_CONFIG_SOURCE_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}; \
+	sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
+	sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE};
+endef
+
+$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template
+	$(QUIET_GEN) $(call do_make_pkgconfig_file,$(prefix))
+
 define do_install_pkgconfig_file
 	if [ -n "${pkgconfig_dir}" ]; then 					\
-		cp -f ${PKG_CONFIG_SOURCE_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}; \
-		sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
-		sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE}; \
 		$(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644); 	\
 	else 									\
 		(echo Failed to locate pkg-config directory) 1>&2;		\
@@ -228,7 +235,7 @@ install_lib: all_cmd install_plugins install_headers install_pkgconfig
 		$(call do_install_mkdir,$(libdir_SQ)); \
 		cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
 
-install_pkgconfig:
+install_pkgconfig: $(PKG_CONFIG_FILE)
 	$(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
 		$(call do_install_pkgconfig_file,$(prefix))
 
-- 
2.25.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v2] libtracevent: Build libtraceevent.pc via "make" not "make install"
  2020-11-24 14:12 [PATCH v2] libtracevent: Build libtraceevent.pc via "make" not "make install" Steven Rostedt
@ 2020-11-24 16:21 ` Tzvetomir Stoyanov
  0 siblings, 0 replies; 2+ messages in thread
From: Tzvetomir Stoyanov @ 2020-11-24 16:21 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: Linux Trace Devel

On Tue, Nov 24, 2020 at 4:12 PM Steven Rostedt <rostedt@goodmis.org> wrote:
>
> From: "Steven Rostedt (VMware)" <rostedt@goodmis.org>
>
> "make install" copies libtraceevent.pc.template to libtraceevent.pc and then
> modifies it for the installation. This command is usually executed as root,
> and when finished, it leaves behind the libtraceevent.pc file owned by root
> and that may not be modified by the owner of the directory.
>
> Instead, have the libtraceevent.pc file created via normal "make" and then
> have the "make install" copy it to the system location.
>
> Link: https://lore.kernel.org/linux-trace-devel/20201123184940.031517790@goodmis.org
>
> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
> ---
>  Changes since v1:
>     - Have libtraceevent.pc created by "make" and not simply remove
>       it after creation from the "make install". This allows us to be
>       able to debug it, if it was not created properly.
>          (Tzvetomir Stoyanov)
>
>  Makefile | 25 ++++++++++++++++---------
>  1 file changed, 16 insertions(+), 9 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 2a6bfcc..318ec55 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -52,6 +52,9 @@ includedir_relative = traceevent
>  includedir = $(prefix)/include/$(includedir_relative)
>  includedir_SQ = '$(subst ','\'',$(includedir))'
>
> +PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
> +PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
> +
>  export man_dir man_dir_SQ INSTALL
>  export DESTDIR DESTDIR_SQ
>  export EVENT_PARSE_VERSION
> @@ -126,7 +129,7 @@ build := -f $(srctree)/build/Makefile.build dir=. obj
>  TE_IN      := $(OUTPUT)libtraceevent-in.o
>  LIB_TARGET := $(addprefix $(OUTPUT),$(LIB_TARGET))
>
> -CMD_TARGETS = $(LIB_TARGET)
> +CMD_TARGETS = $(LIB_TARGET) $(PKG_CONFIG_FILE)
>
>  TARGETS = $(CMD_TARGETS)
>
> @@ -208,15 +211,19 @@ define do_install
>         $(INSTALL) $(if $3,-m $3,) $1 '$(DESTDIR_SQ)$2'
>  endef
>
> -PKG_CONFIG_SOURCE_FILE = libtraceevent.pc
> -PKG_CONFIG_FILE := $(addprefix $(OUTPUT),$(PKG_CONFIG_SOURCE_FILE))
> +define do_make_pkgconfig_file
> +       cp -f ${PKG_CONFIG_SOURCE_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}; \
> +       sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
> +       sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE};
> +endef
> +
> +$(PKG_CONFIG_FILE) : ${PKG_CONFIG_SOURCE_FILE}.template
> +       $(QUIET_GEN) $(call do_make_pkgconfig_file,$(prefix))
> +
>  define do_install_pkgconfig_file
>         if [ -n "${pkgconfig_dir}" ]; then                                      \
> -               cp -f ${PKG_CONFIG_SOURCE_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}; \
> -               sed -i "s|LIB_DIR|${libdir}|g" ${PKG_CONFIG_FILE}; \
> -               sed -i "s|HEADER_DIR|$(includedir)|g" ${PKG_CONFIG_FILE}; \
>                 $(call do_install,$(PKG_CONFIG_FILE),$(pkgconfig_dir),644);     \
>         else                                                                    \
>                 (echo Failed to locate pkg-config directory) 1>&2;              \
> @@ -228,7 +235,7 @@ install_lib: all_cmd install_plugins install_headers install_pkgconfig
>                 $(call do_install_mkdir,$(libdir_SQ)); \
>                 cp -fpR $(LIB_INSTALL) $(DESTDIR)$(libdir_SQ)
>
> -install_pkgconfig:
> +install_pkgconfig: $(PKG_CONFIG_FILE)
>         $(call QUIET_INSTALL, $(PKG_CONFIG_FILE)) \
>                 $(call do_install_pkgconfig_file,$(prefix))
>
> --
> 2.25.4
>

Thanks Steven!
Acked-by: "Tzvetomir Stoyanov (VMware)" <tz.stoyanov@gmail.com>

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-11-24 16:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 14:12 [PATCH v2] libtracevent: Build libtraceevent.pc via "make" not "make install" Steven Rostedt
2020-11-24 16:21 ` Tzvetomir Stoyanov

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).