Revision 9b6d2d92

b/Makefile.am
239 239
	$(addsuffix /*.py[co],$(DIRS)) \
240 240
	$(addsuffix /*.hi,$(HS_DIRS)) \
241 241
	$(addsuffix /*.o,$(HS_DIRS)) \
242
	$(addsuffix /*.$(HTEST_SUFFIX)_hi,$(HS_DIRS)) \
243
	$(addsuffix /*.$(HTEST_SUFFIX)_o,$(HS_DIRS)) \
244
	Makefile.ghc \
245
	Makefile.ghc.bak \
242 246
	$(PYTHON_BOOTSTRAP) \
243 247
	$(gnt_python_sbin_SCRIPTS) \
244 248
	epydoc.conf \
......
614 618

  
615 619
HS_ALL_PROGS = $(HS_DEFAULT_PROGS) $(HS_MYEXECLIB_PROGS)
616 620

  
621
HS_TEST_PROGS = $(filter test/%,$(HS_ALL_PROGS))
622
HS_SRC_PROGS = $(filter-out test/%,$(HS_ALL_PROGS))
623

  
617 624
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_DEFAULT_PROGS)) src/mon-collector.hs
618 625
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
619 626

  
......
623 630
	-fwarn-tabs \
624 631
	$(GHC_BYVERSION_FLAGS)
625 632

  
633
if HPROFILE
634
HFLAGS += -prof -auto-all
635
endif
636
if HCOVERAGE
637
HFLAGS += -fhpc
638
endif
639
if HTEST
640
HFLAGS += -DTEST
641
endif
642

  
643
HTEST_SUFFIX = hpc
644

  
645
HTEST_FLAGS = $(HFLAGS) -fhpc -itest/hs \
646
	-osuf .$(HTEST_SUFFIX)_o \
647
	-hisuf .$(HTEST_SUFFIX)_hi
648

  
626 649
# extra flags that can be overriden on the command line (e.g. -Wwarn, etc.)
627 650
HEXTRA =
628 651
# internal extra flags (used for test/hs/htest mainly)
......
989 1012
	  $(LN_S) -f htools $(DESTDIR)$(bindir)/$$role ; \
990 1013
	done
991 1014

  
992
HNORMAL_SUFFIX = .o
993
HPROFILE_SUFFIX = .prof.o
994
HCOVERAGE_SUFFIX = .hpc.o
995
HTEST_SUFFIX = .test.o
1015
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
996 1016

  
997
HSUFFIX = $(if $(HPROFILE),$(HPROFILE_SUFFIX), \
998
	  $(if $(HCOVERAGE),$(HCOVERAGE_SUFFIX), \
999
	  $(if $(HTEST),$(HTEST_SUFFIX), \
1000
	  $(HNORMAL_SUFFIX))))
1017
Makefile.ghc: $(HS_ALL_PROGS:%=%.hs) $(HS_SRCS) Makefile | $(built_base_sources)
1018
	$(GHC) -M -dep-makefile $@ -dep-suffix $(HTEST_SUFFIX) $(HFLAGS) \
1019
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(HS_ALL_PROGS:%=%.hs) $(HS_SRCS)
1001 1020

  
1002
HFLAGS += $(if $(HPROFILE),-prof -auto-all,)
1003
HFLAGS += $(if $(HCOVERAGE),-fhpc,)
1004
HFLAGS += $(if $(HTEST),-DTEST,)
1021
@include_makefile_ghc@
1005 1022

  
1006
HS_SRCS = $(HS_LIBTESTBUILT_SRCS)
1023
%.o:
1024
	$(GHC) -c $(HFLAGS) \
1025
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(@:%.o=%.hs)
1026

  
1027
%.$(HTEST_SUFFIX)_o:
1028
	$(GHC) -c $(HTEST_FLAGS) \
1029
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $(@:%.$(HTEST_SUFFIX)_o=%.hs)
1007 1030

  
1008
.NOTPARALLEL: $(HS_ALL_PROGS)
1009
.PHONY: $(HS_ALL_PROGS)
1010
$(HS_ALL_PROGS): %: %.hs $(HS_SRCS) Makefile
1011
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
1031
%.hi: %.o ;
1032
%.$(HTEST_SUFFIX)_hi: %.$(HTEST_SUFFIX)_o ;
1033

  
1034
$(HS_SRC_PROGS): %: %.o | stamp-directories
1035
	$(GHC) $(HFLAGS) \
1036
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) --make $(@:%=%.hs)
1037
	@rm -f $(notdir $@).tix
1038
	@touch "$@"
1039

  
1040
$(HS_TEST_PROGS): %: %.$(HTEST_SUFFIX)_o \
1041
	                   | stamp-directories $(BUILT_PYTHON_SOURCES)
1042
	@if [ "$(HS_NODEV)" ]; then \
1012 1043
	  echo "Error: cannot run unittests without the development" \
1013 1044
	       " libraries (see devnotes.rst)" 1>&2; \
1014 1045
	  exit 1; \
1015 1046
	fi
1047
	$(GHC) $(HTEST_FLAGS) \
1048
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) --make $(@:%=%.hs)
1016 1049
	@rm -f $(notdir $@).tix
1017
	$(GHC) --make $(HFLAGS) \
1018
		-osuf $(HSUFFIX) \
1019
		-hisuf $(patsubst %.o,%.hi,$(HSUFFIX)) \
1020
		$(HS_PARALLEL3) $(HS_REGEX_PCRE) $(HEXTRA) $@
1021 1050
	@touch "$@"
1022 1051

  
1023
# for the test/hs/htest binary, we need to enable profiling/coverage
1024
test/hs/htest: HCOVERAGE = true
1025
test/hs/htest: HFLAGS += -itest/hs
1026
test/hs/htest: | $(BUILT_PYTHON_SOURCES)
1027

  
1028
# we compile the hpc-htools binary with the program coverage
1029
test/hs/hpc-htools: HCOVERAGE = true
1030

  
1031
# we compile the hpc-mon-collector binary with the program coverage
1032
test/hs/hpc-mon-collector: HCOVERAGE = true
1033

  
1034 1052
# test dependency
1035 1053
test/hs/offline-test.sh: test/hs/hpc-htools test/hs/hpc-mon-collector
1036 1054

  
1037
# rule for building profiling-enabled versions of the haskell programs
1038
.PHONY: hs-prof
1039
hs-prof:
1040
	@if [ -z "$(TARGET)" ]; then \
1041
	  echo "You need to define TARGET when running this rule" 1>&2; \
1042
	  exit 1; \
1043
	fi
1044
	$(MAKE) $(AM_MAKEFLAGS) HPROFILE=y $(TARGET)
1045

  
1046 1055
dist_sbin_SCRIPTS = \
1047 1056
	tools/ganeti-listrunner
1048 1057

  
b/configure.ac
809 809
AC_SUBST(PY_NODEV)
810 810
AM_CONDITIONAL([PY_UNIT], [test -n $PY_NODEV])
811 811

  
812
include_makefile_ghc='
813
ifneq ($(MAKECMDGOALS),ganeti)
814
ifneq ($(MAKECMDGOALS),clean)
815
ifneq ($(MAKECMDGOALS),distclean)
816
include Makefile.ghc
817
endif
818
endif
819
endif
820
'
821
AC_SUBST([include_makefile_ghc])
822
AM_SUBST_NOTMAKE([include_makefile_ghc])
823

  
812 824
AC_CONFIG_FILES([ Makefile ])
813 825

  
814 826
AC_OUTPUT

Also available in: Unified diff