@@ -1777,6 +1777,26 @@ ifdef ASCIIDOC7
17771777 export ASCIIDOC7
17781778endif
17791779
1780+ # ## profile feedback build
1781+ #
1782+
1783+ # Can adjust this to be a global directory if you want to do extended
1784+ # data gathering
1785+ PROFILE_DIR := $(CURDIR )
1786+
1787+ ifeq ("$(PROFILE ) ","GEN")
1788+ CFLAGS += -fprofile-generate=$(PROFILE_DIR) -DNO_NORETURN=1
1789+ EXTLIBS += -lgcov
1790+ export CCACHE_DISABLE=t
1791+ V=1
1792+ else
1793+ ifneq ("$(PROFILE ) ","")
1794+ CFLAGS += -fprofile-use=$(PROFILE_DIR) -fprofile-correction -DNO_NORETURN=1
1795+ export CCACHE_DISABLE=t
1796+ V=1
1797+ endif
1798+ endif
1799+
17801800# Shell quote (do not use $(call) to accommodate ancient setups);
17811801
17821802SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER ) )
@@ -1833,7 +1853,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
18331853
18341854SHELL = $(SHELL_PATH )
18351855
1836- all :: shell_compatibility_test $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) $(OTHER_PROGRAMS ) GIT-BUILD-OPTIONS
1856+ all :: shell_compatibility_test
1857+
1858+ ifeq "$(PROFILE ) " "BUILD"
1859+ ifeq ($(filter all,$(MAKECMDGOALS ) ) ,all)
1860+ all :: profile-clean
1861+ $(MAKE ) PROFILE=GEN all
1862+ $(MAKE ) PROFILE=GEN -j1 test
1863+ endif
1864+ endif
1865+
1866+ all :: $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) $(OTHER_PROGRAMS ) GIT-BUILD-OPTIONS
18371867ifneq (,$X)
18381868 $(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';)
18391869endif
@@ -2581,7 +2611,11 @@ distclean: clean
25812611 $(RM ) configure
25822612 $(RM ) po/git.pot
25832613
2584- clean :
2614+ profile-clean :
2615+ $(RM ) $(addsuffix * .gcda,$(addprefix $(PROFILE_DIR ) /, $(object_dirs ) ) )
2616+ $(RM ) $(addsuffix * .gcno,$(addprefix $(PROFILE_DIR ) /, $(object_dirs ) ) )
2617+
2618+ clean : profile-clean
25852619 $(RM ) * .o block-sha1/* .o ppc/* .o compat/* .o compat/* /* .o xdiff/* .o vcs-svn/* .o \
25862620 builtin/* .o $(LIB_FILE ) $(XDIFF_LIB ) $(VCSSVN_LIB )
25872621 $(RM ) $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) git$X
@@ -2611,7 +2645,7 @@ ifndef NO_TCLTK
26112645endif
26122646 $(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
26132647
2614- .PHONY : all install clean strip
2648+ .PHONY : all install profile-clean clean strip
26152649.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
26162650.PHONY : FORCE cscope
26172651
@@ -2721,18 +2755,3 @@ cover_db: coverage-report
27212755cover_db_html : cover_db
27222756 cover -report html -outputdir cover_db_html cover_db
27232757
2724- # ## profile feedback build
2725- #
2726- .PHONY : profile-all profile-clean
2727-
2728- PROFILE_GEN_CFLAGS := $(CFLAGS ) -fprofile-generate -DNO_NORETURN=1
2729- PROFILE_USE_CFLAGS := $(CFLAGS ) -fprofile-use -fprofile-correction -DNO_NORETURN=1
2730-
2731- profile-clean :
2732- $(RM ) $(addsuffix * .gcda,$(object_dirs ) )
2733- $(RM ) $(addsuffix * .gcno,$(object_dirs ) )
2734-
2735- profile-all : profile-clean
2736- $(MAKE ) CFLAGS=" $( PROFILE_GEN_CFLAGS) " all
2737- $(MAKE ) CFLAGS=" $( PROFILE_GEN_CFLAGS) " -j1 test
2738- $(MAKE ) CFLAGS=" $( PROFILE_USE_CFLAGS) " all
0 commit comments