@@ -1771,6 +1771,26 @@ ifdef ASCIIDOC7
1771
1771
export ASCIIDOC7
1772
1772
endif
1773
1773
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
+
1774
1794
# Shell quote (do not use $(call) to accommodate ancient setups);
1775
1795
1776
1796
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER ) )
@@ -1827,7 +1847,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
1827
1847
1828
1848
SHELL = $(SHELL_PATH )
1829
1849
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
1831
1861
ifneq (,$X)
1832
1862
$(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';)
1833
1863
endif
@@ -2555,7 +2585,11 @@ distclean: clean
2555
2585
$(RM ) configure
2556
2586
$(RM ) po/git.pot
2557
2587
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
2559
2593
$(RM ) * .o block-sha1/* .o ppc/* .o compat/* .o compat/* /* .o xdiff/* .o vcs-svn/* .o \
2560
2594
builtin/* .o $(LIB_FILE ) $(XDIFF_LIB ) $(VCSSVN_LIB )
2561
2595
$(RM ) $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) git$X
@@ -2585,7 +2619,7 @@ ifndef NO_TCLTK
2585
2619
endif
2586
2620
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2587
2621
2588
- .PHONY : all install clean strip
2622
+ .PHONY : all install profile-clean clean strip
2589
2623
.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2590
2624
.PHONY : FORCE cscope
2591
2625
@@ -2695,18 +2729,3 @@ cover_db: coverage-report
2695
2729
cover_db_html : cover_db
2696
2730
cover -report html -outputdir cover_db_html cover_db
2697
2731
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