From: Andre Noll Date: Sat, 5 Aug 2017 22:55:50 +0000 (+0200) Subject: build: Use .ONESHELL. X-Git-Tag: v0.6.3~39^2 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=ece3b9ff875a28473a4f840bb016f8debb2531fc;p=paraslash.git build: Use .ONESHELL. This instructs "make" to pass all the lines in the recipe to a single invocation of the shell. This has no disadvantage and improves performance slightly. Best out of five "make -j 4" runs: Before: 0m3.510s After: 0m3.280s Speedup: 6.55% With .ONESHELL given, only the first line of each recipe will be checked for the special '@' prefix character. This made it necessary to modify the "Q" macro slightly. Rename it to "SAY" while at it. The second issue with .ONESHELL is that a failure of any but the final recipe line will not be noticed by make. To work around this, we set .SHELLFLAGS to '-ec'. The '-e' flag instructs the shell to exit at any failure anywhere in the command line. --- diff --git a/Makefile.real b/Makefile.real index dae48f0e..c8d30aae 100644 --- a/Makefile.real +++ b/Makefile.real @@ -6,6 +6,8 @@ MAKEFLAGS += -Rr ifeq ("$(origin CC)", "default") CC := cc endif +.ONESHELL: +.SHELLFLAGS := -ec LOGLEVELS := LL_DEBUG,LL_INFO,LL_NOTICE,LL_WARNING,LL_ERROR,LL_CRIT,LL_EMERG vardir := /var/paraslash @@ -102,7 +104,7 @@ endif $(object_dir) $(man_dir) $(dep_dir) $(m4depdir) $(lls_suite_dir) \ $(yy_build_dir): - $(Q) $(MKDIR_P) $@ + @$(MKDIR_P) $@ CPPFLAGS += -DBINDIR='"$(bindir)"' CPPFLAGS += -DCOPYRIGHT_YEAR='"$(COPYRIGHT_YEAR)"' @@ -149,9 +151,9 @@ STRICT_CFLAGS += $(call cc-option, -Wdiscarded-qualifiers) # To put more focus on warnings, be less verbose as default # Use 'make V=1' to see the full commands ifeq ("$(origin V)", "command line") - Q := + SAY = else - Q := @ + SAY = @echo '$(strip $(1))' endif audiod_commands := $(addprefix $(lls_suite_dir)/, \ @@ -178,9 +180,9 @@ $(man_dir)/para_write.1: all_commands := $(write_commands) $(man_dir)/para_%.1: $(lls_suite_dir)/%.lsg.man \ $(lls_m4_dir)/copyright.m4 | $(man_dir) - @[ -z "$(Q)" ] || echo 'LLSMAN $<' - $(Q) cat $< $(all_commands) > $@ - $(Q) $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@ + $(call SAY, LLSMAN $<) + cat $< $(all_commands) > $@ + $(M4) -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) $(lls_m4_dir)/copyright.m4 >> $@ $(object_dir)/%.o: %.c | $(object_dir) @@ -248,8 +250,8 @@ $(object_dir)/mm.o \ $(object_dir)/compress_filter.o: CFLAGS += -O3 $(object_dir)/%.o: %.c | $(object_dir) $(dep_dir) $(lsg_h) $(yy_h) - @[ -z "$(Q)" ] || echo 'CC $<' - $(Q) $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \ + $(call SAY, CC $<) + $(CC) -c -o $@ -MMD -MF $(dep_dir)/$(*F).d -MT $@ $(CPPFLAGS) \ $(STRICT_CFLAGS) $(CFLAGS) $< para_recv para_afh para_play para_server: LDFLAGS += $(id3tag_ldflags) @@ -314,24 +316,24 @@ para_afh para_recv para_server para_play: LDFLAGS += $(iconv_ldflags) $(foreach exe,$(executables),$(eval para_$(exe): $$($(exe)_objs))) $(prefixed_executables): - @[ -z "$(Q)" ] || echo 'LD $@' - $(Q) $(CC) $^ -o $@ $(LDFLAGS) + $(call SAY, LD $@) + $(CC) $^ -o $@ $(LDFLAGS) mostlyclean: - @[ -z "$(Q)" ] || echo 'MOSTLYCLEAN' - $(Q) rm -f para_* - $(Q) rm -rf $(object_dir) + $(call SAY, MOSTLYCLEAN) + rm -f para_* + rm -rf $(object_dir) clean: mostlyclean - @[ -z "$(Q)" ] || echo 'CLEAN' - $(Q) rm -rf $(build_dir) + $(call SAY, CLEAN) + rm -rf $(build_dir) distclean: clean - @[ -z "$(Q)" ] || echo 'DISTCLEAN' - $(Q) rm -f Makefile autoscan.log config.status config.log - $(Q) rm -f config.h configure config.h.in + $(call SAY, DISTCLEAN) + rm -f Makefile autoscan.log config.status config.log + rm -f config.h configure config.h.in maintainer-clean: distclean - @[ -z "$(Q)" ] || echo 'MAINTAINER-CLEAN' - $(Q) rm -f *.tar.bz2 *.tar.xz - $(Q) rm -f GPATH GRTAGS GSYMS GTAGS + $(call SAY, MAINTAINER-CLEAN) + rm -f *.tar.bz2 *.tar.xz + rm -f GPATH GRTAGS GSYMS GTAGS INSTALL ?= install INSTALL_PROGRAM ?= $(INSTALL) @@ -347,14 +349,15 @@ install install-strip: all man $(MKDIR_P) $(DESTDIR)$(vardir) >/dev/null 2>&1 || true # not fatal, so don't complain $(tarball) dist tarball: - $(Q) rm -rf $(tarball) $(tarball_pfx) - $(Q) git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \ - | tar --delete $(tarball_delete) > $(tarball_pfx).tar - $(Q) $(MKDIR_P) $(tarball_pfx) - $(Q) ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION - $(Q) cp $(autocrap) $(tarball_pfx) - $(Q) tar rf $(tarball_pfx).tar $(tarball_pfx)/* - $(Q) xz -9 $(tarball_pfx).tar - $(Q) ls -l $(tarball) - $(Q) ln -sf $(tarball) paraslash-git.tar.xz - $(Q) rm -rf $(tarball_pfx) + $(call SAY, DIST) + rm -rf $(tarball) $(tarball_pfx) + git archive --format=tar --prefix=$(tarball_pfx)/ HEAD \ + | tar --delete $(tarball_delete) > $(tarball_pfx).tar + $(MKDIR_P) $(tarball_pfx) + ./GIT-VERSION-GEN > $(tarball_pfx)/VERSION + cp $(autocrap) $(tarball_pfx) + tar rf $(tarball_pfx).tar $(tarball_pfx)/* + xz -9 $(tarball_pfx).tar + ls -l $(tarball) + ln -sf $(tarball) paraslash-git.tar.xz + rm -rf $(tarball_pfx) diff --git a/m4/lls/makefile b/m4/lls/makefile index dd86b51d..daf6de92 100644 --- a/m4/lls/makefile +++ b/m4/lls/makefile @@ -2,29 +2,29 @@ lls_m4_include_dir := $(lls_m4_dir)/include $(lls_suite_dir)/%.m4d: $(lls_m4_dir)/%.suite.m4 | $(lls_suite_dir) - @[ -z "$(Q)" ] || echo 'M4D $<' - $(Q) $(M4) -Pg -I $(lls_m4_include_dir) -s $< \ + $(call SAY, M4D $<) + $(M4) -Pg -I $(lls_m4_include_dir) -s $< \ | awk '{if ($$1 ~ /#line/) {gsub(/"/, "", $$3); if ($$3 != "$<") \ print "$(lls_suite_dir)/$(*F).suite: " $$3}}' | sort | uniq > $@ $(lls_suite_dir)/%.suite: $(lls_m4_dir)/%.suite.m4 | $(lls_suite_dir) - @[ -z "$(Q)" ] || echo 'M4 $<' - $(Q) $(M4) -Pg -I $(lls_m4_include_dir) -D GIT_VERSION=$(GIT_VERSION) \ + $(call SAY, M4 $<) + $(M4) -Pg -I $(lls_m4_include_dir) -D GIT_VERSION=$(GIT_VERSION) \ -D COPYRIGHT_YEAR=$(COPYRIGHT_YEAR) -D LOGLEVELS=$(LOGLEVELS) \ $< > $@ $(lls_suite_dir)/%.lsg.c: $(lls_suite_dir)/%.suite - @[ -z "$(Q)" ] || echo 'LSGC $<' - $(Q) $(LOPSUBGEN) --gen-c --output-dir $(lls_suite_dir) < $< + $(call SAY, LSGC $<) + $(LOPSUBGEN) --gen-c --output-dir $(lls_suite_dir) < $< $(lls_suite_dir)/%.lsg.h: $(lls_suite_dir)/%.suite - @[ -z "$(Q)" ] || echo 'LSGH $<' - $(Q) $(LOPSUBGEN) --gen-header --output-dir $(lls_suite_dir) < $< + $(call SAY, LSGH $<) + $(LOPSUBGEN) --gen-header --output-dir $(lls_suite_dir) < $< $(lls_suite_dir)/%.lsg.man: $(lls_suite_dir)/%.suite - @[ -z "$(Q)" ] || echo 'LSGM $<' - $(Q) $(LOPSUBGEN) --gen-man --output-dir $(lls_suite_dir) < $< + $(call SAY, LSGM $<) + $(LOPSUBGEN) --gen-man --output-dir $(lls_suite_dir) < $< $(object_dir)/%.o: $(lls_suite_dir)/%.c | $(object_dir) - @[ -z "$(Q)" ] || echo 'CC $<' - $(Q) $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $< + $(call SAY, CC $<) + $(CC) -c -o $@ $(CPPFLAGS) $(STRICT_CFLAGS) $< diff --git a/t/makefile.test b/t/makefile.test index a71963c9..904c7793 100644 --- a/t/makefile.test +++ b/t/makefile.test @@ -22,10 +22,11 @@ check: $(tests) test: $(tests) $(tests): all - $(Q) $@ $(test_options) + $(call SAY, $(@)) + $@ $(test_options) test-help: - $(Q) for t in $(tests); do $$t $(test_options) -h; done + @for t in $(tests); do $$t $(test_options) -h; done test-clean: $(RM) -r $(results_dir)