[buildout]
# You need to define rootdir and destdir on an upper level
#
# rootdir is where the parts will be installed by the debian package (e.g. /opt/slapos)
# destdir is where we can put the files during compilation (e.g. /tmp/build-slapos)
# buildout MUST BE launched in $destdir/$rootdir (this is enforced by an assert)
#
# in this file, we teach many packages to use prefix = $rootdir/parts/package and we
# set DESTDIR = $destdir so in reality the files land in $destdir/$rootdir/parts/package
# which is EXACTLY what cmmi recipe uses by default (buildout run dir/parts/package)
# that's why everything is working
#
# please be careful when touching this file

#rootdir = %TARGET_DIRECTORY%
#destdir = %BUILD_ROOT_DIRECTORY%

extends =
  buildout.cfg

# Don't load extensions
extensions =
  slapos.rebootstrap

extends-cache = extends-cache
download-cache = download-cache

[python]
init +=
  buildout = self.buildout['buildout']
  assert buildout['directory'] == buildout['destdir'] + buildout['rootdir'], (
    "Buildout MUST BE launched in destdir/rootdir (currently launched in %s but should be launched in %s)" %
    (buildout['directory'], buildout['destdir'] + buildout['rootdir']))

[python3-common]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
environment +=
  DESTDIR=${buildout:destdir}

[bison]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
make-options +=
  DESTDIR=${buildout:destdir}
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/

[intltool]
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/

[autoconf]
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/

[automake]
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/

[firewalld]
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/


[dbus]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
make-options +=
  DESTDIR=${buildout:destdir}
environment +=
  LDFLAGS=-L${libexpat:location}/lib -L${buildout:parts-directory}/${:_buildout_section_name_}/lib -Wl,-rpath=${buildout:parts-directory}/${:_buildout_section_name_}/lib
  LD_LIBRARY_PATH=${buildout:parts-directory}/${:_buildout_section_name_}/lib
post-install =
  mkdir -p ${buildout:destdir}/parts/${:_buildout_section_name_}/var/run/dbus

[dbus-glib]
environment +=
  LD_LIBRARY_PATH=${dbus:location}/lib
  DBUS_CFLAGS=-I${dbus:location}/include/dbus-1.0 -I${dbus:location}/lib/dbus-1.0/include


[dbus-python]
pre-configure =
  sed -i 's#/opt/slapos/parts/dbus/lib/libdbus-1.la#${dbus:location}/lib/libdbus-1.la#' ${dbus-glib:location}/lib/libdbus-glib-1.la
environment +=
  LD_LIBRARY_PATH=${dbus:location}/lib
  PYTHON_INCLUDES=-I${python:location}/include/python${python:version}m
  PYTHON_LIBS=-L${python:location}/lib -lpython${python:version}m -lpthread -ldl -lutil -lm
post-install =
  sed -i 's#${dbus:location}/lib/libdbus-1.la#/opt/slapos/parts/dbus/lib/libdbus-1.la#' ${dbus-glib:location}/lib/libdbus-glib-1.la

[openssl]
shared = false
prefix = ${buildout:rootdir}/parts/${:_buildout_section_name_}
make-options +=
  INSTALL_PREFIX=${buildout:destdir}
  DESTDIR=${buildout:destdir}
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/

[gobject-introspection]
pre-configure =
  sed -i 's#!/opt/slapos/parts/python${python:version}/bin/python${python:version}#!${python:location}/bin/python${python:version}#' ${python:location}/bin/python${python:version}-config
configure-options +=
  --enable-shared
environment +=
  PERL5LIB=${perl:location}/lib/5.38.0/
post-install =
  sed -i 's#!${python:location}/bin/python${python:version}#!/opt/slapos/parts/python${python:version}/bin/python${python:version}#' ${python:location}/bin/python${python:version}-config

[pygobject3]
pre-configure +=
  sed -i 's#!/opt/slapos/parts/python${python:version}/bin/python${python:version}#!${python:location}/bin/python${python:version}#' ${python:location}/bin/python${python:version}-config
post-install =
  sed -i 's#!${python:location}/bin/python${python:version}#!/opt/slapos/parts/python${python:version}/bin/python${python:version}#' ${python:location}/bin/python${python:version}-config

[flex]
environment +=
 BISON_PKGDATADIR=${bison:location}/share/bison/


[perl-CPAN-package]
perl-PERL5LIB=${perl:location}/lib/5.38.0/

pre-configure =
  sed -i "s#'/opt/slapos/parts/perl#'${perl:location}#" ${perl:location}/lib/5.38.0/*-linux-thread-multi/Config.pm
  sed -i "s#'/opt/slapos/parts/site_perl#'${buildout:destdir}/parts/site_perl#" ${perl:location}/lib/5.38.0/*-linux-thread-multi/Config.pm
post-install =
  sed -i "s#'${perl:location}#'/opt/slapos/parts/perl#" ${perl:location}/lib/5.38.0/*-linux-thread-multi/Config.pm
  sed -i "s#'${buildout:destdir}/parts/site_perl#'/opt/slapos/parts/site_perl#" ${perl:location}/lib/5.38.0/*-linux-thread-multi/Config.pm

[perl]
configure-command =
  sh Configure -des \
    -Dprefix=${buildout:rootdir}/parts/${:_buildout_section_name_} \
    -Dsiteprefix=${buildout:rootdir}/parts/site_${:_buildout_section_name_} \
    -Dcflags=-I${gdbm:location}/include \
    -Dldflags="-L${gdbm:location}/lib -Wl,-rpath=${gdbm:location}/lib" \
    -Ui_db \
    -Dnoextensions=ODBM_File \
    -Dusethreads
environment +=
  DESTDIR=${buildout:destdir}

[iptables]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
environment +=
  DESTDIR=${buildout:destdir}

[swig]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
environment +=
  DESTDIR=${buildout:destdir}
