src/ganeti-confd \
src/ganeti-luxid \
src/ganeti-mond \
+ src/hs2py-constants \
.hpc/*.mix src/*.tix test/hs/*.tix \
doc/hs-lint.html
built_python_base_sources = \
lib/_autoconf.py \
+ lib/_constants.py \
lib/_vcsversion.py \
lib/opcodes.py
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 = \
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 \
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 \
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
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" \
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) \
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`; \
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 > $@