[buildout]
extends =
  ../autoconf/buildout.cfg
  ../automake/buildout.cfg
  ../git/buildout.cfg
  ../glib/buildout.cfg
  ../libtool/buildout.cfg
  ../make/buildout.cfg
  ../pkgconfig/buildout.cfg
  ../texinfo/buildout.cfg
  ../zeromq/buildout.cfg

#########
# Cleanup
#########

#[zerovm-cleanup]
#recipe = plone.recipe.command
#command = rm -r ${buildout:parts-directory}/zerovm*
#stop-on-error = false

##########
# Download
##########

[zerovm-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = zerovm
revision = e18e0d7959b636fe21919e692adb61373faaebba
strip-top-level-dir = true


[zerovm-validator-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
revision = b37f603854220fd7ea00c400df84d1b57b1a669f
repository-name = validator
destination = ${zerovm-source:location}/valz
strip-top-level-dir = true


[zerovm-zrt-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = zrt
revision = fb1ddedc17c8cc642d0db7342eb4e3d082592242
strip-top-level-dir = true
#md5sum =


[zerovm-toolchain-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = toolchain
revision = 4e2904fe0cf313cebd323526652259babf00a2ea
strip-top-level-dir = true


[zerovm-linux-headers-for-nacl-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = linux-headers-for-nacl
revision = 5ad6d9bd4edcd02d004b8f5f0b5575b1ad725dd6
destination = ${zerovm-toolchain-source:location}/SRC/linux-headers-for-nacl
strip-top-level-dir = true

[zerovm-gcc-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = gcc
revision = db21864a3d1d8045f48d6017a7631fcfa8e5ad75
destination = ${zerovm-toolchain-source:location}/SRC/gcc
strip-top-level-dir = true

[zerovm-glibc-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = glibc
revision = 7bf286b0d2f00e72a8e6f28f266c8ac09acd9f1c
destination = ${zerovm-toolchain-source:location}/SRC/glibc
strip-top-level-dir = true

[zerovm-newlib-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = newlib
revision = 625975a5e3bd5cc624f042795f8d9895caa927c9
destination = ${zerovm-toolchain-source:location}/SRC/newlib
strip-top-level-dir = true

[zerovm-binutils-source]
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/${:revision}.zip
repository-name = binutils
revision = e0648d331e12a691e41645592005e72ace44667b
destination = ${zerovm-toolchain-source:location}/SRC/binutils
strip-top-level-dir = true

#########
# Install
#########

[zerovm]
recipe = plone.recipe.command
path = ${zerovm-source:location}
# Hack
location = ${buildout:parts-directory}/${:_buildout_section_name_}
stop-on-error = true
# Arbitrary parameter used to force buildout to process dependencies
depends =
  ${zerovm-validator-source:location}
  ${zerovm-toolchain-source:location}
  ${zerovm-linux-headers-for-nacl-source:location}
  ${zerovm-gcc-source:location}
  ${zerovm-glibc-source:location}
  ${zerovm-newlib-source:location}
  ${zerovm-binutils-source:location}
command =
  export PATH=${autoconf:location}/bin:${automake:location}/bin:${libtool:location}/bin:${make:location}/bin:${texinfo:location}/bin:${pkgconfig:location}/bin:$PATH && \
  export ZEROVM_ROOT=${zerovm-source:location} && \
  export ZVM_PREFIX=${:location} && \
  export PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig && \
  export ZRT_ROOT=${zerovm-zrt-source:location} && \
#  make -C ${zerovm-source:location} clean && \
  rm -rf ${:location} && \
  mkdir -p ${:location} && \
  make -C ${zerovm-toolchain-source:location} clean && \
  make -C ${zerovm-validator-source:location} validator && \
  DESTDIR=${:location} make -C ${zerovm-validator-source:location} install && \
  TAG_ENCRYPTION="G_CHECKSUM_SHA1 -I${zeromq2:location}/include" make -C ${zerovm-source:location} all && \
  make -C ${zerovm-source:location} install PREFIX=$ZVM_PREFIX && \
#  MAKEFLAGS="" \
# Require gcc i386, glibc i396 and libstdc++ i386 to be installed (main packages + headers)
  make -C ${zerovm-toolchain-source:location}


########
#zpython
########

# XXX: deploy standalone zpython, instead of examples

[zerovm-samples-source]
# Hack
location = ${buildout:parts-directory}/${:_buildout_section_name_}
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/master.zip
repository-name = zerovm-samples
strip-top-level-dir = true
#md5sum =

[zerovm-zpython-source]
# Hack
location = ${buildout:parts-directory}/${:_buildout_section_name_}
recipe = hexagonit.recipe.download
url = https://github.com/zerovm/${:repository-name}/archive/master.zip
repository-name = zpython
strip-top-level-dir = true
destination = ${zerovm-samples-source:location}/zshell/zpython
ignore-existing = true
#md5sum =

[zerovm-samples]
# Hack
depends =
  ${zerovm:location}
  ${zerovm-zpython-source:location}
  ${zerovm-samples-source:location}
recipe = plone.recipe.command
command=
  export PATH=${autoconf:location}/bin:${automake:location}/bin:${libtool:location}/bin:${texinfo:location}/bin:${pkgconfig:location}/bin:${zerovm:location}/bin:$PATH && \
  export PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig && \
  export ZRT_ROOT=${zerovm-zrt-source:location} && \
  export ZEROVM_ROOT=${zerovm-source:location} && \
  export ZVM_PREFIX=${zerovm:location} && \
  make -C ${zerovm-samples-source:location}/zshell zpython && \
  make -C ${zerovm-samples-source:location}/zshell createdirs zshell.nexe
stop-on-error=true