@@ -1777,6 +1777,26 @@ ifdef ASCIIDOC7
1777
1777
export ASCIIDOC7
1778
1778
endif
1779
1779
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
+
1780
1800
# Shell quote (do not use $(call) to accommodate ancient setups);
1781
1801
1782
1802
SHA1_HEADER_SQ = $(subst ','\'',$(SHA1_HEADER ) )
@@ -1833,7 +1853,17 @@ export DIFF TAR INSTALL DESTDIR SHELL_PATH
1833
1853
1834
1854
SHELL = $(SHELL_PATH )
1835
1855
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
1837
1867
ifneq (,$X)
1838
1868
$(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';)
1839
1869
endif
@@ -2581,7 +2611,11 @@ distclean: clean
2581
2611
$(RM ) configure
2582
2612
$(RM ) po/git.pot
2583
2613
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
2585
2619
$(RM ) * .o block-sha1/* .o ppc/* .o compat/* .o compat/* /* .o xdiff/* .o vcs-svn/* .o \
2586
2620
builtin/* .o $(LIB_FILE ) $(XDIFF_LIB ) $(VCSSVN_LIB )
2587
2621
$(RM ) $(ALL_PROGRAMS ) $(SCRIPT_LIB ) $(BUILT_INS ) git$X
@@ -2611,7 +2645,7 @@ ifndef NO_TCLTK
2611
2645
endif
2612
2646
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-GUI-VARS GIT-BUILD-OPTIONS
2613
2647
2614
- .PHONY : all install clean strip
2648
+ .PHONY : all install profile-clean clean strip
2615
2649
.PHONY : shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
2616
2650
.PHONY : FORCE cscope
2617
2651
@@ -2721,18 +2755,3 @@ cover_db: coverage-report
2721
2755
cover_db_html : cover_db
2722
2756
cover -report html -outputdir cover_db_html cover_db
2723
2757
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