Revision 1b2adaa6 Makefile.am

b/Makefile.am
240 240
	src/ganeti-confd \
241 241
	src/ganeti-luxid \
242 242
	src/ganeti-mond \
243
	src/hs2py-constants \
243 244
	.hpc/*.mix src/*.tix test/hs/*.tix \
244 245
	doc/hs-lint.html
245 246

  
......
266 267

  
267 268
built_python_base_sources = \
268 269
	lib/_autoconf.py \
270
	lib/_constants.py \
269 271
	lib/_vcsversion.py \
270 272
	lib/opcodes.py
271 273

  
......
549 551
	test/hs/htest \
550 552
	$(HS_COMPILE_PROGS)
551 553

  
552
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS))
554
HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) src/hs2py-constants.hs
553 555
HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail
554 556

  
555 557
HFLAGS = \
......
634 636
	src/Ganeti/Hs2Py/GenConstants.hs \
635 637
	src/Ganeti/Hs2Py/GenOpCodes.hs \
636 638
	src/Ganeti/Hs2Py/OpDoc.hs \
639
	src/Ganeti/HsConstants.hs \
637 640
	src/Ganeti/JQueue.hs \
638 641
	src/Ganeti/JSON.hs \
639 642
	src/Ganeti/Jobs.hs \
......
722 725

  
723 726
HS_BUILT_SRCS = \
724 727
	test/hs/Test/Ganeti/TestImports.hs \
728
	src/Ganeti/Hs2Py/ListConstants.hs \
725 729
	src/Ganeti/PyConstants.hs \
726 730
	src/Ganeti/Curl/Internal.hs \
727 731
	src/Ganeti/Version.hs
728 732
HS_BUILT_SRCS_IN = \
729 733
	$(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \
730 734
	src/Ganeti/Curl/Internal.hsc \
735
	lib/_constants.py.in \
731 736
	lib/opcodes.py.in_after \
732 737
	lib/opcodes.py.in_before
733 738

  
......
895 900
	done
896 901
endif
897 902

  
903
# This target cannot be merged with the '$(HS_ALL_PROGS)' target
904
# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'.  And
905
# the reason for this is because 'hs2py-constants' needs to generate
906
# Python code, and 'Ganeti.Constants' is generated by Python.
907
src/hs2py-constants: src/hs2py-constants.hs src/Ganeti/BasicTypes.hs \
908
		     src/Ganeti/JSON.hs src/Ganeti/THH.hs \
909
		     src/Ganeti/Hs2Py/GenConstants.hs \
910
		     src/Ganeti/Hs2Py/ListConstants.hs \
911
		     src/Ganeti/HsConstants.hs \
912
		     src/Ganeti/PyValueInstances.hs \
913
		   | stamp-srclinks
914
	$(GHC) --make \
915
	  $(HFLAGS) \
916
	  -osuf $(notdir $@).o -hisuf $(notdir $@).hi \
917
	  $(HEXTRA) $(HEXTRA_INT) src/hs2py-constants.hs
918

  
898 919
$(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile
899 920
	@if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \
900 921
	  echo "Error: cannot run unittests without the development" \
......
1611 1632
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \
1612 1633
	sed -e "s/%ver%/$$VCSVER/" < $< > $@
1613 1634

  
1635
src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \
1636
				   src/Ganeti/HsConstants.hs \
1637
			         | stamp-directories
1638
	@echo Generating $@
1639
	@set -e; \
1640
## Extract constant names from 'HsConstants.hs' by extracting the left
1641
## side of all lines containing an equal sign (i.e., '=') and
1642
## prepending the apostrophe sign (i.e., "'").
1643
##
1644
## For example, the constant
1645
##   adminstDown = ...
1646
## becomes
1647
##   'adminstDown
1648
	NAMES=$$(sed -n -e "/=/ s/\(.*\) =.*/    '\1:/g p" \
1649
		 $(abs_top_srcdir)/src/Ganeti/HsConstants.hs); \
1650
	m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@
1651

  
1614 1652
src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \
1615 1653
	lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \
1616 1654
	lib/jstore.py $(RUN_IN_TEMPDIR) \
......
1716 1754
	  echo "}"; \
1717 1755
	} > $@
1718 1756

  
1757
lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \
1758
		 | stamp-directories
1759
	cat $(abs_top_srcdir)/lib/_constants.py.in > $@
1760
	src/hs2py-constants >> $@
1761

  
1762
lib/constants.py: lib/_constants.py
1763

  
1719 1764
lib/_vcsversion.py: Makefile vcs-version | stamp-directories
1720 1765
	set -e; \
1721 1766
	VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \

Also available in: Unified diff