@@ -1771,6 +1771,26 @@ ifdef ASCIIDOC7
17711771 export ASCIIDOC7
17721772endif
17731773
1774+ # ## profile feedback build
1775+ #
1776+
1777+ # Can adjust this to be a global directory if you want to do extended
1778+ # data gathering
1779+ PROFILE_DIR := $(CURDIR )
1780+
1781+ ifeq ("$(PROFILE ) ","GEN")
1782+ CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
1783+ EXTLIBS += -lgcov
1784+ export CCACHE_DISABLE=t
1785+ V=1
1786+ else
1787+ ifneq ("$(PROFILE ) ","")
1788+ CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
1789+ export CCACHE_DISABLE=t
1790+ V=1
1791+ endif
1792+ endif
1793+
17741794# Shell quote (do not use $(call) to accommodate ancient setups);
17751795
17761796SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER ) )
@@ -1827,7 +1847,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
18271847
18281848SHELL = $(SHELL_PATH )
18291849
1830- all :: shell_compatibility_test $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) $(OTHER_PROGRAMS ) GIT-BUILD-OPTIONS
1850+ all :: shell_compatibility_test
1851+
1852+ ifeq "$(PROFILE ) " "BUILD"
1853+ ifeq ($(filter all,$(MAKECMDGOALS ) ) ,all)
1854+ all :: profile-clean
1855+ $(MAKE ) PROFILE=GEN all
1856+ $(MAKE ) PROFILE=GEN -j1 test
1857+ endif
1858+ endif
1859+
1860+ all :: $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) $(OTHER_PROGRAMS ) GIT-BUILD-OPTIONS
18311861ifneq (,$X)
18321862 $(QUIET_BUILT_IN)$(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_PROGRAMS) $(BUILT_INS) git$X)), test -d '$p' -o '$p' -ef '$p$X' || $(RM) '$p';)
18331863endif
@@ -2555,7 +2585,11 @@ distclean: clean
25552585 $(RM ) configure
25562586 $(RM ) po/git.pot
25572587
2558- clean :
2588+ profile-clean :
2589+ $(RM ) $(addsuffix * .gcda,$(addprefix $(PROFILE_DIR ) /, $(object_dirs ) ) )
2590+ $(RM ) $(addsuffix * .gcno,$(addprefix $(PROFILE_DIR ) /, $(object_dirs ) ) )
2591+
2592+ clean : profile-clean
25592593 $(RM ) * .o block-sha1/* .o ppc/* .o compat/* .o compat/* /* .o xdiff/* .o vcs-svn/* .o \
25602594 builtin/* .o $(LIB_FILE ) $(XDIFF_LIB ) $(VCSSVN_LIB )
25612595 $(RM ) $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) git$X
@@ -2585,7 +2619,7 @@ ifndef NO_TCLTK
25852619endif
25862620 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
25872621
2588- .PHONY : all install clean strip
2622+ .PHONY : all install profile-clean clean strip
25892623.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
25902624.PHONY : FORCE cscope
25912625
@@ -2695,18 +2729,3 @@ cover_db: coverage-report
26952729cover_db_html : cover_db
26962730 cover -report html -outputdir cover_db_html cover_db
26972731
2698- # ## profile feedback build
2699- #
2700- .PHONY : profile-all profile-clean
2701-
2702- PROFILE_GEN_CFLAGS := $(CFLAGS ) -fprofile-generate -DNO_NORETURN=1
2703- PROFILE_USE_CFLAGS := $(CFLAGS ) -fprofile-use -fprofile-correction -DNO_NORETURN=1
2704-
2705- profile-clean :
2706- $(RM ) $(addsuffix * .gcda,$(object_dirs ) )
2707- $(RM ) $(addsuffix * .gcno,$(object_dirs ) )
2708-
2709- profile-all : profile-clean
2710- $(MAKE ) CFLAGS=" $( PROFILE_GEN_CFLAGS) " all
2711- $(MAKE ) CFLAGS=" $( PROFILE_GEN_CFLAGS) " -j1 test
2712- $(MAKE ) CFLAGS=" $( PROFILE_USE_CFLAGS) " all
0 commit comments