Skip to content

Commit

Permalink
Merge branch 'sp/make'
Browse files Browse the repository at this point in the history
* sp/make:
  Allow "make -w" generate its usual output
  Support of "make -s": do not output anything of the build itself
  More build output cleaning up
  Make 'make' quiet by default
  Make 'make' quieter while building git
  • Loading branch information
Junio C Hamano committed Mar 11, 2007
2 parents ed287ab + a6f3709 commit 5339fb2
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 44 deletions.
100 changes: 62 additions & 38 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# The default target of this Makefile is...
all::

# Define V=1 to have a more verbose compile.
#
# Define NO_OPENSSL environment variable if you do not have OpenSSL.
# This also implies MOZILLA_SHA1.
#
Expand Down Expand Up @@ -603,6 +605,31 @@ ifdef NO_PERL_MAKEMAKER
export NO_PERL_MAKEMAKER
endif

QUIET_SUBDIR0 = $(MAKE) -C # space to separate -C and subdir
QUIET_SUBDIR1 =

ifneq ($(findstring $(MAKEFLAGS),w),w)
PRINT_DIR = --no-print-directory
else # "make -w"
NO_SUBDIR = :
endif

ifneq ($(findstring $(MAKEFLAGS),s),s)
ifndef V
QUIET_CC = @echo ' ' CC $@;
QUIET_AR = @echo ' ' AR $@;
QUIET_LINK = @echo ' ' LINK $@;
QUIET_BUILT_IN = @echo ' ' BUILTIN $@;
QUIET_GEN = @echo ' ' GEN $@;
QUIET_SUBDIR0 = @subdir=
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
$(MAKE) $(PRINT_DIR) -C $$subdir
export V
export QUIET_GEN
export QUIET_BUILT_IN
endif
endif

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

SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER))
Expand Down Expand Up @@ -637,44 +664,43 @@ ifneq (,$X)
endif

all::
$(MAKE) -C git-gui all
$(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
$(MAKE) -C templates
$(QUIET_SUBDIR0)git-gui $(QUIET_SUBDIR1) all
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' all
$(QUIET_SUBDIR0)templates $(QUIET_SUBDIR1)

strip: $(PROGRAMS) git$X
$(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X

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

help.o: common-cmds.h

$(BUILT_INS): git$X
rm -f $@ && ln git$X $@
$(QUIET_BUILT_IN)rm -f $@ && ln git$X $@

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

$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh
rm -f $@ $@+
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
$@.sh >$@+
chmod +x $@+
$@.sh >$@+ && \
chmod +x $@+ && \
mv $@+ $@

$(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak

perl/perl.mak: GIT-CFLAGS
$(MAKE) -C perl PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)
$(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F)

$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
rm -f $@ $@+
$(QUIET_GEN)rm -f $@ $@+ && \
INSTLIBDIR=`$(MAKE) -C perl -s --no-print-directory instlibdir` && \
sed -e '1{' \
-e ' s|#!.*perl|#!$(PERL_PATH_SQ)|' \
Expand All @@ -685,20 +711,18 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl
-e '}' \
-e 's|@@INSTLIBDIR@@|'"$$INSTLIBDIR"'|g' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
$@.perl >$@+
chmod +x $@+
$@.perl >$@+ && \
chmod +x $@+ && \
mv $@+ $@

git-cherry-pick: git-revert
cp $< $@+
mv $@+ $@
$(QUIET_GEN)cp $< $@+ && mv $@+ $@

git-status: git-commit
cp $< $@+
mv $@+ $@
$(QUIET_GEN)cp $< $@+ && mv $@+ $@

gitweb/gitweb.cgi: gitweb/gitweb.perl
rm -f $@ $@+
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*perl|#!$(PERL_PATH_SQ)|' \
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
-e 's|++GIT_BINDIR++|$(bindir)|g' \
Expand All @@ -716,28 +740,28 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
-e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
-e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
-e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
$< >$@+
chmod +x $@+
$< >$@+ && \
chmod +x $@+ && \
mv $@+ $@

git-instaweb: git-instaweb.sh gitweb/gitweb.cgi gitweb/gitweb.css
rm -f $@ $@+
$(QUIET_GEN)rm -f $@ $@+ && \
sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
-e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
-e 's/@@NO_CURL@@/$(NO_CURL)/g' \
-e '/@@GITWEB_CGI@@/r gitweb/gitweb.cgi' \
-e '/@@GITWEB_CGI@@/d' \
-e '/@@GITWEB_CSS@@/r gitweb/gitweb.css' \
-e '/@@GITWEB_CSS@@/d' \
$@.sh > $@+
chmod +x $@+
$@.sh > $@+ && \
chmod +x $@+ && \
mv $@+ $@

configure: configure.ac
rm -f $@ $<+
$(QUIET_GEN)rm -f $@ $<+ && \
sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \
$< > $<+
autoconf -o $@ $<+
$< > $<+ && \
autoconf -o $@ $<+ && \
rm -f $<+

# These can record GIT_VERSION
Expand All @@ -747,25 +771,25 @@ git$X git.spec \
: GIT-VERSION-FILE

%.o: %.c GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<
%.o: %.S
$(CC) -o $*.o -c $(ALL_CFLAGS) $<
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) $<

exec_cmd.o: exec_cmd.c GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<

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

ifdef NO_EXPAT
http-fetch.o: http-fetch.c http.h GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DNO_EXPAT $<
endif

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

ssh-pull.o: ssh-fetch.c
ssh-push.o: ssh-upload.c
Expand All @@ -779,27 +803,27 @@ git-imap-send$X: imap-send.o $(LIB_FILE)

http.o http-fetch.o http-push.o: http.h
git-http-fetch$X: fetch.o http.o http-fetch.o $(GITLIBS)
$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(LIBS) $(CURL_LIBCURL) $(EXPAT_LIBEXPAT)

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

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

$(LIB_FILE): $(LIB_OBJS)
rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)
$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(LIB_OBJS)

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

$(XDIFF_LIB): $(XDIFF_OBJS)
rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)
$(QUIET_AR)rm -f $@ && $(AR) rcs $@ $(XDIFF_OBJS)


perl/Makefile: perl/Git.pm perl/Makefile.PL GIT-CFLAGS
Expand Down
10 changes: 7 additions & 3 deletions perl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ makfile:=perl.mak
PERL_PATH_SQ = $(subst ','\'',$(PERL_PATH))
prefix_SQ = $(subst ','\'',$(prefix))

ifndef V
QUIET = @
endif

all install instlibdir: $(makfile)
$(MAKE) -f $(makfile) $@
$(QUIET)$(MAKE) -f $(makfile) $@

clean:
test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0
$(QUIET)test -f $(makfile) && $(MAKE) -f $(makfile) $@ || exit 0
$(RM) ppport.h
$(RM) $(makfile)
$(RM) $(makfile).old
Expand All @@ -29,7 +33,7 @@ $(makfile): ../GIT-CFLAGS Makefile
echo ' echo $(instdir_SQ)' >> $@
else
$(makfile): Makefile.PL ../GIT-CFLAGS
'$(PERL_PATH_SQ)' $< PREFIX='$(prefix_SQ)'
$(QUIET_GEN)'$(PERL_PATH_SQ)' $< PREFIX='$(prefix_SQ)'
endif

# this is just added comfort for calling make directly in perl dir
Expand Down
10 changes: 7 additions & 3 deletions templates/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# make and install sample templates

ifndef V
QUIET = @
endif

INSTALL ?= install
TAR ?= tar
prefix ?= $(HOME)
Expand All @@ -18,7 +22,7 @@ all: boilerplates.made custom

bpsrc = $(filter-out %~,$(wildcard *--*))
boilerplates.made : $(bpsrc)
ls *--* 2>/dev/null | \
$(QUIET)ls *--* 2>/dev/null | \
while read boilerplate; \
do \
case "$$boilerplate" in *~) continue ;; esac && \
Expand All @@ -29,13 +33,13 @@ boilerplates.made : $(bpsrc)
*--) ;; \
*) cp $$boilerplate blt/$$dst ;; \
esac || exit; \
done || exit
done && \
date >$@

# If you need build-tailored templates, build them into blt/
# directory yourself here.
custom:
: no custom templates yet
$(QUIET): no custom templates yet

clean:
rm -rf blt boilerplates.made
Expand Down

0 comments on commit 5339fb2

Please sign in to comment.