X-Git-Url: https://code.grnet.gr/git/ganeti-local/blobdiff_plain/d34c79b6efd5ffc37af388151bf9d07a40f8e350..1b2adaa67411daf827d91f5169e859a1571200b8:/Makefile.am diff --git a/Makefile.am b/Makefile.am index 4dc6a7b..3e40ded 100644 --- a/Makefile.am +++ b/Makefile.am @@ -240,6 +240,7 @@ CLEANFILES = \ src/ganeti-confd \ src/ganeti-luxid \ src/ganeti-mond \ + src/hs2py-constants \ .hpc/*.mix src/*.tix test/hs/*.tix \ doc/hs-lint.html @@ -266,6 +267,7 @@ built_base_sources = \ built_python_base_sources = \ lib/_autoconf.py \ + lib/_constants.py \ lib/_vcsversion.py \ lib/opcodes.py @@ -549,7 +551,7 @@ HS_ALL_PROGS = \ test/hs/htest \ $(HS_COMPILE_PROGS) -HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) +HS_PROG_SRCS = $(patsubst %,%.hs,$(HS_ALL_PROGS)) src/hs2py-constants.hs HS_BUILT_TEST_HELPERS = $(HS_BIN_ROLES:%=test/hs/%) test/hs/hail HFLAGS = \ @@ -586,6 +588,7 @@ HS_LIB_SRCS = \ src/Ganeti/Confd/Utils.hs \ src/Ganeti/Config.hs \ src/Ganeti/ConfigReader.hs \ + src/Ganeti/Constants.hs \ src/Ganeti/Cpu/LoadParser.hs \ src/Ganeti/Cpu/Types.hs \ src/Ganeti/Curl/Multi.hs \ @@ -633,6 +636,7 @@ HS_LIB_SRCS = \ src/Ganeti/Hs2Py/GenConstants.hs \ src/Ganeti/Hs2Py/GenOpCodes.hs \ src/Ganeti/Hs2Py/OpDoc.hs \ + src/Ganeti/HsConstants.hs \ src/Ganeti/JQueue.hs \ src/Ganeti/JSON.hs \ src/Ganeti/Jobs.hs \ @@ -721,12 +725,14 @@ HS_LIBTEST_SRCS = $(HS_LIB_SRCS) $(HS_TEST_SRCS) HS_BUILT_SRCS = \ test/hs/Test/Ganeti/TestImports.hs \ - src/Ganeti/Constants.hs \ + src/Ganeti/Hs2Py/ListConstants.hs \ + src/Ganeti/PyConstants.hs \ src/Ganeti/Curl/Internal.hs \ src/Ganeti/Version.hs HS_BUILT_SRCS_IN = \ $(patsubst %,%.in,$(filter-out src/Ganeti/Curl/Internal.hs,$(HS_BUILT_SRCS))) \ src/Ganeti/Curl/Internal.hsc \ + lib/_constants.py.in \ lib/opcodes.py.in_after \ lib/opcodes.py.in_before @@ -894,6 +900,22 @@ install-exec-hook: done endif +# This target cannot be merged with the '$(HS_ALL_PROGS)' target +# because 'hs2py-constants' cannot depend on 'Ganeti.Constants'. And +# the reason for this is because 'hs2py-constants' needs to generate +# Python code, and 'Ganeti.Constants' is generated by Python. +src/hs2py-constants: src/hs2py-constants.hs src/Ganeti/BasicTypes.hs \ + src/Ganeti/JSON.hs src/Ganeti/THH.hs \ + src/Ganeti/Hs2Py/GenConstants.hs \ + src/Ganeti/Hs2Py/ListConstants.hs \ + src/Ganeti/HsConstants.hs \ + src/Ganeti/PyValueInstances.hs \ + | stamp-srclinks + $(GHC) --make \ + $(HFLAGS) \ + -osuf $(notdir $@).o -hisuf $(notdir $@).hi \ + $(HEXTRA) $(HEXTRA_INT) src/hs2py-constants.hs + $(HS_ALL_PROGS): %: %.hs $(HS_LIBTESTBUILT_SRCS) Makefile @if [ "$(notdir $@)" = "test" ] && [ "$(HS_NODEV)" ]; then \ echo "Error: cannot run unittests without the development" \ @@ -1610,7 +1632,24 @@ src/Ganeti/Version.hs: src/Ganeti/Version.hs.in \ VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \ sed -e "s/%ver%/$$VCSVER/" < $< > $@ -src/Ganeti/Constants.hs: src/Ganeti/Constants.hs.in \ +src/Ganeti/Hs2Py/ListConstants.hs: src/Ganeti/Hs2Py/ListConstants.hs.in \ + src/Ganeti/HsConstants.hs \ + | stamp-directories + @echo Generating $@ + @set -e; \ +## Extract constant names from 'HsConstants.hs' by extracting the left +## side of all lines containing an equal sign (i.e., '=') and +## prepending the apostrophe sign (i.e., "'"). +## +## For example, the constant +## adminstDown = ... +## becomes +## 'adminstDown + NAMES=$$(sed -n -e "/=/ s/\(.*\) =.*/ '\1:/g p" \ + $(abs_top_srcdir)/src/Ganeti/HsConstants.hs); \ + m4 -DPY_CONSTANT_NAMES="$$NAMES" $(abs_top_srcdir)/$< > $@ + +src/Ganeti/PyConstants.hs: src/Ganeti/PyConstants.hs.in \ lib/constants.py lib/_autoconf.py lib/luxi.py lib/errors.py \ lib/jstore.py $(RUN_IN_TEMPDIR) \ $(CONVERT_CONSTANTS) $(built_base_sources) \ @@ -1715,6 +1754,13 @@ lib/_autoconf.py: Makefile | stamp-directories echo "}"; \ } > $@ +lib/_constants.py: Makefile lib/_constants.py.in src/hs2py-constants \ + | stamp-directories + cat $(abs_top_srcdir)/lib/_constants.py.in > $@ + src/hs2py-constants >> $@ + +lib/constants.py: lib/_constants.py + lib/_vcsversion.py: Makefile vcs-version | stamp-directories set -e; \ VCSVER=`cat $(abs_top_srcdir)/vcs-version`; \ @@ -1736,7 +1782,7 @@ lib/_vcsversion.py: Makefile vcs-version | stamp-directories echo "VCS_VERSION = '$$VCSVER'"; \ } > $@ -lib/opcodes.py: Makefile src/hs2py src/Ganeti/Constants.hs \ +lib/opcodes.py: Makefile src/hs2py src/Ganeti/PyConstants.hs \ lib/opcodes.py.in_before lib/opcodes.py.in_after \ | stamp-directories cat $(abs_top_srcdir)/lib/opcodes.py.in_before > $@