Add a Makefile target for profiling targets
authorIustin Pop <iustin@google.com>
Sat, 14 Jan 2012 00:07:21 +0000 (01:07 +0100)
committerIustin Pop <iustin@google.com>
Mon, 16 Jan 2012 12:49:28 +0000 (13:49 +0100)
This simplifies the building of profiling-enabled htools binaries;
there are two targets, one used for the initial two-stage build, and
one that can be used for incremental builds.

The patch adds a new internal variable for the htools/test binary,
which should also simplify custom builds for the non-profiling
targets.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: RenĂ© Nussbaumer <rn@google.com>

Makefile.am
doc/devnotes.rst

index 759f717..5dfa489 100644 (file)
@@ -354,6 +354,8 @@ HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
 HFLAGS = -O -Wall -fwarn-monomorphism-restriction -fwarn-tabs -ihtools
 # extra flags that can be overriden on the command line
 HEXTRA =
+# internal extra flags (used for htools/test mainly)
+HEXTRA_INT =
 # exclude options for coverage reports
 HPCEXCL = --exclude Main \
        --exclude Ganeti.Constants \
@@ -512,13 +514,27 @@ $(HS_ALL_PROGS): %: %.hs $(HS_LIB_SRCS) $(HS_BUILT_SRCS) Makefile
          $(HFLAGS) \
          $(HTOOLS_NOCURL) $(HTOOLS_PARALLEL3) \
          -osuf $$BINARY.o -hisuf $$BINARY.hi \
-         $(HEXTRA) $@
+         $(HEXTRA) $(HEXTRA_INT) $@
 
 # for the htools/test binary, we need to enable profiling/coverage
-htools/test: HEXTRA=-fhpc -Wwarn -fno-warn-missing-signatures \
+htools/test: HEXTRA_INT=-fhpc -Wwarn -fno-warn-missing-signatures \
        -fno-warn-monomorphism-restriction -fno-warn-orphans \
        -fno-warn-missing-methods -fno-warn-unused-imports
 
+# rules for building profiling-enabled versions of the haskell
+# programs: hs-prof does the full two-step build, whereas
+# hs-prof-quick does only the final rebuild (hs-prof must have been
+# run before)
+.PHONY: hs-prof hs-prof-quick
+hs-prof:
+       $(MAKE) clean
+       $(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .o"
+       rm -f $(HS_ALL_PROGS)
+       $(MAKE) hs-prof-quick
+
+hs-prof-quick:
+       $(MAKE) $(HS_ALL_PROGS) HEXTRA="-osuf .prof_o -prof -auto-all"
+
 dist_sbin_SCRIPTS = \
        tools/ganeti-listrunner
 
index 2d2a2cf..2fcc7d8 100644 (file)
@@ -81,7 +81,8 @@ what the splices are converted to. This can be done via::
   make HEXTRA="-ddump-splices"
 
 Due to the way TemplateHaskell works, it's not straightforward to
-build profiling code. The recommended way is::
+build profiling code. The recommended way is to run ``make hs-prof``,
+or alternatively the manual sequence is::
 
   make clean
   make htools/htools HEXTRA="-osuf .o"