From: "Thiago Marcos P. Santos" <[email protected]>

libseccomp should not assume the existence of the prefix and library
directory since it can be an empty directory used for testing.
The best we can do is check if the destination path is not a directory
if it exists.

Added a macro for installing .pc files that creates a directory if it
doesn't exists and copy the file to the destination, respecting
ownership with proper file permissions.

Signed-off-by: Thiago Marcos P. Santos <[email protected]>
---
 Makefile  |    2 +-
 configure |    4 ++--
 macros.mk |   11 +++++++++++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 8c414d4..94de37b 100644
--- a/Makefile
+++ b/Makefile
@@ -85,7 +85,7 @@ tools: src
 
 install: $(SUBDIRS_BUILD)
        @$(ECHO) "INFO: installing in $(INSTALL_PREFIX) ..."
-       $(INSTALL_MACRO) libseccomp.pc $(INSTALL_LIB_DIR)/pkgconfig
+       $(INSTALL_PC_MACRO) libseccomp.pc
        @for dir in $(SUBDIRS_INSTALL); do \
                $(ECHO) "INFO: installing from $$dir/"; \
                $(MAKE) -C $$dir install; \
diff --git a/configure b/configure
index 8ac0b75..e11dea6 100755
--- a/configure
+++ b/configure
@@ -188,14 +188,14 @@ while [[ $# -gt 0 ]]; do
 done
 
 # validate the options
-if [[ ! -d $opt_prefix ]]; then
+if [[ -e "$opt_prefix" && ! -d "$opt_prefix" ]]; then
        msg_error "install prefix ($opt_prefix) is not a directory"
        exit 1
 fi
 if [[ -z $opt_libdir ]]; then
        opt_libdir="$opt_prefix/lib"
 fi
-if [[ ! -d $opt_libdir ]]; then
+if [[ -e "$opt_libdir" && ! -d "$opt_libdir" ]]; then
        msg_error "libdir ($opt_libdir) is not a directory"
        exit 1
 fi
diff --git a/macros.mk b/macros.mk
index 5998010..4a12a9a 100644
--- a/macros.mk
+++ b/macros.mk
@@ -179,6 +179,17 @@ INSTALL_LIB_MACRO = \
        }; \
        install_lib_func
 
+INSTALL_PC_MACRO += \
+       @install_pc_func() { \
+               dir="$(INSTALL_LIB_DIR)/pkgconfig"; \
+               $(ECHO) " INSTALL $$1 ($$dir/$$1)"; \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
+                       -d "$$dir"; \
+               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
+                       $$1 "$$dir"; \
+       }; \
+       install_pc_func
+
 ifeq ($(V),0)
        INSTALL_INC_MACRO = @echo " INSTALL $^ ($(INSTALL_INC_DIR))";
 endif
-- 
1.7.9.5


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libseccomp-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/libseccomp-discuss

Reply via email to