This patch, along with some general Makefile cleanups, adds the
ability to display verbose build information if desired.  To perform
a verbose build, simple add "V=1" to the make command line as shown
below:

        # make V=1

The default remains the same, builds will be "quiet".

Signed-off-by: Paul Moore <[email protected]>
---
 Makefile       |   58 ++++++++++++------------
 README         |    2 -
 doc/Makefile   |    2 -
 macros.mk      |  135 ++++++++++++++++++++++++++------------------------------
 src/Makefile   |    2 -
 tests/Makefile |    2 -
 tools/Makefile |    2 -
 7 files changed, 96 insertions(+), 107 deletions(-)

diff --git a/Makefile b/Makefile
index b54f4c9..8c414d4 100644
--- a/Makefile
+++ b/Makefile
@@ -46,66 +46,66 @@ SUBDIRS_INSTALL = src include doc
 all: $(SUBDIRS_BUILD)
 
 $(CONFIGS): version_info
-       @echo "INFO: automatically generating configuration ..."
+       @$(ECHO) "INFO: automatically generating configuration ..."
        @./configure
 
 tarball: clean
        @ver=$(VERSION_RELEASE); \
        tarball=libseccomp-$$ver.tar.gz; \
-       echo "INFO: creating the tarball ../$$tarball"; \
+       $(ECHO) "INFO: creating the tarball ../$$tarball"; \
        tmp_dir=$$(mktemp -d /tmp/libseccomp.XXXXX); \
        rel_dir=$$tmp_dir/libseccomp-$$ver; \
-       mkdir $$rel_dir; \
-       tar cf - --exclude=*~ --exclude=.git* --exclude=.stgit* . | \
+       $(MKDIR) $$rel_dir; \
+       $(TAR) cf - --exclude=*~ --exclude=.git* --exclude=.stgit* . | \
                (cd $$rel_dir; tar xf -); \
-       (cd $$tmp_dir; tar zcf $$tarball libseccomp-$$ver); \
-       mv $$tmp_dir/$$tarball ..; \
-       rm -rf $$tmp_dir;
+       (cd $$tmp_dir; $(TAR) zcf $$tarball libseccomp-$$ver); \
+       $(MV) $$tmp_dir/$$tarball ..; \
+       $(RM) -rf $$tmp_dir;
 
 $(VERSION_HDR): version_info.mk
-       @echo "INFO: creating the version header file"
+       @$(ECHO) "INFO: creating the version header file"
        @hdr="$(VERSION_HDR)"; \
-       echo "/* automatically generated - do not edit */" > $$hdr; \
-       echo "#ifndef _VERSION_H" >> $$hdr; \
-       echo "#define _VERSION_H" >> $$hdr; \
-       echo "#define VERSION_RELEASE \"$(VERSION_RELEASE)\"" >> $$hdr; \
-       echo "#endif" >> $$hdr;
+       $(ECHO) "/* automatically generated - do not edit */" > $$hdr; \
+       $(ECHO) "#ifndef _VERSION_H" >> $$hdr; \
+       $(ECHO) "#define _VERSION_H" >> $$hdr; \
+       $(ECHO) "#define VERSION_RELEASE \"$(VERSION_RELEASE)\"" >> $$hdr; \
+       $(ECHO) "#endif" >> $$hdr;
 
 src: $(VERSION_HDR) $(CONFIGS)
-       @echo "INFO: building in directory $@/ ..."
-       @$(MAKE) -s -C $@
+       @$(ECHO) "INFO: building in directory $@/ ..."
+       @$(MAKE) -C $@
 
 tests: src
-       @echo "INFO: building in directory $@/ ..."
-       @$(MAKE) -s -C $@
+       @$(ECHO) "INFO: building in directory $@/ ..."
+       @$(MAKE) -C $@
 
 tools: src
-       @echo "INFO: building in directory $@/ ..."
-       @$(MAKE) -s -C $@
+       @$(ECHO) "INFO: building in directory $@/ ..."
+       @$(MAKE) -C $@
 
 install: $(SUBDIRS_BUILD)
-       @echo "INFO: installing in $(INSTALL_PREFIX) ..."
-       @$(INSTALL_MACRO) $(INSTALL_LIB_DIR)/pkgconfig libseccomp.pc
+       @$(ECHO) "INFO: installing in $(INSTALL_PREFIX) ..."
+       $(INSTALL_MACRO) libseccomp.pc $(INSTALL_LIB_DIR)/pkgconfig
        @for dir in $(SUBDIRS_INSTALL); do \
-               echo "INFO: installing from $$dir/"; \
-               $(MAKE) -s -C $$dir install; \
+               $(ECHO) "INFO: installing from $$dir/"; \
+               $(MAKE) -C $$dir install; \
        done
 
 ctags:
-       @echo "INFO: generating ctags for the project ..."
+       @$(ECHO) "INFO: generating ctags for the project ..."
        @ctags -R *
 
 cstags:
-       @echo "INFO: generating cscope tags for the project ..."
+       @$(ECHO) "INFO: generating cscope tags for the project ..."
        @find -iname *.[ch] > cscope.files
        @cscope -b -q -k
 
 clean:
+       @$(ECHO) "INFO: cleaning up libseccomp"
        @for dir in $(SUBDIRS_BUILD); do \
-               echo "INFO: cleaning in $$dir/"; \
-               $(MAKE) -s -C $$dir clean; \
+               $(MAKE) -C $$dir clean; \
        done
 
 dist-clean: clean
-       @echo "INFO: removing the configuration files"
-       @rm -f $(CONFIGS)
+       @$(ECHO) "INFO: removing the configuration files"
+       @$(RM) $(CONFIGS)
diff --git a/README b/README
index 2af1d14..37b9709 100644
--- a/README
+++ b/README
@@ -21,7 +21,7 @@ In order to build the library you should follow the familiar 
three step
 process used by most applications:
 
        # ./configure
-       # make
+       # make [V=0|1]
        # make install
 
 As usual, running "./configure -h" will display a list of build-time
diff --git a/doc/Makefile b/doc/Makefile
index 1d422c9..c6d3f52 100644
--- a/doc/Makefile
+++ b/doc/Makefile
@@ -57,4 +57,4 @@ all:
 install: install_man3
 
 install_man3: $(MAN3)
-       $(INSTALL_MAN_MACRO) man3 "manpages"
+       $(INSTALL_MAN3_MACRO)
diff --git a/macros.mk b/macros.mk
index 90cfc88..5998010 100644
--- a/macros.mk
+++ b/macros.mk
@@ -40,6 +40,8 @@ TOPDIR := $(shell \
 # build configuration
 #
 
+V ?= 0
+
 CPPFLAGS += -I$(TOPDIR) -I$(TOPDIR)/include
 LIBFLAGS =
 
@@ -55,6 +57,8 @@ LN ?= ln
 MV ?= mv
 CAT ?= cat
 ECHO ?= echo
+TAR ?= tar
+MKDIR ?= mkdir
 
 SED ?= sed
 AWK ?= awk
@@ -92,66 +96,63 @@ VERSION_HDR = version.h
 # build macros
 #
 
-ARCHIVE = @echo " AR $@ (add/update: $?)"; $(AR) -cru $@ $?;
-COMPILE = @echo " CC $@"; $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<;
-COMPILE_EXEC = @echo " CC $@"; $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ $< 
$(LDFLAGS);
-LINK_EXEC = @echo " LD $@"; $(GCC) $(LDFLAGS) -o $@ $^ $(LIBFLAGS);
-LINK_LIB = \
-       @link_lib_func() { \
-               name=$${1//.so.*/.so}.$(VERSION_MAJOR); \
-               echo " LD $@ ($$name)"; \
-               $(GCC) $(LDFLAGS) -o $@ $^ -shared -Wl,-soname=$$name; \
-       }; \
-       link_lib_func $@;
+ifeq ($(V),0)
+       ARCHIVE = @echo " AR $@ (add/update: $?)";
+endif
+ARCHIVE += $(AR) -cru $@ $?;
+
+ifeq ($(V),0)
+       COMPILE = @echo " CC $@";
+endif
+COMPILE += $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<;
+
+ifeq ($(V),0)
+       COMPILE_EXEC = @echo " CC $@";
+endif
+COMPILE_EXEC += $(GCC) $(CFLAGS) $(CPPFLAGS) -o $@ $< $(LDFLAGS);
+
+ifeq ($(V),0)
+       LINK_EXEC = @echo " LD $@";
+endif
+LINK_EXEC += $(GCC) $(LDFLAGS) -o $@ $^ $(LIBFLAGS);
+
+ifeq ($(V),0)
+       LINK_LIB = @echo " LD $@" \
+              "($(patsubst %.so.$(VERSION_RELEASE),%.so.$(VERSION_MAJOR),$@))";
+endif
+LINK_LIB += $(GCC) $(LDFLAGS) -o $@ $^ -shared \
+       -Wl,-soname=$(patsubst %.so.$(VERSION_RELEASE),%.so.$(VERSION_MAJOR),$@)
 
 #
 # install macros
 #
 
-INSTALL_MACRO = \
-       @install_func() { \
-               dir="$$1"; \
-               if [[ -n "$$3" ]]; then \
-                       $(ECHO) " INSTALL $$3"; \
-               else \
-                       $(ECHO) " INSTALL $$2 ($$dir/$$2)"; \
-               fi; \
-               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
-                       -d "$$dir"; \
-               $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
-                       $$2 "$$dir"; \
-       }; \
-       install_func
+ifeq ($(V),0)
+       INSTALL_MACRO = \
+         @echo " INSTALL $$(cat /proc/$$$$/cmdline | awk '{print $$(NF-1)}')" \
+          " ($$(cat /proc/$$$$/cmdline | awk '{print $$NF}'))";
+endif
+INSTALL_MACRO += \
+       $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644
 
-INSTALL_SBIN_MACRO = \
-       @install_sbin_func() { \
-               dir="$(INSTALL_SBIN_DIR)"; \
-               if [[ -n "$$2" ]]; then \
-                       $(ECHO) " INSTALL $$2"; \
-               else \
-                       $(ECHO) " INSTALL $^ ($$dir/$^)"; \
-               fi; \
+ifeq ($(V),0)
+       INSTALL_SBIN_MACRO = @echo " INSTALL $^ ($(INSTALL_SBIN_DIR))";
+endif
+INSTALL_SBIN_MACRO += \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
-                       -d "$$dir"; \
+                       -d "$(INSTALL_SBIN_DIR)"; \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
-                       $^ "$$dir"; \
-       }; \
-       install_sbin_func
+                       $^ "$(INSTALL_SBIN_DIR)"; \
 
-INSTALL_BIN_MACRO = \
-       @install_bin_func() { \
-               dir="$(INSTALL_BIN_DIR)"; \
-               if [[ -n "$$2" ]]; then \
-                       $(ECHO) " INSTALL $$2"; \
-               else \
-                       $(ECHO) " INSTALL $^ ($$dir/$^)"; \
-               fi; \
+ifeq ($(V),0)
+       INSTALL_BIN_MACRO = @echo " INSTALL $^ ($(INSTALL_BIN_DIR))";
+endif
+INSTALL_BIN_MACRO += \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
-                       -d "$$dir"; \
+                       -d "$(INSTALL_BIN_DIR)"; \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
-                       $^ "$$dir"; \
-       }; \
-       install_bin_func
+                       $^ "$(INSTALL_BIN_DIR)"; \
+
 
 INSTALL_LIB_MACRO = \
        @install_lib_func() { \
@@ -178,35 +179,23 @@ INSTALL_LIB_MACRO = \
        }; \
        install_lib_func
 
-INSTALL_INC_MACRO = \
-       @install_inc_func() { \
-               dir="$(INSTALL_INC_DIR)"; \
-               if [[ -n "$$2" ]]; then \
-                       $(ECHO) " INSTALL $$2"; \
-               else \
-                       $(ECHO) " INSTALL $^ ($$dir/$^)"; \
-               fi; \
+ifeq ($(V),0)
+       INSTALL_INC_MACRO = @echo " INSTALL $^ ($(INSTALL_INC_DIR))";
+endif
+INSTALL_INC_MACRO += \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
-                       -d "$$dir"; \
+                       -d "$(INSTALL_INC_DIR)"; \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
-                       $^ "$$dir"; \
-       }; \
-       install_inc_func
+                       $^ "$(INSTALL_INC_DIR)"; \
 
-INSTALL_MAN_MACRO = \
-       @install_man_func() { \
-               dir="$(INSTALL_MAN_DIR)"/"$$1"; \
-               if [[ -n "$$2" ]]; then \
-                       $(ECHO) " INSTALL $$2"; \
-               else \
-                       $(ECHO) " INSTALL $^ ($$dir/$^)"; \
-               fi; \
+ifeq ($(V),0)
+       INSTALL_MAN3_MACRO = @echo " INSTALL manpages 
($(INSTALL_MAN_DIR)/man3)";
+endif
+INSTALL_MAN3_MACRO += \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) \
-                       -d "$$dir"; \
+                       -d "$(INSTALL_MAN_DIR)/man3"; \
                $(INSTALL) -o $(INSTALL_OWNER) -g $(INSTALL_GROUP) -m 0644 \
-                       $^ "$$dir"; \
-       }; \
-       install_man_func
+                       $^ "$(INSTALL_MAN_DIR)/man3"; \
 
 #
 # default build targets
diff --git a/src/Makefile b/src/Makefile
index e826bcf..801e814 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -64,4 +64,4 @@ install: $(LIB_SHARED)
        $(INSTALL_LIB_MACRO)
 
 clean:
-       $(RM) -f $(DEPS) $(OBJS) $(LIB_STATIC) $(LIB_SHARED)
+       $(RM) $(DEPS) $(OBJS) $(LIB_STATIC) $(LIB_SHARED)
diff --git a/tests/Makefile b/tests/Makefile
index 99cba86..a356eb3 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -72,4 +72,4 @@ $(TESTS):
        $(COMPILE_EXEC)
 
 clean:
-       $(RM) -f $(DEPS_TESTS) $(DEPS_OBJS) $(TESTS) $(OBJS)
+       $(RM) $(DEPS_TESTS) $(DEPS_OBJS) $(TESTS) $(OBJS)
diff --git a/tools/Makefile b/tools/Makefile
index 6d12196..bc056d0 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -53,4 +53,4 @@ $(TOOLS):
        $(COMPILE_EXEC)
 
 clean:
-       $(RM) -f $(DEPS) $(TOOLS)
+       $(RM) $(DEPS) $(TOOLS)


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