[buildout]

extends = 
  ../../component/flex/buildout.cfg
  ../../component/bison/buildout.cfg
  ../../component/qt/buildout.cfg
  ../../component/gtk-2/buildout.cfg
  ../../component/alsa/buildout.cfg
  ../../component/java/buildout.cfg
  ../../component/qt/buildout.cfg
  ../../component/gcc/buildout.cfg
  ../../component/git/buildout.cfg
  ../../component/fontconfig/buildout.cfg

  ../glib/buildout.cfg
  ../xorg/buildout.cfg

  ../../component/cmake/buildout.cfg
  ../libdb/buildout.cfg
  ../zlib/buildout.cfg
  ../../component/java-openjdk/buildout.cfg
#  ../../component/automake/buildout.cfg
  ../gnutls/buildout.cfg
  ../python3/buildout.cfg
  ../mesa/buildout.cfg

# to move to xorg with type1
  ../freetype/buildout.cfg

parts = 
  pwr

#[java-openjdk]
#recipe = hexagonit.recipe.download
#url = https://download.java.net/java/GA/jdk12.0.2/e482c34c86bd4bf8b56c0b35558996b9/10/GPL/openjdk-12.0.2_linux-x64_bin.tar.gz
#md5sum = f5da6f4dec81bdd2a096184ec1d69216
#strip-top-level-dir = true

[doxygen]
recipe = slapos.recipe.cmmi
url = http://doxygen.nl/files/doxygen-1.8.16.src.tar.gz
md5sum = 3ec5f8bfda38a05845161fbbd5d8b439
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  mkdir build && cd build && \
  ${cmake:location}/bin/cmake \
  -DCMAKE_INSTALL_PREFIX=${:location} \
  -G "Unix Makefiles" ../
make-binary =
  cd build && make
environment =
  PATH=${git:location}/bin:${cmake:location}/bin:${flex:location}/bin:${bison:location}/bin:%(PATH)s

[make-4]
recipe = slapos.recipe.cmmi
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  libtoolize --force
  aclocal -I${pkgconfig:location}/share/aclocal -I${gettext:location}/share/aclocal -I${libtool:location}/share/aclocal
  autoheader
  automake --force-missing --add-missing
  autoconf
  ./configure
url = http://ftp.de.debian.org/debian/pool/main/m/make-dfsg/make-dfsg_4.2.1.orig.tar.gz
make-targets = install
environment =
  PATH=${autoconf:location}/bin:${automake:location}/bin:${libtool:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  LDFLAGS=-L${gettext:location}/lib

[extra-cmake-modules]
recipe = slapos.recipe.cmmi
url = https://github.com/KDE/extra-cmake-modules/archive/v5.62.0.zip
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  mkdir build && cd build && \
  ${cmake:location}/bin/cmake \
    -DCMAKE_INSTALL_PREFIX=${:location} \
    -DQt5LinguistTools_DIR=${qt5-qmake:location}/lib/cmake/Qt5LinguistTools \
   ..
make-binary = cd build && make
environment = 
  PATH=${qt5-qmake:location}/bin:${qt5-tools:location}/bin:%(PATH)s

[phonon]
recipe = slapos.recipe.cmmi
url = http://download.kde.org/stable/phonon/4.11.1/phonon-4.11.1.tar.xz
md5sum = d3df5ba646e4b3f11623d998caa40e74
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  mkdir build && cd build && \
  ${cmake:location}/bin/cmake \
    -DCMAKE_INSTALL_PREFIX=${:location} \
    -DCMAKE_BUILD_TYPE=Release  \
    -DECM_DIR=${extra-cmake-modules:location}/share/ECM/cmake \
    -DQt5LinguistTools_DIR=${qt5-qmake:location}/lib/cmake/Qt5LinguistTools \
    -DQt5Core_DIR=${qt5-qmake:location}/lib/cmake/Qt5Core \
    -DQt5Gui_DIR=${qt5-qmake:location}/lib/cmake/Qt5Gui \
    -DQt5Widgets_DIR=${qt5-qmake:location}/lib/cmake/Qt5Widgets \
    -DQt5Designer_DIR=${qt5-qmake:location}/lib/cmake/Qt5Designer \
    -DGLIB2_LIBRARIES=${glib:location}/lib \
    -DGLIB2_MAIN_INCLUDE_DIR=${glib:location}/lib/glib-2.0/include \
    ..
make-binary = cd build && make
environment =
  PATH=${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig:${pcre:location}/lib/pkgconfig:${qt5-qmake:location}/lib/pkgconfig
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib

[phonon-qt4]
<= phonon
url = https://github.com/KDE/phonon/archive/4.10.tar.gz
md5sum = 1c6f5ad1ec3b2943011364acac8e1847
configure-command =
  mkdir build && cd build && \
  ${cmake:location}/bin/cmake \
    -DCMAKE_INSTALL_PREFIX=${:location} \
    -DCMAKE_BUILD_TYPE=Release  \
    -DPHONON_BUILD_PHONON4QT5=FALSE \
    -DGLIB2_LIBRARIES=${glib:location}/lib \
    -DGLIB2_MAIN_INCLUDE_DIR=${glib:location}/lib/glib-2.0/include \
    -DCMAKE_INCLUDE_PATH=-I${qt4-qmake:location}/include \
    -DCMAKE_CXX_FLAGS=-I${qt4-qmake:location}/include \
    ..
make-binary = cd build && make
environment =
  PATH=${qt4-qmake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${glib:location}/lib/pkgconfig:${pcre:location}/lib/pkgconfig:${qt4-qmake:location}/lib/pkgconfig
  CPPFLAGS=-I${glib:location}/include/glib-2.0 -I${glib:location}/lib/glib-2.0/include -I${qt4-qmake:location}/include
  LDFLAGS=-L${glib:location}/lib -Wl,-rpath=${glib:location}/lib -L${qt4-qmake:location}/lib

[get-pip]
recipe = slapos.recipe.build:download
# version 19.2.3
url = https://github.com/pypa/get-pip/raw/309a56c5fd94bd1134053a541cb4657a4e47e09d/${:filename}
md5sum = 6f489c199cb5be8a4b84c6bd7ad6e051
filename = get-pip.py
mode = 0755

[intall-pip]
recipe = plone.recipe.command
command = ${python3.5:location}/bin/python3.5 ${get-pip:target}
stop-on-error = true

[meson]
recipe = slapos.recipe.cmmi
url = https://github.com/mesonbuild/meson/releases/download/0.52.0/meson-0.52.0.tar.gz
configure-command = true
make-binary = ${python3.5:location}/bin/pip3 install meson --prefix=${:location}
make-targets =
location = ${buildout:parts-directory}/${:_buildout_section_name_}
depends = ${intall-pip:recipe}

[ninja]
recipe = slapos.recipe.cmmi
url = https://github.com/mesonbuild/meson/releases/download/0.52.0/meson-0.52.0.tar.gz
configure-command = true
make-binary = ${python3.5:location}/bin/pip3 install ninja --prefix=${:location}
make-targets =
location = ${buildout:parts-directory}/${:_buildout_section_name_}
depends = ${intall-pip:recipe}

[libepoxy]
recipe = slapos.recipe.cmmi
shared = true
url = https://github.com/anholt/libepoxy/releases/download/1.5.3/libepoxy-1.5.3.tar.xz
md5sum = e2845de8d2782b2d31c01ae8d7cd4cbb
#location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  #sed -i '20s/value: true/value: false/' $${:location}__compile__/libepoxy-1.5.3/meson_options.txt
  echo "current working directory is `pwd`" &&\
  sed -i '20s/value: true/value: false/' meson_options.txt &&\
  mkdir build && cd build && \
  ${meson:location}/bin/meson --prefix=%(prefix)s \
  #$${meson:location}/bin/meson --prefix=$${:location} \
    
make-binary = cd build && ${ninja:location}/bin/ninja
environment =
  PATH=${ninja:location}/bin:${pkgconfig:location}/bin:${cmake:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${mesa:location}/lib/pkgconfig:${libX11:location}/lib/pkgconfig:${xproto:location}/lib/pkgconfig:${libXext:location}/lib/pkgconfig
  PYTHONPATH=${ninja:location}/lib/python3.5/site-packages/:${meson:location}/lib/python3.5/site-packages/
  CFLAGS=-I${mesa:location}/include -I${libX11:location}/include -I${xproto:location}/include -I${glu:location}/include
  LDFLAGS=-L${libX11:location}/lib -L${mesa:location}/lib -Wl,-rpath=${mesa:location}/lib -L${libXext:location}/lib -Wl,-rpath=${libXext:location}/lib -L${xproto:location}/lib -Wl,-rpath=${xproto:location}/lib

[libdrm]
recipe = slapos.recipe.cmmi
url = https://dri.freedesktop.org/libdrm/libdrm-2.4.100.tar.bz2
configure-options =
  --enable-static
  --disable-udev
#  --disable-radeon
  --disable-amdgpu
#  --disable-nouveau
  --disable-manpages
 
environment =
  PKG_CONFIG=${pkgconfig:location}/bin/pkg-config
  PKG_CONFIG_PATH=${pciaccess:location}/lib/pkgconfig 
 
[mesa]
# enable gbm require apt-get install libudev-dev
# that can be provided by
# component/systemd.  but current component/systemd can be built only
# with Linux kernel >= 3.7.
configure-options =
#  --enable-static
  --disable-gles1
  --disable-gles2
#  --disable-dri
  --disable-dri3
  --enable-egl
  --enable-gbm
  --disable-xvmc
  --disable-vdpau
  --disable-va
#  --enable-xlib-glx
#  --disable-shared-glapi
  --disable-driglx-direct
  --disable-gallium-llvm
  --with-gallium-drivers=
#  --with-dri-drivers=swrast
#  --without-dri-drivers
  --enable-dri
  --enable-sysfs
  --enable-shared-glapi
environment =
  PKG_CONFIG=${pkgconfig:location}/bin/pkg-config
  PKG_CONFIG_PATH=${damageproto:location}/lib/pkgconfig:${fixesproto:location}/lib/pkgconfig:${glproto:location}/lib/pkgconfig:${kbproto:location}/lib/pkgconfig:${libX11:location}/lib/pkgconfig:${libXau:location}/lib/pkgconfig:${libXext:location}/lib/pkgconfig:${libexpat:location}/lib/pkgconfig:${libxcb:location}/lib/pkgconfig:${xdamage:location}/lib/pkgconfig:${xextproto:location}/lib/pkgconfig:${xfixes:location}/lib/pkgconfig:${xorg-libpthread-stubs:location}/lib/pkgconfig:${xproto:location}/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:${libdrm:location}/lib/pkgconfig

[xserver]
configure-options =
  --enable-xvfb
  --disable-composite
  --disable-screensaver
  --disable-glx
  --disable-dri
  --disable-dri2
  --enable-xorg
  --disable-config-hal
  --disable-tcp-transport
  --with-xkb-bin-directory=${xkbcomp:location}/bin
  --with-xkb-path=${xkeyboard-config:location}/share/X11/xkb
  --with-sha1=libgcrypt
environment =
  PIXMAN_CFLAGS=-I${pixman:location}/include
  PIXMAN_LIBS=${pixman:location}/lib
  GLAMOR_CFLAGS=-I${libepoxy:location}/include
  GLAMOR_LIBS=${libepoxy:location}/lib
  GBM_CFLAGS=-I${mesa:location}/include
  GBM_LIBS=${mesa:location}/lib
  PKG_CONFIG=${pkgconfig:location}/bin/pkg-config
  CFLAGS=-I${mesa:location}/include -I${libdrm:location}/include -I${libdrm:location}/include/libdrm -I${bzip2:location}/include -I${libgcrypt:location}/include -I${libgpg-error:location}/include -I${zlib:location}/include
  LDFLAGS=-L${bzip2:location}/lib -Wl,-rpath=${bzip2:location}/lib -L${libgcrypt:location}/lib -Wl,-rpath=${libgcrypt:location}/lib -L${libgpg-error:location}/lib -Wl,-rpath=${libgpg-error:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib -L${libgcrypt:location}/lib -Wl,-rpath=${libgcrypt:location}/lib -L${libdrm:location}/lib -Wl,-rpath=${libdrm:location}/lib
  PKG_CONFIG_PATH=${:pkg_config_path}

pkg_config_path = ${pixman:location}/lib/pkgconfig:${openssl:location}/lib/pkgconfig:${xorg-util-macros:location}/share/pkgconfig:${fixesproto:location}/lib/pkgconfig:${damageproto:location}/lib/pkgconfig:${xcmiscproto:location}/lib/pkgconfig:${xtrans:location}/share/pkgconfig:${bigreqsproto:location}/lib/pkgconfig:${xproto:location}/lib/pkgconfig:${xorgproto:pkg_config_depends}:${xorgproto:location}/share/pkgconfig:${renderproto:location}/lib/pkgconfig:${presentproto:location}/lib/pkgconfig:${xextproto:location}/lib/pkgconfig:${inputproto:location}/lib/pkgconfig:${kbproto:location}/lib/pkgconfig:${fontsproto:location}/lib/pkgconfig:${videoproto:location}/lib/pkgconfig:${recordproto:location}/lib/pkgconfig:${resourceproto:location}/lib/pkgconfig:${xineramaproto:location}/lib/pkgconfig:${libXau:location}/lib/pkgconfig:${libxkbfile:location}/lib/pkgconfig:${libXfont:location}/lib/pkgconfig:${libXfont2:location}/lib/pkgconfig:${libX11:location}/lib/pkgconfig:${libxcb:location}/lib/pkgconfig:${xorg-libpthread-stubs:location}/lib/pkgconfig:${libfontenc:location}/lib/pkgconfig:${freetype:pkg_config_depends}:${freetype:location}/lib/pkgconfig:${zlib:location}/lib/pkgconfig:${pciaccess:location}/lib/pkgconfig:${pixman:location}/lib/pkgconfig:${libgcrypt:location}/lib/pkgconfig:${libXdmcp:location}/lib/pkgconfig:${libepoxy:location}/lib/pkgconfig:${mesa:location}/lib/pkgconfig

[xorg-font-util]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/font/font-util-1.3.2.tar.bz2

[xorg-module-base]
recipe = slapos.recipe.cmmi
configure-options =
  --prefix=${xserver:location}
environment = 
  PKG_CONFIG_PATH=${xserver:location}/lib/pkgconfig:${xserver:pkg_config_path}
  PATH=${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:%(PATH)s

[xorg-video-dummy]
<= xorg-module-base
url = https://www.x.org/releases/individual/driver/xf86-video-dummy-0.3.8.tar.bz2

[xorg-input-mouse]
<= xorg-module-base
url = https://www.x.org/releases/individual/driver/xf86-input-mouse-1.9.3.tar.bz2

[xorg-video-fbdev]
<= xorg-module-base
url = https://www.x.org/releases/individual/driver/xf86-video-fbdev-0.5.0.tar.bz2

[xorg-input-kbd]
<= xorg-module-base
url = https://www.x.org/releases/individual/driver/xf86-input-keyboard-1.9.0.tar.bz2

[xorg-video-vesa]
<= xorg-module-base
url = https://www.x.org/releases/individual/driver/xf86-video-vesa-2.4.0.tar.bz2

[xorg-mkfontdir]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/app/mkfontdir-1.0.7.tar.bz2

[xorg-font-type1]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/font/font-bitstream-type1-1.0.3.tar.bz2
md5sum = 5e0c9895d69d2632e2170114f8283c11
environment =
  PATH=${xorg-mkfontdir:location}/bin:${xorg-mkfontscale:location}/bin:${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${xserver:location}/lib/pkgconfig:${xserver:pkg_config_path}:${xorg-font-util:location}/lib/pkgconfig

[xorg-font-adobe-100dpi]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/font/font-bh-100dpi-1.0.3.tar.bz2
environment =
  PATH=${xorg-font-util:location}/bin:${xorg-bdftopcf:location}/bin:${xorg-mkfontdir:location}/bin:${xorg-mkfontscale:location}/bin:${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${xserver:location}/lib/pkgconfig:${xserver:pkg_config_path}:${xorg-font-util:location}/lib/pkgconfig

[xorg-font-adobe-75dpi]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/font/font-bh-75dpi-1.0.3.tar.bz2
environment =
  PATH=${xorg-font-util:location}/bin:${xorg-bdftopcf:location}/bin:${xorg-mkfontdir:location}/bin:${xorg-mkfontscale:location}/bin:${autoconf:location}/bin:${automake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${xserver:location}/lib/pkgconfig:${xserver:pkg_config_path}:${xorg-font-util:location}/lib/pkgconfig

[xorg-mkfontscale]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/app/mkfontscale-1.2.1.tar.bz2
configure-options =
  --disable-static
environment =
  PATH=${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${freetype:pkg_config_depends}:${freetype:location}/lib/pkgconfig:${libfontenc:location}/lib/pkgconfig:${xserver:location}/lib/pkgconfig:${xserver:pkg_config_path}
  CPPFLAGS=-I${zlib:location}/include
  LDFLAGS=-L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib -Wl,-rpath=${libfontenc:location}/lib -Wl,-rpath=${freetype:location}/lib

[xorg-bdftopcf]
recipe = slapos.recipe.cmmi
url = https://www.x.org/releases/individual/app/bdftopcf-1.1.tar.bz2
environment =
  PATH=${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${xserver:pkg_config_path}:${fontsproto:location}/lib/pkgconfig
  CPPFLAGS=-I${xproto:location}/include -I${fontsproto:location}/include

[pwr]
recipe = slapos.recipe.cmmi
#url = https://iweb.dl.sourceforge.net/project/proview/proview/proviewr_${:version}/pwrsrc_${:version}.tar.gz
#md5sum = 2431b0ffec0de9e2d7b1a984b2e216a2
#url = https://github.com/siamect/proview/archive/cc5abd7852b38ae8007d8eedb36acc3a38e4b90d.tar.gz
#md5sum = 909c8543811cb8d84d0d7d81cba6ca96
url = https://github.com/siamect/proview/archive/63dcc19e71741468e2484ea526db1a54601f4319.zip
md5sum = 1e2d6903bd0e1fe5460948e867740323
# XXX - this URL is same as above URL but folder we reduced the folder name to simply pwr. This solve the problem of path too long.
#url = https://softinst56570.host.vifib.net/public/cc5abd785.tar.gz
#version = 5.6.1-1
#version = cc5abd7
version = 63dcc19
location = ${buildout:parts-directory}/${:_buildout_section_name_}
aroot=${:location}/local/adm
keep-compile-dir = true
make-binary = ${:compile-dir}/build.sh
incdir = -I${libdb:location}/include -I${qt4-qmake:location}/include -I${qt4-qmake:location}/include/QtGui -I${qt4-qmake:location}/include/Qt -I${alsa:location}/include -I${phonon-qt4:location}/include -I${fontconfig:location}/include
libs = -L${libdb:location}/lib -ldb_cxx-5 -L${gettext:location}/lib -L${alsa:location}/lib -L${zlib:location}/lib -L ${qt4-qmake:location}/lib -L${phonon-qt4:location}/lib  -L${fontconfig:location}/lib
compile-dir = ${:location}__compile__/proview-${:version}*
#compile-dir = ${:location}__compile__/pwr
configure-command =
  set -e
  sed -i "s#aroot=/usr/local/adm#aroot=${:aroot}#" ${:compile-dir}/build.sh
  sed -i "s#(cross_compile)#(cross_compile) ${:rpaths} #" ${:compile-dir}/xtt/exe/wb_ge/qt/link_rule.mk
  sed -i "s#cflags\s*:= -c#cflags    := ${:incdir} -c#" ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#cflags\s*:= -c#cflags    := ${:incdir} -c#" ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#linkflags	:= \$(cross_compile) #linkflags	:= \$(cross_compile) ${:rpaths} #" ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#cxxflags	:= \$(cflags)#cxxflags	:= -std=gnu++11 \$(cflags)#" ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#\$(\$(pred))#\$(shell expr \$(word) - 1)#" ${:compile-dir}/src/tools/pwre/src/dir_symbols.mk
  sed -i "s#typedef char cnv_tName\[200\]#typedef char cnv_tName\[300\]#" ${:compile-dir}/src/exe/co_convert/src/co_convert.cpp
  sed -i "s#efine pwr_cSizCmd 399#efine pwr_cSizCmd 799#" ${:compile-dir}/src/exp/inc/src/pwr.h
  sed -i "s#efine pwr_cSizFileName 255#efine pwr_cSizFileName 455#" ${:compile-dir}/src/exp/inc/src/pwr.h
  sed -i "s#efine DCLI_CMD_SIZE 400#efine DCLI_CMD_SIZE 800#" ${:compile-dir}/src/lib/co/src/co_dcli.h
  sed -i "s#efine DCLI_QUAL_SIZE 400#efine DCLI_QUAL_SIZE 800#" ${:compile-dir}/src/lib/co/src/co_dcli.h
  sed -i "s#efine DCLI_SYM_KEY_SIZE 200#efine DCLI_SYM_KEY_SIZE 400#" ${:compile-dir}/src/lib/co/src/co_dcli.h
  sed -i "s#efine DCLI_SYM_VALUE_SIZE 200#efine DCLI_SYM_VALUE_SIZE 400#" ${:compile-dir}/src/lib/co/src/co_dcli.h
  sed -i "s#char filename\[120\]#char filename\[400\]#" ${:compile-dir}/src/lib/co/src/co_dcli.h
  sed -i "s#char dcli_qual_str\[10\]\[2\]\[400\]#char dcli_qual_str\[10\]\[2\]\[800\]#" ${:compile-dir}/src/lib/co/src/co_dcli.c
  sed -i "s#200#400#g" ${:compile-dir}/src/lib/co/src/co_dcli_dir.c
  sed -i "s#200#400#g" ${:compile-dir}/src/lib/co/src/co_dcli_file.cpp
  sed -i "s#char cmd_array\[10\]\[400\]#char cmd_array\[10\]\[800\]#" ${:compile-dir}/wb/exe/wb_cmd/src/wb_cmd_main.cpp
  sed -i "s#char dir\[120\]#char dir\[400\]#" ${:compile-dir}/src/exe/co_convert/src/*
  sed -i "s#char current_file\[200\]#char current_file\[400\]#" ${:compile-dir}/src/exe/co_convert/src/*
  sed -i "s#char source_dir\[200\]#char source_dir\[400\]#" ${:compile-dir}/src/exe/co_convert/src/*
  sed -i "s#char directory\[80\]#char directory\[400\]#" ${:compile-dir}/src/exe/co_convert/src/*
  sed -i "s#char filename\[120\]#char filename\[400\]#" ${:compile-dir}/src/exe/co_convert/src/*
  sed -i 's#@_") \&\&#@_ --trace -w") \&\&#' ${:compile-dir}/src/tools/pwre/src/pwre.pl
  #sed -i "s#pwre build_all_modules \$gui#pwre build -v all \$gui#" ${:compile-dir}/build.sh
  sed -i "s#gui=\"gtk\"#gui=\"qt\"#" ${:compile-dir}/build.sh
#  sed -i 's#Compiling $<"#Compiling $< XXX=$(cxxflags)"#g' ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#(lib_dir)#(lib_dir) ${:libs}#" ${:compile-dir}/src/tools/bld/src/variables.mk
  sed -i "s#/usr/include/qt4#${qt4-qmake:location}/include#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libQtGui.so#${qt4-qmake:location}/lib/libQtGui.so#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/local/include/gtk-2.0#${gtk-2:location}/include/gtk-2.0#g" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libgtk-x11-2.0.so#${gtk-2:location}/lib/libgtk-x11-2.0.so#g" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libfl#${flex:location}/lib/libfl#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libasound#${alsa:location}/lib/libasound#g" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libdb#${libdb:location}/lib/libdb#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libz#${zlib:location}/lib/libz#g" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/include/alsa#${alsa:location}/include#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i "s#/usr/lib/libX11#${libX11:location}/lib/libX11#" ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i 's#conf_incdirgst=""#conf_incdirgst=""\nconf_incdir="-I${libdb:location}/include"#' ${:compile-dir}/src/tools/pwre/src/pwre_configure.sh
  sed -i 's,#include <QLabel>,#include "cow_qt_helpers.h"\n\n#include <QLabel>,' ${:compile-dir}/sev/exe/sev_xtt/qt/xtt_tbl_qt.h
  sed -i "s,co_convert -t -d,#co_convert -t -d," ${:compile-dir}/src/tools/pkg/*/pwrrt/build.sh
  sed -i "s,co_convert -t -d,#co_convert -t -d," ${:compile-dir}/build.sh
depends =
  ${xserver:location}
  ${xorg-video-dummy:location}
  ${xorg-input-mouse:location}
  ${xorg-video-fbdev:location}
  ${xorg-input-kbd:location}
  ${xorg-video-vesa:location}
# Start dummy Xserver required to build without display. See: https://github.com/siamect/proview#building-without-a-display

  #PID=`pgrep -u "$(whoami)" -f ${xserver:location}/bin/Xorg`
# ${xserver:location}/bin/Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config ${:compile-dir}/pwr/src/tools/dummy_display/xorg.conf :99 &
#pre-build =
#  PID=`pgrep -u "$(whoami)" -f -x  '${xserver:location}/bin/Xvfb.*'`
#  echo 'I GOT THROUGH PID'
#  echo " PID is $PID "
#  echo "other possibly different PID is `pgrep -f vfb` "
#  echo "my own process is $$"
#  echo "my command name is `ps -ly $$`"  
#  if [ ! -z "$PID" ]; then kill -TERM $PID; fi
#  echo 'I GOT THROUGH IF'  
#  ${xserver:location}/bin/Xvfb -noreset +extension GLX +extension RANDR +extension RENDER :99 &  

pre-build =
  PID=`pgrep -u "$(whoami)" -f -x  '${xserver:location}/bin/Xorg.*'`
  echo 'I GOT THROUGH PID'
  echo " PID is $PID "
  echo "other possibly different PID is `pgrep -f vfb` "
  echo "my own process is $$"
  echo "my command name is `ps -ly $$`"  
  if [ ! -z "$PID" ]; then kill -TERM $PID; fi
  echo 'I GOT THROUGH IF'  
  ${xserver:location}/bin/Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config ${:compile-dir}/src/tools/dummy_display/xorg.conf :99 &

post-install =
  PID=`pgrep -u "$(whoami)" -f -x  '${xserver:location}/bin/Xorg.*'`
  if [ ! -z "$PID" ]; then kill -TERM $PID; fi

make-targets =
make-options =
  -j1
environment =
  PATH=${qt4-qmake:location}/bin:${make-4:location}/bin:${gcc:location}/bin:${doxygen:location}/bin:${pkgconfig:location}/bin:${java-openjdk:location}/bin:${gtk-2:location}/bin:${bison:location}/bin:%(PATH)s
  SHELL=/bin/bash
  PKG_CONFIG_PATH=${qt4-qmake:location}/lib/pkgconfig:${gtk-2:location}/lib/pkgconfig:${pango:location}/lib/pkgconfig:${glib:location}/lib/pkgconfig:${cairo:location}/lib/pkgconfig:${pcre:location}/lib/pkgconfig:${pixman:location}/lib/pkgconfig:${fontconfig:location}/lib/pkgconfig:${fontconfig:pkg_config_depends}:${libXext:location}/lib/pkgconfig:${libXext:pkg_config_depends}:${fribidi:location}/lib/pkgconfig:${harfbuzz:location}/lib/pkgconfig:${harfbuzz:pkg_config_depends}:${atk:location}/lib/pkgconfig:${gdk-pixbuf:location}/lib/pkgconfig:${phonon-qt4:location}/lib/pkgconfig:${alsa:location}/lib/pkgconfig:${zlib:location}/lib/pkgconfig:${libpng:location}/lib/pkgconfig
  LD_LIBRARY_PATH=${:ld-library-path}
  CXXFLAGS= -std=c++11 -I${alsa:location}/include -I${fontconfig:location}/include -I${libdb:location}/include -I${qt4-qmake:location}/include -I${qt4-qmake:location}/include/QtGui
  CFLAGS=-I${qt4-qmake:location}/include -I${qt4-qmake:location}/include/QtGui -I${libdb:location}/include
  LDFLAGS=-L${gcc:location}/lib -Wl,-rpath=${gcc:location}/lib -L${gcc:location}/lib64 -Wl,-rpath=${gcc:location}/lib64 -L${gettext:location}/lib -L${fontconfig:location}/lib -Wl,-rpath=${fontconfig:location}/lib -L${bison:location}/lib -L${libdb:location}/lib -L${gtk-2:location}/lib -L${zlib:location}/lib -Wl,-v
  DISPLAY=:99

ld-library-path = ${alsa:location}/lib:${qt4-qmake:location}/lib:${libdb:location}/lib:${openssl:location}/lib:${gtk-2:location}/lib:${pango:location}/lib:${cairo:location}/lib:${atk:location}/lib:${harfbuzz:location}/lib:${libXext:location}/lib:${gdk-pixbuf:location}/lib:${gettext:location}/lib:${phonon-qt4:location}/lib:${pixman:location}/lib:${zlib:location}/lib:${libpng:location}/lib:${gcc:location}/lib:${gcc:location}/lib64:${fontconfig:location}/lib:${libX11:location}/lib:${freetype:location}/lib


rpaths = -Wl,-rpath=${alsa:location}/lib -Wl,-rpath=${qt4-qmake:location}/lib -Wl,-rpath=${libdb:location}/lib -Wl,-rpath=${openssl:location}/lib -Wl,-rpath=${gtk-2:location}/lib -Wl,-rpath=${pango:location}/lib -Wl,-rpath=${cairo:location}/lib -Wl,-rpath=${atk:location}/lib -Wl,-rpath=${harfbuzz:location}/lib -Wl,-rpath=${libXext:location}/lib -Wl,-rpath=${gdk-pixbuf:location}/lib -Wl,-rpath=${gettext:location}/lib -Wl,-rpath=${phonon-qt4:location}/lib -Wl,-rpath=${pixman:location}/lib -Wl,-rpath=${zlib:location}/lib -Wl,-rpath=${libpng:location}/lib -Wl,-rpath=${gcc:location}/lib -Wl,-rpath=${gcc:location}/lib64  -Wl,-rpath=${glib:location}/lib -Wl,-rpath=${fontconfig:location}/lib  -Wl,-rpath=${libX11:location}/lib -Wl,-rpath=${freetype:location}/lib



[libvncserver]
recipe = slapos.recipe.cmmi
url = https://github.com/LibVNC/libvncserver/archive/LibVNCServer-0.9.12.tar.gz
location = ${buildout:parts-directory}/${:_buildout_section_name_}
configure-command =
  mkdir build && cd build && \
  cmake -DCMAKE_INSTALL_PREFIX=${:location} \
#    -DZLIB_LIBRARY=${zlib:location}/lib \
#    -DZLIB_INCLUDE_DIR=${zlib:location}/include \
#    -DJPEG_LIBRARY=${libjpeg:location}/lib \
#    -DJPEG_INCLUDE_DIR=${libjpeg:location}/include \
#    -DPNG_LIBRARY=${libpng:location}/lib \
#    -DPNG_INCLUDE_DIR=${libpng:location}/include \
#    -DPNG_PNG_INCLUDE_DIR=${libpng:location}/include \
#    -DOPENSSL_ROOT_DIR=${openssl:location} \
#    -DGNUTLS_LIBRARY=${gnutls:location}/lib \
#    -DGNUTLS_INCLUDE_DIR=${gnutls:location}/include \
    -DWITH_SYSTEMD=OFF \
    -DWITH_WEBSOCKETS=ON \
    -DWITH_LZO=OFF \
    ..
  cmake --build .

make-binary = cd build && make
make-targets = install
environment =
  PATH=${cmake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${zlib:location}/lib/pkgconfig:${libpng:location}/lib/pkgconfig:${libjpeg:location}/lib/pkgconfig:${openssl:location}/lib/pkgconfig
  CPPFLAGS=-I${libjpeg:location}/include -I${libpng:location}/include
  LDFLAGS=-L${libjpeg:location}/lib -Wl,-rpath=${libjpeg:location}/lib -L${libpng:location}/lib -Wl,-rpath=${libpng:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib


[x11vnc]
recipe = slapos.recipe.cmmi
url = https://github.com/LibVNC/x11vnc/archive/0.9.16.tar.gz
configure-command =
  autoreconf -fiv -I ${libtool:location}/share/aclocal -I ${pkgconfig:location}/share/aclocal -I ${gettext:location}/share/aclocal
  ./configure
configure-options =
  --disable-static

environment =
  PATH=${autoconf:location}/bin:${automake:location}/bin:${libtool:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${openssl:location}/lib/pkgconfig:${libX11:location}/lib/pkgconfig:${xproto:location}/lib/pkgconfig:${libX11:pkg_config_depends}:${libXext:location}/lib/pkgconfig:${xextproto:location}/lib/pkgconfig:${libXtst:location}/lib/pkgconfig:${libvncserver:location}/lib/pkgconfig:${zlib:location}/lib/pkgconfig
  CPPFLAGS=-I${openssl:location}/include -I${libX11:location}/include -I${xproto:location}/include -I${xorgproto:location}/include -I${libXi:location}/include -I${libXtst:location}/include -I${libXext:location}/include -I${xextproto:location}/include -I${libvncserver:location}/include -I${zlib:location}/include
  LDFLAGS=-L${openssl:location}/lib -Wl,-rpath=${openssl:location}/lib -L${libX11:location}/lib -Wl,-rpath=${libX11:location}/lib -L${xproto:location}/lib -L${xorgproto:location}/lib -L${libXi:location}/lib -L${libXtst:location}/lib -Wl,-rpath=${libXtst:location}/lib -L${libXext:location}/lib -L${xextproto:location}/lib -Wl,-rpath=${libXext:location}/lib -L${libvncserver:location}/lib -Wl,-rpath=${libvncserver:location}/lib -L${zlib:location}/lib -Wl,-rpath=${zlib:location}/lib

