Pino Toscano
2016-Aug-04 14:21 UTC
[Libguestfs] [PATCH] build: add simple custom silent rules for automake
Add makefile variables to enable silent rules for simple command invocations, such as ocamlc, ocamlopt, javac, and erlc. This reduces the log output when building with silent rules, still showing the full command lines otherwise. --- erlang/Makefile.am | 2 +- java/Makefile.am | 6 +++--- ocaml/Makefile.am | 14 +++++++------- subdir-rules.mk | 20 +++++++++++++++++--- 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/erlang/Makefile.am b/erlang/Makefile.am index a9825f6..7dc0906 100644 --- a/erlang/Makefile.am +++ b/erlang/Makefile.am @@ -52,7 +52,7 @@ erlang_bin_DATA = guestfs.beam # The ./run script will set $ERL_LIBS to point to $(builddir)/erlang. # (See: http://www.erlang.org/doc/man/code.html) guestfs.beam: guestfs.erl - $(ERLC) +debug_info $^ + $(guestfs_am_v_erlc)$(ERLC) +debug_info $^ mkdir -p $(PACKAGE)-$(VERSION)/ebin cp $@ $(PACKAGE)-$(VERSION)/ebin diff --git a/java/Makefile.am b/java/Makefile.am index 0651fd3..8b6944d 100644 --- a/java/Makefile.am +++ b/java/Makefile.am @@ -79,7 +79,7 @@ libguestfs_jardir = $(JAR_INSTALL_DIR) libguestfs_jar_DATA = libguestfs-${VERSION}.jar libguestfs_jar_class_files = $(java_sources:.java=.class) $(libguestfs_jar_class_files): %.class: %.java - $(JAVAC) $(JAVAC_FLAGS) -d . -classpath $(srcdir):. $< + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -d . -classpath $(srcdir):. $< libguestfs-${VERSION}.jar: $(libguestfs_jar_class_files) $(JAR) cf $@ $^ @@ -140,9 +140,9 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test check_DATA = Bindtests.class $(java_tests:.java=.class) t/%.class: t/%.java libguestfs-$(VERSION).jar - $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d t $< + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d t $< Bindtests.class: Bindtests.java libguestfs-$(VERSION).jar - $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d . $< + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d . $< endif diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am index acbfad1..501ac69 100644 --- a/ocaml/Makefile.am +++ b/ocaml/Makefile.am @@ -158,12 +158,12 @@ check_DATA += bindtests.opt endif %.bc: %.cmo mlguestfs.cma - $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ + $(guestfs_am_v_ocamlc)$(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -I . -package unix -linkpkg mlguestfs.cma $< -o $@ if HAVE_OCAMLOPT %.opt: %.cmx mlguestfs.cmxa - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@ + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@ endif check-valgrind: @@ -173,16 +173,16 @@ CLEANFILES += bindtests.tmp # Dependencies. %.cmi: %.mli - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ guestfs.cmo: guestfs.ml - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ %.cmo: %.ml mlguestfs.cma - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ if HAVE_OCAMLOPT guestfs.cmx: guestfs.ml - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ %.cmx: %.ml mlguestfs.cmxa - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ endif depend: .depend diff --git a/subdir-rules.mk b/subdir-rules.mk index 39c2f50..d6aaba7 100644 --- a/subdir-rules.mk +++ b/subdir-rules.mk @@ -56,11 +56,25 @@ MLARCHIVE = cmxa BEST = opt endif +# custom silent rules +guestfs_am_v_ocamlc = $(guestfs_am_v_ocamlc_@AM_V@) +guestfs_am_v_ocamlc_ = $(guestfs_am_v_ocamlc_@AM_DEFAULT_V@) +guestfs_am_v_ocamlc_0 = @echo " OCAMLC " $@; +guestfs_am_v_ocamlopt = $(guestfs_am_v_ocamlopt_@AM_V@) +guestfs_am_v_ocamlopt_ = $(guestfs_am_v_ocamlopt_@AM_DEFAULT_V@) +guestfs_am_v_ocamlopt_0 = @echo " OCAMLOPT " $@; +guestfs_am_v_javac = $(guestfs_am_v_javac_@AM_V@) +guestfs_am_v_javac_ = $(guestfs_am_v_javac_@AM_DEFAULT_V@) +guestfs_am_v_javac_0 = @echo " JAVAC " $@; +guestfs_am_v_erlc = $(guestfs_am_v_erlc_@AM_V@) +guestfs_am_v_erlc_ = $(guestfs_am_v_erlc_@AM_DEFAULT_V@) +guestfs_am_v_erlc_0 = @echo " ERLC " $@; + .mli.cmi: - $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ .ml.cmo: - $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ if HAVE_OCAMLOPT .ml.cmx: - $(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ endif -- 2.7.4
Richard W.M. Jones
2016-Aug-04 14:26 UTC
Re: [Libguestfs] [PATCH] build: add simple custom silent rules for automake
On Thu, Aug 04, 2016 at 04:21:51PM +0200, Pino Toscano wrote:> Add makefile variables to enable silent rules for simple command > invocations, such as ocamlc, ocamlopt, javac, and erlc. > > This reduces the log output when building with silent rules, still > showing the full command lines otherwise. > --- > erlang/Makefile.am | 2 +- > java/Makefile.am | 6 +++--- > ocaml/Makefile.am | 14 +++++++------- > subdir-rules.mk | 20 +++++++++++++++++--- > 4 files changed, 28 insertions(+), 14 deletions(-) > > diff --git a/erlang/Makefile.am b/erlang/Makefile.am > index a9825f6..7dc0906 100644 > --- a/erlang/Makefile.am > +++ b/erlang/Makefile.am > @@ -52,7 +52,7 @@ erlang_bin_DATA = guestfs.beam > # The ./run script will set $ERL_LIBS to point to $(builddir)/erlang. > # (See: http://www.erlang.org/doc/man/code.html) > guestfs.beam: guestfs.erl > - $(ERLC) +debug_info $^ > + $(guestfs_am_v_erlc)$(ERLC) +debug_info $^ > mkdir -p $(PACKAGE)-$(VERSION)/ebin > cp $@ $(PACKAGE)-$(VERSION)/ebin > > diff --git a/java/Makefile.am b/java/Makefile.am > index 0651fd3..8b6944d 100644 > --- a/java/Makefile.am > +++ b/java/Makefile.am > @@ -79,7 +79,7 @@ libguestfs_jardir = $(JAR_INSTALL_DIR) > libguestfs_jar_DATA = libguestfs-${VERSION}.jar > libguestfs_jar_class_files = $(java_sources:.java=.class) > $(libguestfs_jar_class_files): %.class: %.java > - $(JAVAC) $(JAVAC_FLAGS) -d . -classpath $(srcdir):. $< > + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -d . -classpath $(srcdir):. $< > > libguestfs-${VERSION}.jar: $(libguestfs_jar_class_files) > $(JAR) cf $@ $^ > @@ -140,9 +140,9 @@ TESTS_ENVIRONMENT = $(top_builddir)/run --test > check_DATA = Bindtests.class $(java_tests:.java=.class) > > t/%.class: t/%.java libguestfs-$(VERSION).jar > - $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d t $< > + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d t $< > > Bindtests.class: Bindtests.java libguestfs-$(VERSION).jar > - $(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d . $< > + $(guestfs_am_v_javac)$(JAVAC) $(JAVAC_FLAGS) -classpath libguestfs-$(VERSION).jar -d . $< > > endif > diff --git a/ocaml/Makefile.am b/ocaml/Makefile.am > index acbfad1..501ac69 100644 > --- a/ocaml/Makefile.am > +++ b/ocaml/Makefile.am > @@ -158,12 +158,12 @@ check_DATA += bindtests.opt > endif > > %.bc: %.cmo mlguestfs.cma > - $(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ > + $(guestfs_am_v_ocamlc)$(top_builddir)/libtool -dlopen $(top_builddir)/src/.libs/libguestfs.la --mode=execute \ > $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -I . -package unix -linkpkg mlguestfs.cma $< -o $@ > > if HAVE_OCAMLOPT > %.opt: %.cmx mlguestfs.cmxa > - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@ > + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -cclib -L$(top_builddir)/src/.libs -I . -package unix -linkpkg mlguestfs.cmxa $< -o $@ > endif > > check-valgrind: > @@ -173,16 +173,16 @@ CLEANFILES += bindtests.tmp > > # Dependencies. > %.cmi: %.mli > - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > guestfs.cmo: guestfs.ml > - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > %.cmo: %.ml mlguestfs.cma > - $(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLCFLAGS) -package unix -c $< -o $@ > if HAVE_OCAMLOPT > guestfs.cmx: guestfs.ml > - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ > + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ > %.cmx: %.ml mlguestfs.cmxa > - $(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ > + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLOPTFLAGS) -package unix -c $< -o $@ > endif > > depend: .depend > diff --git a/subdir-rules.mk b/subdir-rules.mk > index 39c2f50..d6aaba7 100644 > --- a/subdir-rules.mk > +++ b/subdir-rules.mk > @@ -56,11 +56,25 @@ MLARCHIVE = cmxa > BEST = opt > endif > > +# custom silent rules > +guestfs_am_v_ocamlc = $(guestfs_am_v_ocamlc_@AM_V@) > +guestfs_am_v_ocamlc_ = $(guestfs_am_v_ocamlc_@AM_DEFAULT_V@) > +guestfs_am_v_ocamlc_0 = @echo " OCAMLC " $@; > +guestfs_am_v_ocamlopt = $(guestfs_am_v_ocamlopt_@AM_V@) > +guestfs_am_v_ocamlopt_ = $(guestfs_am_v_ocamlopt_@AM_DEFAULT_V@) > +guestfs_am_v_ocamlopt_0 = @echo " OCAMLOPT " $@; > +guestfs_am_v_javac = $(guestfs_am_v_javac_@AM_V@) > +guestfs_am_v_javac_ = $(guestfs_am_v_javac_@AM_DEFAULT_V@) > +guestfs_am_v_javac_0 = @echo " JAVAC " $@; > +guestfs_am_v_erlc = $(guestfs_am_v_erlc_@AM_V@) > +guestfs_am_v_erlc_ = $(guestfs_am_v_erlc_@AM_DEFAULT_V@) > +guestfs_am_v_erlc_0 = @echo " ERLC " $@; > + > .mli.cmi: > - $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > .ml.cmo: > - $(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > + $(guestfs_am_v_ocamlc)$(OCAMLFIND) ocamlc $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > if HAVE_OCAMLOPT > .ml.cmx: > - $(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > + $(guestfs_am_v_ocamlopt)$(OCAMLFIND) ocamlopt $(OCAMLFLAGS) $(OCAMLPACKAGES) -c $< -o $@ > endif > -- > 2.7.4ACK. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-df lists disk usage of guests without needing to install any software inside the virtual machine. Supports Linux and Windows. http://people.redhat.com/~rjones/virt-df/