[x264-devel] [PATCH 1/2] Add autotools-style silent build rules

Stephen Hutchinson qyot27 at gmail.com
Sat Apr 5 22:16:51 CEST 2014


From: Måns Rullgård <mans at mansr.com>

The V variable can be passed directly to make in order to
enable or disable the silent rules. V=0 (the default) turns
them on, anything other than zero turns them off.
---
 Makefile  | 43 +++++++++++++++++++++++++++++--------------
 configure |  3 +++
 2 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/Makefile b/Makefile
index a2bc0dc..c3e7ad5 100644
--- a/Makefile
+++ b/Makefile
@@ -2,6 +2,21 @@
 
 include config.mak
 
+# Silent make rules
+ifeq ($(V), 0)
+Q      = @
+ECHO   = printf "$(1)\t%s\n" $(2)
+BRIEF  = CC AS YASM AR LD STRIP CP RC
+SILENT = RM RANLIB
+
+MSG    = $@
+M      = @$(call ECHO,$(TAG),$@);
+$(foreach VAR,$(BRIEF), \
+    $(eval override $(VAR) = @$$(call ECHO,$(VAR),$$(MSG)); $($(VAR))))
+$(foreach VAR,$(SILENT),$(eval override $(VAR) = @$($(VAR))))
+$(eval INSTALL = @$(call ECHO,INSTALL,$$(^:$(SRC_DIR)/%=%)); $(INSTALL))
+endif
+
 vpath %.c $(SRCPATH)
 vpath %.h $(SRCPATH)
 vpath %.S $(SRCPATH)
@@ -164,7 +179,7 @@ lib-static: $(LIBX264)
 lib-shared: $(SONAME)
 
 $(LIBX264): $(GENERATED) .depend $(OBJS) $(OBJASM)
-	rm -f $(LIBX264)
+	$(RM) -f $(LIBX264)
 	$(AR)$@ $(OBJS) $(OBJASM)
 	$(if $(RANLIB), $(RANLIB) $@)
 
@@ -200,8 +215,8 @@ $(OBJS) $(OBJASM) $(OBJSO) $(OBJCLI) $(OBJCHK): .depend
 	$(RC) $(RCFLAGS)$@ $<
 
 .depend: config.mak
-	@rm -f .depend
-	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
+	@$(RM) -f .depend
+	@$(foreach SRC, $(addprefix $(SRCPATH)/, $(SRCS) $(SRCCLI) $(SRCSO)), $(CC_VERBOSE) $(CFLAGS) $(SRC) $(DEPMT) $(SRC:$(SRCPATH)/%.c=%.o) $(DEPMM) 1>> .depend;)
 
 config.mak:
 	./configure
@@ -232,18 +247,18 @@ fprofiled:
 	$(MAKE) clean
 	$(MAKE) x264$(EXE) CFLAGS="$(CFLAGS) $(PROF_GEN_CC)" LDFLAGS="$(LDFLAGS) $(PROF_GEN_LD)"
 	$(foreach V, $(VIDS), $(foreach I, 0 1 2 3 4 5 6 7, ./x264$(EXE) $(OPT$I) --threads 1 $(V) -o $(DEVNULL) ;))
-	rm -f $(SRC2:%.c=%.o)
+	$(RM) -f $(SRC2:%.c=%.o)
 	$(MAKE) CFLAGS="$(CFLAGS) $(PROF_USE_CC)" LDFLAGS="$(LDFLAGS) $(PROF_USE_LD)"
-	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
+	$(RM) -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
 endif
 
 clean:
-	rm -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
-	rm -f checkasm checkasm.exe $(OBJCHK) $(GENERATED) x264_lookahead.clbin
-	rm -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
+	$(RM) -f $(OBJS) $(OBJASM) $(OBJCLI) $(OBJSO) $(SONAME) *.a *.lib *.exp *.pdb x264 x264.exe .depend TAGS
+	$(RM) -f checkasm checkasm.exe $(OBJCHK) $(GENERATED) x264_lookahead.clbin
+	$(RM) -f $(SRC2:%.c=%.gcda) $(SRC2:%.c=%.gcno) *.dyn pgopti.dpi pgopti.dpi.lock
 
 distclean: clean
-	rm -f config.mak x264_config.h config.h config.log x264.pc x264.def
+	$(RM) -f config.mak x264_config.h config.h config.log x264.pc x264.def
 
 install-cli: cli
 	$(INSTALL) -d $(DESTDIR)$(bindir)
@@ -267,17 +282,17 @@ ifneq ($(IMPLIBNAME),)
 	$(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(bindir)
 	$(INSTALL) -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir)
 else ifneq ($(SONAME),)
-	ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
+	$(Q)ln -f -s $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
 	$(INSTALL) -m 755 $(SONAME) $(DESTDIR)$(libdir)
 endif
 
 uninstall:
-	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
-	rm -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
+	$(RM) -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
+	$(RM) -f $(DESTDIR)$(bindir)/x264$(EXE) $(DESTDIR)$(libdir)/pkgconfig/x264.pc
 ifneq ($(IMPLIBNAME),)
-	rm -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
+	$(RM) -f $(DESTDIR)$(bindir)/$(SONAME) $(DESTDIR)$(libdir)/$(IMPLIBNAME)
 else ifneq ($(SONAME),)
-	rm -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
+	$(RM) -f $(DESTDIR)$(libdir)/$(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX)
 endif
 
 etags: TAGS
diff --git a/configure b/configure
index 5401753..f99ec00 100755
--- a/configure
+++ b/configure
@@ -279,6 +279,7 @@ bit_depth="8"
 chroma_format="all"
 compiler="GNU"
 opencl="yes"
+V=0
 
 CFLAGS="$CFLAGS -Wall -I. -I\$(SRCPATH)"
 LDFLAGS="$LDFLAGS"
@@ -1156,6 +1157,7 @@ includedir=$includedir
 ARCH=$ARCH
 SYS=$SYS
 CC=$CC
+CC_VERBOSE=$CC
 CFLAGS=$CFLAGS
 DEPMM=$DEPMM
 DEPMT=$DEPMT
@@ -1178,6 +1180,7 @@ PROF_GEN_LD=$PROF_GEN_LD
 PROF_USE_CC=$PROF_USE_CC
 PROF_USE_LD=$PROF_USE_LD
 HAVE_OPENCL=$opencl
+V=$V
 EOF
 
 if [ $compiler = ICL ]; then
-- 
1.8.3.2



More information about the x264-devel mailing list