diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-07-15 21:39:17 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-07-15 21:39:17 -0700 |
commit | d06414b9ce66137a7c7464fbc6ce3512c51dc3de (patch) | |
tree | 40c3c40893dee7488ee58fad31da63e57581a461 | |
parent | Merge branch 'ar/clone-honor-umask-at-top' (diff) | |
parent | Makefile: document ground rules for target-specific dependencies (diff) | |
download | tgif-d06414b9ce66137a7c7464fbc6ce3512c51dc3de.tar.xz |
Merge branch 'jn/makefile-cleanup'
Tightens dependency rules to avoid unnecessary recompilation, and
cleans up our Makefile in general.
* jn/makefile-cleanup:
Makefile: document ground rules for target-specific dependencies
Makefile: move GIT-VERSION-FILE dependencies closer to use
Makefile: build instaweb similar to other scripts
Makefile: update scripts when build-time parameters change
Makefile: do not replace @@GIT_VERSION@@ in shell scripts
Makefile: split prefix flags from GIT-CFLAGS
Makefile: be silent when only GIT_USER_AGENT changes
Makefile: split GIT_USER_AGENT from GIT-CFLAGS
Makefile: do not replace @@GIT_USER_AGENT@@ in scripts
Makefile: apply dependencies consistently to sparse/asm targets
Makefile: do not have git.o depend on common-cmds.h
Makefile: fold XDIFF_H and VCSSVN_H into LIB_H
Makefile: fold MISC_H into LIB_H
Makefile: sort LIB_H list
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Makefile | 230 |
2 files changed, 131 insertions, 102 deletions
diff --git a/.gitignore b/.gitignore index c188d0b461..bb5c91e712 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,9 @@ /GIT-CFLAGS /GIT-LDFLAGS /GIT-GUI-VARS +/GIT-PREFIX +/GIT-SCRIPT-DEFINES +/GIT-USER-AGENT /GIT-VERSION-FILE /bin-wrappers/ /git @@ -397,12 +397,9 @@ BUILTIN_OBJS = BUILT_INS = COMPAT_CFLAGS = COMPAT_OBJS = -XDIFF_H = XDIFF_OBJS = -VCSSVN_H = VCSSVN_OBJS = -VCSSVN_TEST_OBJS = -MISC_H = +GENERATED_H = EXTRA_CPPFLAGS = LIB_H = LIB_OBJS = @@ -562,46 +559,38 @@ LIB_FILE=libgit.a XDIFF_LIB=xdiff/lib.a VCSSVN_LIB=vcs-svn/lib.a -XDIFF_H += xdiff/xinclude.h -XDIFF_H += xdiff/xmacros.h -XDIFF_H += xdiff/xdiff.h -XDIFF_H += xdiff/xtypes.h -XDIFF_H += xdiff/xutils.h -XDIFF_H += xdiff/xprepare.h -XDIFF_H += xdiff/xdiffi.h -XDIFF_H += xdiff/xemit.h - -VCSSVN_H += vcs-svn/line_buffer.h -VCSSVN_H += vcs-svn/sliding_window.h -VCSSVN_H += vcs-svn/repo_tree.h -VCSSVN_H += vcs-svn/fast_export.h -VCSSVN_H += vcs-svn/svndiff.h -VCSSVN_H += vcs-svn/svndump.h - -MISC_H += bisect.h -MISC_H += branch.h -MISC_H += bundle.h -MISC_H += common-cmds.h -MISC_H += fetch-pack.h -MISC_H += reachable.h -MISC_H += send-pack.h -MISC_H += shortlog.h -MISC_H += tar.h -MISC_H += thread-utils.h -MISC_H += url.h -MISC_H += walker.h -MISC_H += wt-status.h +LIB_H += xdiff/xinclude.h +LIB_H += xdiff/xmacros.h +LIB_H += xdiff/xdiff.h +LIB_H += xdiff/xtypes.h +LIB_H += xdiff/xutils.h +LIB_H += xdiff/xprepare.h +LIB_H += xdiff/xdiffi.h +LIB_H += xdiff/xemit.h + +LIB_H += vcs-svn/line_buffer.h +LIB_H += vcs-svn/sliding_window.h +LIB_H += vcs-svn/repo_tree.h +LIB_H += vcs-svn/fast_export.h +LIB_H += vcs-svn/svndiff.h +LIB_H += vcs-svn/svndump.h + +GENERATED_H += common-cmds.h LIB_H += advice.h LIB_H += archive.h LIB_H += argv-array.h LIB_H += attr.h +LIB_H += bisect.h LIB_H += blob.h +LIB_H += branch.h LIB_H += builtin.h LIB_H += bulk-checkin.h -LIB_H += cache.h +LIB_H += bundle.h LIB_H += cache-tree.h +LIB_H += cache.h LIB_H += color.h +LIB_H += column.h LIB_H += commit.h LIB_H += compat/bswap.h LIB_H += compat/cygwin.h @@ -623,6 +612,7 @@ LIB_H += diff.h LIB_H += diffcore.h LIB_H += dir.h LIB_H += exec_cmd.h +LIB_H += fetch-pack.h LIB_H += fmt-merge-msg.h LIB_H += fsck.h LIB_H += gettext.h @@ -632,6 +622,7 @@ LIB_H += graph.h LIB_H += grep.h LIB_H += hash.h LIB_H += help.h +LIB_H += http.h LIB_H += kwset.h LIB_H += levenshtein.h LIB_H += list-objects.h @@ -641,19 +632,20 @@ LIB_H += mailmap.h LIB_H += merge-file.h LIB_H += merge-recursive.h LIB_H += mergesort.h -LIB_H += notes.h LIB_H += notes-cache.h LIB_H += notes-merge.h +LIB_H += notes.h LIB_H += object.h -LIB_H += pack.h LIB_H += pack-refs.h LIB_H += pack-revindex.h +LIB_H += pack.h LIB_H += parse-options.h LIB_H += patch-ids.h LIB_H += pkt-line.h LIB_H += progress.h LIB_H += prompt.h LIB_H += quote.h +LIB_H += reachable.h LIB_H += reflog-walk.h LIB_H += refs.h LIB_H += remote.h @@ -661,9 +653,11 @@ LIB_H += rerere.h LIB_H += resolve-undo.h LIB_H += revision.h LIB_H += run-command.h +LIB_H += send-pack.h LIB_H += sequencer.h LIB_H += sha1-array.h LIB_H += sha1-lookup.h +LIB_H += shortlog.h LIB_H += sideband.h LIB_H += sigchain.h LIB_H += strbuf.h @@ -671,14 +665,18 @@ LIB_H += streaming.h LIB_H += string-list.h LIB_H += submodule.h LIB_H += tag.h +LIB_H += tar.h LIB_H += thread-utils.h LIB_H += transport.h -LIB_H += tree.h LIB_H += tree-walk.h +LIB_H += tree.h LIB_H += unpack-trees.h +LIB_H += url.h LIB_H += userdiff.h LIB_H += utf8.h LIB_H += varint.h +LIB_H += walker.h +LIB_H += wt-status.h LIB_H += xdiff-interface.h LIB_H += xdiff/xdiff.h @@ -1934,7 +1932,10 @@ endif GIT_USER_AGENT_SQ = $(subst ','\'',$(GIT_USER_AGENT)) GIT_USER_AGENT_CQ = "$(subst ",\",$(subst \,\\,$(GIT_USER_AGENT)))" GIT_USER_AGENT_CQ_SQ = $(subst ','\'',$(GIT_USER_AGENT_CQ)) -BASIC_CFLAGS += -DGIT_USER_AGENT='$(GIT_USER_AGENT_CQ_SQ)' +GIT-USER-AGENT: FORCE + @if test x'$(GIT_USER_AGENT_SQ)' != x"`cat GIT-USER-AGENT 2>/dev/null`"; then \ + echo '$(GIT_USER_AGENT_SQ)' >GIT-USER-AGENT; \ + fi ifdef DEFAULT_HELP_FORMAT BASIC_CFLAGS += -DDEFAULT_HELP_FORMAT='"$(DEFAULT_HELP_FORMAT)"' @@ -1986,7 +1987,40 @@ shell_compatibility_test: please_set_SHELL_PATH_to_a_more_modern_shell strip: $(PROGRAMS) git$X $(STRIP) $(STRIP_OPTS) $(PROGRAMS) git$X -git.o: common-cmds.h +### Target-specific flags and dependencies + +# The generic compilation pattern rule and automatically +# computed header dependencies (falling back to a dependency on +# LIB_H) are enough to describe how most targets should be built, +# but some targets are special enough to need something a little +# different. +# +# - When a source file "foo.c" #includes a generated header file, +# we need to list that dependency for the "foo.o" target. +# +# We also list it from other targets that are built from foo.c +# like "foo.sp" and "foo.s", even though that is easy to forget +# to do because the generated header is already present around +# after a regular build attempt. +# +# - Some code depends on configuration kept in makefile +# variables. The target-specific variable EXTRA_CPPFLAGS can +# be used to convey that information to the C preprocessor +# using -D options. +# +# The "foo.o" target should have a corresponding dependency on +# a file that changes when the value of the makefile variable +# changes. For example, targets making use of the +# $(GIT_VERSION) variable depend on GIT-VERSION-FILE. +# +# Technically the ".sp" and ".s" targets do not need this +# dependency because they are force-built, but they get the +# same dependency for consistency. This way, you do not have to +# know how each target is implemented. And it means the +# dependencies here will not need to change if the force-build +# details change some day. + +git.sp git.s git.o: GIT-PREFIX git.sp git.s git.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_SQ)"' \ @@ -1996,16 +2030,18 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS) $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \ $(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS) -help.sp help.o: common-cmds.h +help.sp help.s help.o: common-cmds.h -builtin/help.sp builtin/help.o: common-cmds.h +builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \ '-DGIT_HTML_PATH="$(htmldir_SQ)"' \ '-DGIT_MAN_PATH="$(mandir_SQ)"' \ '-DGIT_INFO_PATH="$(infodir_SQ)"' +version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT version.sp version.s version.o: EXTRA_CPPFLAGS = \ - '-DGIT_VERSION="$(GIT_VERSION)"' + '-DGIT_VERSION="$(GIT_VERSION)"' \ + '-DGIT_USER_AGENT=$(GIT_USER_AGENT_CQ_SQ)' $(BUILT_INS): git$X $(QUIET_BUILT_IN)$(RM) $@ && \ @@ -2018,36 +2054,47 @@ common-cmds.h: ./generate-cmdlist.sh command-list.txt common-cmds.h: $(wildcard Documentation/git-*.txt) $(QUIET_GEN)./generate-cmdlist.sh > $@+ && mv $@+ $@ +SCRIPT_DEFINES = $(SHELL_PATH_SQ):$(DIFF_SQ):$(GIT_VERSION):\ + $(localedir_SQ):$(NO_CURL):$(USE_GETTEXT_SCHEME):$(SANE_TOOL_PATH_SQ):\ + $(gitwebdir_SQ):$(PERL_PATH_SQ) define cmd_munge_script $(RM) $@ $@+ && \ sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ -e 's|@SHELL_PATH@|$(SHELL_PATH_SQ)|' \ -e 's|@@DIFF@@|$(DIFF_SQ)|' \ - -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ - -e 's|@@GIT_USER_AGENT@@|$(GIT_USER_AGENT_SQ)|g' \ -e 's|@@LOCALEDIR@@|$(localedir_SQ)|g' \ -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ -e 's/@@USE_GETTEXT_SCHEME@@/$(USE_GETTEXT_SCHEME)/g' \ -e $(BROKEN_PATH_FIX) \ + -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \ + -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ $@.sh >$@+ endef -$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh +GIT-SCRIPT-DEFINES: FORCE + @FLAGS='$(SCRIPT_DEFINES)'; \ + if test x"$$FLAGS" != x"`cat $@ 2>/dev/null`" ; then \ + echo 1>&2 " * new script parameters"; \ + echo "$$FLAGS" >$@; \ + fi + + +$(patsubst %.sh,%,$(SCRIPT_SH)) : % : %.sh GIT-SCRIPT-DEFINES $(QUIET_GEN)$(cmd_munge_script) && \ chmod +x $@+ && \ mv $@+ $@ -$(SCRIPT_LIB) : % : %.sh +$(SCRIPT_LIB) : % : %.sh GIT-SCRIPT-DEFINES $(QUIET_GEN)$(cmd_munge_script) && \ mv $@+ $@ ifndef NO_PERL $(patsubst %.perl,%,$(SCRIPT_PERL)): perl/perl.mak -perl/perl.mak: GIT-CFLAGS perl/Makefile perl/Makefile.PL +perl/perl.mak: GIT-CFLAGS GIT-PREFIX perl/Makefile perl/Makefile.PL $(QUIET_SUBDIR0)perl $(QUIET_SUBDIR1) PERL_PATH='$(PERL_PATH_SQ)' prefix='$(prefix_SQ)' $(@F) -$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl +$(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl GIT-VERSION-FILE $(QUIET_GEN)$(RM) $@ $@+ && \ INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C perl -s --no-print-directory instlibdir` && \ sed -e '1{' \ @@ -2067,14 +2114,8 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)): % : %.perl gitweb: $(QUIET_SUBDIR0)gitweb $(QUIET_SUBDIR1) all -git-instaweb: git-instaweb.sh gitweb - $(QUIET_GEN)$(RM) $@ $@+ && \ - sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \ - -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ - -e 's/@@NO_CURL@@/$(NO_CURL)/g' \ - -e 's|@@GITWEBDIR@@|$(gitwebdir_SQ)|g' \ - -e 's|@@PERL@@|$(PERL_PATH_SQ)|g' \ - $@.sh > $@+ && \ +git-instaweb: git-instaweb.sh gitweb GIT-SCRIPT-DEFINES + $(QUIET_GEN)$(cmd_munge_script) && \ chmod +x $@+ && \ mv $@+ $@ else # NO_PERL @@ -2088,7 +2129,7 @@ $(patsubst %.perl,%,$(SCRIPT_PERL)) git-instaweb: % : unimplemented.sh endif # NO_PERL ifndef NO_PYTHON -$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS +$(patsubst %.py,%,$(SCRIPT_PYTHON)): GIT-CFLAGS GIT-PREFIX $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : %.py $(QUIET_GEN)$(RM) $@ $@+ && \ INSTLIBDIR=`MAKEFLAGS= $(MAKE) -C git_remote_helpers -s \ @@ -2110,26 +2151,13 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)): % : unimplemented.sh mv $@+ $@ endif # NO_PYTHON -configure: configure.ac +configure: configure.ac GIT-VERSION-FILE $(QUIET_GEN)$(RM) $@ $<+ && \ sed -e 's/@@GIT_VERSION@@/$(GIT_VERSION)/g' \ $< > $<+ && \ autoconf -o $@ $<+ && \ $(RM) $<+ -# These can record GIT_VERSION -version.o git.spec \ - $(patsubst %.sh,%,$(SCRIPT_SH)) \ - $(patsubst %.perl,%,$(SCRIPT_PERL)) \ - : GIT-VERSION-FILE - -TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS)) -GIT_OBJS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \ - git.o -ifndef NO_CURL - GIT_OBJS += http.o http-walker.o remote-curl.o -endif - XDIFF_OBJS += xdiff/xdiffi.o XDIFF_OBJS += xdiff/xprepare.o XDIFF_OBJS += xdiff/xutils.o @@ -2145,9 +2173,14 @@ VCSSVN_OBJS += vcs-svn/fast_export.o VCSSVN_OBJS += vcs-svn/svndiff.o VCSSVN_OBJS += vcs-svn/svndump.o -VCSSVN_TEST_OBJS += test-line-buffer.o - -OBJECTS := $(GIT_OBJS) $(XDIFF_OBJS) $(VCSSVN_OBJS) +TEST_OBJS := $(patsubst test-%$X,test-%.o,$(TEST_PROGRAMS)) +OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \ + $(XDIFF_OBJS) \ + $(VCSSVN_OBJS) \ + git.o +ifndef NO_CURL + OBJECTS += http.o http-walker.o remote-curl.o +endif dep_files := $(foreach f,$(OBJECTS),$(dir $f).depend/$(notdir $f).d) dep_dirs := $(addsuffix .depend,$(sort $(dir $(OBJECTS)))) @@ -2246,45 +2279,29 @@ else # Dependencies on automatically generated headers such as common-cmds.h # should _not_ be included here, since they are necessary even when # building an object for the first time. -# -# XXX. Please check occasionally that these include all dependencies -# gcc detects! - -$(GIT_OBJS): $(LIB_H) -builtin/branch.o builtin/checkout.o builtin/clone.o builtin/reset.o branch.o transport.o: branch.h -builtin/bundle.o bundle.o transport.o: bundle.h -builtin/bisect--helper.o builtin/rev-list.o bisect.o: bisect.h -builtin/clone.o builtin/fetch-pack.o transport.o: fetch-pack.h -builtin/index-pack.o builtin/grep.o builtin/pack-objects.o transport-helper.o thread-utils.o: thread-utils.h -builtin/send-pack.o transport.o: send-pack.h -builtin/log.o builtin/shortlog.o: shortlog.h -builtin/prune.o builtin/reflog.o reachable.o: reachable.h -builtin/commit.o builtin/revert.o wt-status.o: wt-status.h -builtin/tar-tree.o archive-tar.o: tar.h -connect.o transport.o url.o http-backend.o: url.h -builtin/branch.o builtin/commit.o builtin/tag.o column.o help.o pager.o: column.h -http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h -http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h - -xdiff-interface.o $(XDIFF_OBJS): $(XDIFF_H) -$(VCSSVN_OBJS) $(VCSSVN_TEST_OBJS): $(LIB_H) $(VCSSVN_H) +$(OBJECTS): $(LIB_H) endif +exec_cmd.sp exec_cmd.s exec_cmd.o: GIT-PREFIX exec_cmd.sp exec_cmd.s exec_cmd.o: EXTRA_CPPFLAGS = \ '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' \ '-DBINDIR="$(bindir_relative_SQ)"' \ '-DPREFIX="$(prefix_SQ)"' +builtin/init-db.sp builtin/init-db.s builtin/init-db.o: GIT-PREFIX builtin/init-db.sp builtin/init-db.s builtin/init-db.o: EXTRA_CPPFLAGS = \ -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' +config.sp config.s config.o: GIT-PREFIX config.sp config.s config.o: EXTRA_CPPFLAGS = \ -DETC_GITCONFIG='"$(ETC_GITCONFIG_SQ)"' +attr.sp attr.s attr.o: GIT-PREFIX attr.sp attr.s attr.o: EXTRA_CPPFLAGS = \ -DETC_GITATTRIBUTES='"$(ETC_GITATTRIBUTES_SQ)"' +gettext.sp gettext.s gettext.o: GIT-PREFIX gettext.sp gettext.s gettext.o: EXTRA_CPPFLAGS = \ -DGIT_LOCALE_PATH='"$(localedir_SQ)"' @@ -2361,7 +2378,7 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \ --keyword=_ --keyword=N_ --keyword="Q_:1,2" XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl -LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(XDIFF_H) $(VCSSVN_H) $(MISC_H) +LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H) LOCALIZED_SH := $(SCRIPT_SH) LOCALIZED_PERL := $(SCRIPT_PERL) @@ -2408,14 +2425,22 @@ cscope: $(FIND_SOURCE_FILES) | xargs cscope -b ### Detect prefix changes -TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):\ - $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\ - $(localedir_SQ):$(USE_GETTEXT_SCHEME) +TRACK_PREFIX = $(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ):\ + $(localedir_SQ) + +GIT-PREFIX: FORCE + @FLAGS='$(TRACK_PREFIX)'; \ + if test x"$$FLAGS" != x"`cat GIT-PREFIX 2>/dev/null`" ; then \ + echo 1>&2 " * new prefix flags"; \ + echo "$$FLAGS" >GIT-PREFIX; \ + fi + +TRACK_CFLAGS = $(CC):$(subst ','\'',$(ALL_CFLAGS)):$(USE_GETTEXT_SCHEME) GIT-CFLAGS: FORCE @FLAGS='$(TRACK_CFLAGS)'; \ if test x"$$FLAGS" != x"`cat GIT-CFLAGS 2>/dev/null`" ; then \ - echo 1>&2 " * new build flags or prefix"; \ + echo 1>&2 " * new build flags"; \ echo "$$FLAGS" >GIT-CFLAGS; \ fi @@ -2667,7 +2692,7 @@ quick-install-html: ### Maintainer's dist rules -git.spec: git.spec.in +git.spec: git.spec.in GIT-VERSION-FILE sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@+ mv $@+ $@ @@ -2751,6 +2776,7 @@ ifndef NO_TCLTK $(MAKE) -C git-gui clean endif $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS + $(RM) GIT-USER-AGENT GIT-PREFIX GIT-SCRIPT-DEFINES .PHONY: all install profile-clean clean strip .PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell |