Skip to content

Commit 74f2b2a

Browse files
spearceJunio C Hamano
authored andcommitted
Make 'make' quieter while building git
I find it difficult to see compiler warnings amongst the massive spewing produced by GNU make as it works through our productions. This is especially true if CFLAGS winds up being rather long, due to a large number of -W options being enabled and due to a number of -D options being configured/required by my platform. By defining QUIET_MAKE (e.g. make QUIET_MAKE=YesPlease) during compilation users will get a less verbose output, such as: ... CC builtin-grep.c builtin-grep.c:187: warning: 'external_grep' defined but not used CC builtin-init-db.c CC builtin-log.c CC builtin-ls-files.c CC builtin-ls-tree.c ... The verbose (normal make) output is still the default. Signed-off-by: Shawn O. Pearce <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent ba66c58 commit 74f2b2a

File tree

3 files changed

+62
-42
lines changed

3 files changed

+62
-42
lines changed

Makefile

Lines changed: 49 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# The default target of this Makefile is...
22
all::
33

4+
# Define QUIET_MAKE to have a less verbose compile.
5+
#
46
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
57
# This also implies MOZILLA_SHA1.
68
#
@@ -602,6 +604,19 @@ endif
602604
ifdef NO_PERL_MAKEMAKER
603605
export NO_PERL_MAKEMAKER
604606
endif
607+
ifdef QUIET_MAKE
608+
QUIET_CC = @echo ' ' CC $<;
609+
QUIET_AR = @echo ' ' AR $@;
610+
QUIET_LINK = @echo ' ' LINK $@;
611+
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
612+
QUIET_GEN = @echo ' ' GEN $@;
613+
QUIET_SUBDIR0 = @subdir=
614+
QUIET_SUBDIR1 = ;echo ' ' SUBDIR $$subdir; $(MAKE) -C$$subdir
615+
export QUIET_MAKE
616+
else
617+
QUIET_SUBDIR0 = $(MAKE) -C
618+
QUIET_SUBDIR1 =
619+
endif
605620

606621
# Shell quote (do not use $(call) to accommodate ancient setups);
607622

@@ -637,35 +652,34 @@ ifneq (,$X)
637652
endif
638653

639654
all::
640-
$(MAKE) -C git-gui all
641-
$(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
642-
$(MAKE) -C templates
655+
$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
656+
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
657+
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)
643658

644659
strip: $(PROGRAMS) git$X
645660
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X
646661

647662
git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS
648-
$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
663+
$(QUIET_LINK)$(CC) -DGIT_VERSION='"$(GIT_VERSION)"' \
649664
$(ALL_CFLAGS) -o $@ $(filter %.c,$^) \
650665
$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)
651666

652667
help.o: common-cmds.h
653668

654669
$(BUILT_INS): git$X
655-
rm -f $@ && ln git$X $@
670+
$(QUIET_BUILT_IN)rm -f $@ && ln git$X $@
656671

657672
common-cmds.h: Documentation/git-*.txt
658-
./generate-cmdlist.sh > $@+
659-
mv $@+ $@
673+
$(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@
660674

661675
$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
662-
rm -f $@ $@+
676+
$(QUIET_GEN)rm -f $@ $@+ && \
663677
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
664678
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
665679
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
666680
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
667-
$@.sh >$@+
668-
chmod +x $@+
681+
$@.sh >$@+ && \
682+
chmod +x $@+ && \
669683
mv $@+ $@
670684

671685
$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak
@@ -674,7 +688,7 @@ perl/perl.mak: GIT-CFLAGS
674688
$(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
675689

676690
$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
677-
rm -f $@ $@+
691+
$(QUIET_GEN)rm -f $@ $@+ && \
678692
INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
679693
sed -e '1{' \
680694
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
@@ -685,20 +699,18 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
685699
-e '}' \
686700
-e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
687701
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
688-
$@.perl >$@+
689-
chmod +x $@+
702+
$@.perl >$@+ && \
703+
chmod +x $@+ && \
690704
mv $@+ $@
691705

692706
git-cherry-pick: git-revert
693-
cp $< $@+
694-
mv $@+ $@
707+
$(QUIET_GEN)cp $< $@+ && mv $@+ $@
695708

696709
git-status: git-commit
697-
cp $< $@+
698-
mv $@+ $@
710+
$(QUIET_GEN)cp $< $@+ && mv $@+ $@
699711

700712
gitweb/gitweb.cgi: gitweb/gitweb.perl
701-
rm -f $@ $@+
713+
$(QUIET_GEN)rm -f $@ $@+ && \
702714
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
703715
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
704716
-e 's|++GIT_BINDIR++|$(bindir)|g' \
@@ -716,28 +728,28 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
716728
-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
717729
-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
718730
-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
719-
$< >$@+
720-
chmod +x $@+
731+
$< >$@+ && \
732+
chmod +x $@+ && \
721733
mv $@+ $@
722734

723735
git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
724-
rm -f $@ $@+
736+
$(QUIET_GEN)rm -f $@ $@+ && \
725737
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
726738
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
727739
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
728740
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
729741
-e '/@@GITWEB_CGI@@/d' \
730742
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
731743
-e '/@@GITWEB_CSS@@/d' \
732-
$@.sh > $@+
733-
chmod +x $@+
744+
$@.sh > $@+ && \
745+
chmod +x $@+ && \
734746
mv $@+ $@
735747

736748
configure: configure.ac
737-
rm -f $@ $<+
749+
$(QUIET_GEN)rm -f $@ $<+ && \
738750
sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
739-
$< > $<+
740-
autoconf -o $@ $<+
751+
$< > $<+ && \
752+
autoconf -o $@ $<+ && \
741753
rm -f $<+
742754

743755
# These can record GIT_VERSION
@@ -747,25 +759,25 @@ git$X git.spec \
747759
: GIT-VERSION-FILE
748760

749761
%.o: %.c GIT-CFLAGS
750-
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
762+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
751763
%.o: %.S
752-
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
764+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
753765

754766
exec_cmd.o: exec_cmd.c GIT-CFLAGS
755-
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
767+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
756768
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
757-
$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
769+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
758770

759771
http.o: http.c GIT-CFLAGS
760-
$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
772+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
761773

762774
ifdef NO_EXPAT
763775
http-fetch.o: http-fetch.c http.h GIT-CFLAGS
764-
$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
776+
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
765777
endif
766778

767779
git-%$X: %.o $(GITLIBS)
768-
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
780+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
769781

770782
ssh-pull.o: ssh-fetch.c
771783
ssh-push.o: ssh-upload.c
@@ -779,27 +791,27 @@ git-imap-send$X: imap-send.o $(LIB_FILE)
779791

780792
http.o http-fetch.o http-push.o: http.h
781793
git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
782-
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
794+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
783795
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
784796

785797
git-http-push$X: revision.o http.o http-push.o $(GITLIBS)
786-
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
798+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
787799
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)
788800

789801
$(LIB_OBJS) $(BUILTIN_OBJS) fetch.o: $(LIB_H)
790802
$(patsubst git-%$X,%.o,$(PROGRAMS)): $(LIB_H) $(wildcard */*.h)
791803
$(DIFF_OBJS): diffcore.h
792804

793805
$(LIB_FILE): $(LIB_OBJS)
794-
rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
806+
$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
795807

796808
XDIFF_OBJS=xdiff/xdiffi.o xdiff/xprepare.o xdiff/xutils.o xdiff/xemit.o \
797809
xdiff/xmerge.o
798810
$(XDIFF_OBJS): xdiff/xinclude.h xdiff/xmacros.h xdiff/xdiff.h xdiff/xtypes.h \
799811
xdiff/xutils.h xdiff/xprepare.h xdiff/xdiffi.h xdiff/xemit.h
800812

801813
$(XDIFF_LIB): $(XDIFF_OBJS)
802-
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
814+
$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
803815

804816

805817
perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS

perl/Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ makfile:=perl.mak
66
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
77
prefix_SQ = $(subst ','\'',$(prefix))
88

9+
ifdef QUIET_MAKE
10+
QUIET = @
11+
endif
12+
913
all install instlibdir: $(makfile)
10-
$(MAKE) -f $(makfile) $@
14+
$(QUIET)$(MAKE) -f $(makfile) $@
1115

1216
clean:
13-
test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0
17+
$(QUIET)test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0
1418
$(RM) ppport.h
1519
$(RM) $(makfile)
1620
$(RM) $(makfile).old

templates/Makefile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# make and install sample templates
22

3+
ifdef QUIET_MAKE
4+
QUIET = @
5+
endif
6+
37
INSTALL ?= install
48
TAR ?= tar
59
prefix ?= $(HOME)
@@ -18,7 +22,7 @@ all: boilerplates.made custom
1822

1923
bpsrc = $(filter-out %~,$(wildcard *--*))
2024
boilerplates.made : $(bpsrc)
21-
ls *--* 2>/dev/null | \
25+
$(QUIET)ls *--* 2>/dev/null | \
2226
while read boilerplate; \
2327
do \
2428
case "$$boilerplate" in *~) continue ;; esac && \
@@ -29,13 +33,13 @@ boilerplates.made : $(bpsrc)
2933
*--) ;; \
3034
*) cp $$boilerplate blt/$$dst ;; \
3135
esac || exit; \
32-
done || exit
36+
done && \
3337
date >$@
3438

3539
# If you need build-tailored templates, build them into blt/
3640
# directory yourself here.
3741
custom:
38-
: no custom templates yet
42+
$(QUIET): no custom templates yet
3943

4044
clean:
4145
rm -rf blt boilerplates.made

0 commit comments

Comments
 (0)