[buildout]
# You need to define rootdir and destdir on an upper level
#rootdir = %TARGET_DIRECTORY%
#destdir = %BUILD_ROOT_DIRECTORY% 
#builddir = %BUILD_DIRECTORY%
extends =
  buildout.cfg

# Don't load extensions
extensions =
  slapos.rebootstrap

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

[gcc]
# force usage of gcc from slapos
max_version = 0

# Uguu, upstream buildout.cfg must be patched as it works the other way
# around from a packager point of view at least, thus at the end static
# path, such as Python HOME directory, are wrong...
#
# Currently:
# ./configure --prefix=BUILD_DIRECTORY && make install
# Instead of:
# ./configure --prefix=INSTALL_DIRECTORY && make install DESTDIR=BUILD_DIRECTORY
[python2.7]
configure-options +=
  --prefix=${buildout:rootdir}/parts/${:_buildout_section_name_}
environment +=
  DESTDIR=${buildout:destdir}

[gettext]
# Add gettext library path to RPATH as its binaries are used to build
# glib for example
environment =
  PATH=${perl:location}/bin:${lunzip:location}/bin:%(PATH)s
  CPPFLAGS=-I${libxml2:location}/include -I${zlib:location}/include -I${ncurses:location}/include
  LDFLAGS=-L${libxml2:location}/lib -Wl,-rpath=${libxml2:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib -L${ncurses:location}/lib -Wl,-rpath=${ncurses:location}/lib -Wl,-rpath=${buildout:builddir}/parts/${:_buildout_section_name_}/lib

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

environment +=
  PERL5LIB=${perl:location}/lib/5.28.1/

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

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

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

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


[dbus]
location = ${buildout:parts-directory}/${:_buildout_section_name_}
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]
location = ${buildout:parts-directory}/${:_buildout_section_name_}
environment +=
  CPPFLAGS=-I${libexpat:location}/include -I${dbus:location}/include/dbus-1.0 -I${dbus:location}/lib/dbus-1.0/include
  LDFLAGS=-L${libexpat:location}/lib -L${gettext:location}/lib -Wl,-rpath=${zlib:location}/lib -L${dbus:location}/lib -Wl,-rpath=${dbus:location}/lib
  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 +=
  PATH=${pkgconfig:location}/bin:${python:location}/bin:%(PATH)s
  LD_LIBRARY_PATH=${dbus:location}/lib
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${dbus:location}/lib -Wl,-rpath=${dbus:location}/lib
  PYTHON=${python:location}/bin/python${python:version}
  PYTHON_INCLUDES=-I${python:location}/include/python${python:version}
  PYTHON_LIBS=-L${python:location}/lib -lpython${python:version} -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]
prefix = ${buildout:rootdir}/parts/${:_buildout_section_name_}
location = ${buildout:parts-directory}/${:_buildout_section_name_}
make-options +=
  INSTALL_PREFIX=${buildout:destdir}
  DESTDIR=${buildout:destdir}
 
environment =
  PERL5LIB=${perl:location}/lib/5.28.1/
  PERL=${perl:location}/bin/perl

[bison-go]
<= bison
configure-options =
  --prefix=${buildout:parts-directory}/${:_buildout_section_name_}
make-options =

[gobject-introspection]
pre-configure =
  ln -s ${python:location}/bin/python${python:version} ${python:location}/bin/python2.
  sed -i 's#!/opt/slapos/parts/python2.7/bin/python2.7#!${python2.7:location}/bin/python2.7#' ${python2.7:location}/bin/python-config
  libtoolize -c -f
  aclocal -I${pkgconfig:location}/share/aclocal -I${gettext:location}/share/aclocal -I${libtool:location}/share/aclocal -I${glib:location}/share/aclocal
  ./autogen.sh
configure-options +=
  --enable-shared
environment +=
  PATH=${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:${libtool:location}/bin:${intltool:location}/bin:${gettext:location}/bin:${glib:location}/bin:${flex:location}/bin:${bison-go:location}/bin:%(PATH)s
  GIR_DIR=${buildout:parts-directory}/${:_buildout_section_name_}/share/gir-1.0
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include -I${python:location}/include/python${python:version}
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${libffi:location}/lib -Wl,-rpath=${libffi:location}/lib -lffi -L${python:location}/lib
  ACLOCAL_PATH=${pkgconfig:location}/share/aclocal:${gettext:location}/share/aclocal:${libtool:location}/share/aclocal:${glib:location}/share/aclocal:${intltool:location}/share/aclocal
  M4=${m4:location}/bin/m4
  PERL5LIB=${perl:location}/lib/5.28.1/

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-config
  rm -rf ${bison-go:location}

[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-config
environment +=
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include -I${gettext:location}/include -I${libffi:location}/include -I${python:location}/include/python${python:version}
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${gettext:location}/lib -Wl,-rpath=${gettext:location}/lib -L${python:location}/lib
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-config

[ncurses]
configure-options =
  --prefix=${buildout:parts-directory}/${:_buildout_section_name_}
  --with-shared
  --without-ada
  --without-manpages
  --without-tests
  --without-normal
  --without-debug
  --without-gpm
  --enable-rpath

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


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

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

[perl]
location = ${buildout:destdir}/parts/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}

[versions]
# More recently version of cliff uses pbr which will break package build on OBS.
cliff = 1.4.5
