Makefile: use `find` to determine static header dependencies

Most modern platforms will use automatically computed header dependencies to figure out when a C file needs rebuilt due to a header changing. With old compilers, however, we fallback to a static list of header files. If any of them changes, we recompile everything. This is overly conservative, but the best we can do on older platforms. It is unfortunately easy for our static header list to grow stale, as none of the regular developers make use of it. Instead of trying to keep it up to date, let's invoke "find" to generate the list dynamically. Since we do not use the value $(LIB_H) unless either COMPUTE_HEADER_DEPENDENCIES is turned on or the user is building "po/git.pot" (where it comes in via $(LOCALIZED_C), make is smart enough to not even run this "find" in most cases. However, we do need to stop using the "immediate" variable assignment ":=" for $(LOCALIZED_C). That's OK, because it was not otherwise useful here. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Aug 25, 2014 at 16:00 UTC d85b0dff7297fb43a57a0c1e697417bb7723247c
1 file changed +8 -132
Makefile
+8 -132
@@ -432,7 +432,6 @@ XDIFF_OBJS =
432 VCSSVN_OBJS =
433 GENERATED_H =
434 EXTRA_CPPFLAGS =
435 -LIB_H =
435 LIB_OBJS =
436 PROGRAM_OBJS =
437 PROGRAMS =
@@ -631,131 +630,11 @@ VCSSVN_LIB = vcs-svn/lib.a
630
631 GENERATED_H += common-cmds.h
632
634 -LIB_H += advice.h
635 -LIB_H += archive.h
636 -LIB_H += argv-array.h
637 -LIB_H += attr.h
638 -LIB_H += bisect.h
639 -LIB_H += blob.h
640 -LIB_H += branch.h
641 -LIB_H += builtin.h
642 -LIB_H += bulk-checkin.h
643 -LIB_H += bundle.h
644 -LIB_H += cache-tree.h
645 -LIB_H += cache.h
646 -LIB_H += color.h
647 -LIB_H += column.h
648 -LIB_H += commit.h
649 -LIB_H += compat/bswap.h
650 -LIB_H += compat/mingw.h
651 -LIB_H += compat/obstack.h
652 -LIB_H += compat/poll/poll.h
653 -LIB_H += compat/precompose_utf8.h
654 -LIB_H += compat/terminal.h
655 -LIB_H += compat/win32/dirent.h
656 -LIB_H += compat/win32/pthread.h
657 -LIB_H += compat/win32/syslog.h
658 -LIB_H += connected.h
659 -LIB_H += convert.h
660 -LIB_H += credential.h
661 -LIB_H += csum-file.h
662 -LIB_H += decorate.h
663 -LIB_H += delta.h
664 -LIB_H += diff.h
665 -LIB_H += diffcore.h
666 -LIB_H += dir.h
667 -LIB_H += exec_cmd.h
668 -LIB_H += ewah/ewok.h
669 -LIB_H += ewah/ewok_rlw.h
670 -LIB_H += fetch-pack.h
671 -LIB_H += fmt-merge-msg.h
672 -LIB_H += fsck.h
673 -LIB_H += gettext.h
674 -LIB_H += git-compat-util.h
675 -LIB_H += gpg-interface.h
676 -LIB_H += graph.h
677 -LIB_H += grep.h
678 -LIB_H += hashmap.h
679 -LIB_H += help.h
680 -LIB_H += http.h
681 -LIB_H += kwset.h
682 -LIB_H += levenshtein.h
683 -LIB_H += line-log.h
684 -LIB_H += line-range.h
685 -LIB_H += list-objects.h
686 -LIB_H += ll-merge.h
687 -LIB_H += log-tree.h
688 -LIB_H += mailmap.h
689 -LIB_H += merge-blobs.h
690 -LIB_H += merge-recursive.h
691 -LIB_H += mergesort.h
692 -LIB_H += notes-cache.h
693 -LIB_H += notes-merge.h
694 -LIB_H += notes-utils.h
695 -LIB_H += notes.h
696 -LIB_H += object.h
697 -LIB_H += pack-objects.h
698 -LIB_H += pack-revindex.h
699 -LIB_H += pack.h
700 -LIB_H += pack-bitmap.h
701 -LIB_H += parse-options.h
702 -LIB_H += patch-ids.h
703 -LIB_H += pathspec.h
704 -LIB_H += pkt-line.h
705 -LIB_H += prio-queue.h
706 -LIB_H += progress.h
707 -LIB_H += prompt.h
708 -LIB_H += quote.h
709 -LIB_H += reachable.h
710 -LIB_H += reflog-walk.h
711 -LIB_H += refs.h
712 -LIB_H += remote.h
713 -LIB_H += rerere.h
714 -LIB_H += resolve-undo.h
715 -LIB_H += revision.h
716 -LIB_H += run-command.h
717 -LIB_H += send-pack.h
718 -LIB_H += sequencer.h
719 -LIB_H += sha1-array.h
720 -LIB_H += sha1-lookup.h
721 -LIB_H += shortlog.h
722 -LIB_H += sideband.h
723 -LIB_H += sigchain.h
724 -LIB_H += strbuf.h
725 -LIB_H += streaming.h
726 -LIB_H += string-list.h
727 -LIB_H += submodule.h
728 -LIB_H += tag.h
729 -LIB_H += tar.h
730 -LIB_H += thread-utils.h
731 -LIB_H += transport.h
732 -LIB_H += tree-walk.h
733 -LIB_H += tree.h
734 -LIB_H += unpack-trees.h
735 -LIB_H += unicode_width.h
736 -LIB_H += url.h
737 -LIB_H += urlmatch.h
738 -LIB_H += userdiff.h
739 -LIB_H += utf8.h
740 -LIB_H += varint.h
741 -LIB_H += vcs-svn/fast_export.h
742 -LIB_H += vcs-svn/line_buffer.h
743 -LIB_H += vcs-svn/repo_tree.h
744 -LIB_H += vcs-svn/sliding_window.h
745 -LIB_H += vcs-svn/svndiff.h
746 -LIB_H += vcs-svn/svndump.h
747 -LIB_H += walker.h
748 -LIB_H += wildmatch.h
749 -LIB_H += wt-status.h
750 -LIB_H += xdiff-interface.h
751 -LIB_H += xdiff/xdiff.h
752 -LIB_H += xdiff/xdiffi.h
753 -LIB_H += xdiff/xemit.h
754 -LIB_H += xdiff/xinclude.h
755 -LIB_H += xdiff/xmacros.h
756 -LIB_H += xdiff/xprepare.h
757 -LIB_H += xdiff/xtypes.h
758 -LIB_H += xdiff/xutils.h
633 +LIB_H = $(shell $(FIND) . \
634 + -name .git -prune -o \
635 + -name t -prune -o \
636 + -name Documentation -prune -o \
637 + -name '*.h' -print)
638
639 LIB_OBJS += abspath.o
640 LIB_OBJS += advice.o
@@ -1381,7 +1260,6 @@ ifdef NO_INET_PTON
1260 endif
1261 ifndef NO_UNIX_SOCKETS
1262 LIB_OBJS += unix-socket.o
1384 - LIB_H += unix-socket.h
1263 PROGRAM_OBJS += credential-cache.o
1264 PROGRAM_OBJS += credential-cache--daemon.o
1265 endif
@@ -1405,12 +1283,10 @@ endif
1283 ifdef BLK_SHA1
1284 SHA1_HEADER = "block-sha1/sha1.h"
1285 LIB_OBJS += block-sha1/sha1.o
1408 - LIB_H += block-sha1/sha1.h
1286 else
1287 ifdef PPC_SHA1
1288 SHA1_HEADER = "ppc/sha1.h"
1289 LIB_OBJS += ppc/sha1.o ppc/sha1ppc.o
1413 - LIB_H += ppc/sha1.h
1290 else
1291 ifdef APPLE_COMMON_CRYPTO
1292 COMPAT_CFLAGS += -DCOMMON_DIGEST_FOR_OPENSSL
@@ -2128,9 +2004,9 @@ XGETTEXT_FLAGS_C = $(XGETTEXT_FLAGS) --language=C \
2004 XGETTEXT_FLAGS_SH = $(XGETTEXT_FLAGS) --language=Shell \
2005 --keyword=gettextln --keyword=eval_gettextln
2006 XGETTEXT_FLAGS_PERL = $(XGETTEXT_FLAGS) --keyword=__ --language=Perl
2131 -LOCALIZED_C := $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
2132 -LOCALIZED_SH := $(SCRIPT_SH)
2133 -LOCALIZED_PERL := $(SCRIPT_PERL)
2007 +LOCALIZED_C = $(C_OBJ:o=c) $(LIB_H) $(GENERATED_H)
2008 +LOCALIZED_SH = $(SCRIPT_SH)
2009 +LOCALIZED_PERL = $(SCRIPT_PERL)
2010
2011 ifdef XGETTEXT_INCLUDE_TESTS
2012 LOCALIZED_C += t/t0200/test.c