[buildout]
extends =
  ../java/buildout.cfg
  ../java-jdk/buildout.cfg
  ../cmake/buildout.cfg
  ../libjpeg/buildout.cfg
  ../python-2.7/buildout.cfg
  ../python3/buildout.cfg
  ../defaults.cfg
parts =
  opencv

[java-re]
<= java-re-temurin-11

[ant]
recipe = slapos.recipe.build:download-unpacked
shared = true
url = https://dlcdn.apache.org/ant/binaries/apache-ant-1.9.16-bin.tar.bz2
md5sum = 2a1ef0230e673b6da876a8fc9744b9a1

[opencv]
recipe = slapos.recipe.cmmi
shared = true
url = https://github.com/opencv/opencv/archive/4.3.0.tar.gz
configure-command = cmake
configure-options =
  -Bbuild
  -DCMAKE_INSTALL_PREFIX=@@LOCATION@@
  -DCMAKE_BUILD_TYPE=RELEASE
  -DINSTALL_PYTHON_EXAMPLES=OFF
  -DINSTALL_C_EXAMPLES=OFF
  -DOPENCV_ENABLE_NONFREE=ON
  -DPYTHON_EXECUTABLE=${python2.7:location}/bin/python
  -DANT_EXECUTABLE=${ant:location}/bin/ant
  -DBUILD_SHARED_LIBRARY=OFF
  -DBUILD_TESTS=OFF
  -DBUILD_PERF_TESTS=OFF
  -DBUILD_EXAMPLES=OFF
  -DBUILD_JAVA=ON
  -DJAVA_AWT_INCLUDE_PATH=${java-jdk:location}/include
  -DJAVA_AWT_LIBRARY=${java-jdk:location}/lib/libawt.so
  -DJAVA_INCLUDE_PATH=${java-jdk:location}/include
  -DJAVA_INCLUDE_PATH2=${java-jdk:location}/include/linux
  -DJAVA_JVM_LIBRARY=${java-jdk:location}/include/jni.h
  -DWITH_VTK=OFF
  -DWITH_FFMPEG=OFF
  -DWITH_GTK=OFF
  -DPYTHON_LIBRARIES=${python:location}/lib
  -DPYTHON_INCLUDE_DIRS=${python:location}/include/python${python:version}
  -DZLIB_INCLUDE_DIR=${zlib:location}/include
  -DZLIB_LIBRARY=${zlib:location}/lib/libz.so
  -DJPEG_LIBRARY=${libjpeg-turbo2:location}/lib/libjpeg.so
  -DJPEG_INCLUDE_DIR=${libjpeg-turbo2:location}/include
  -DPNG_LIBRARY=${libpng:location}/lib/libpng.so
  -DPNG_PNG_INCLUDE_DIR=${libpng:location}/include

make-options = -C build
post-install =
  cp build/lib/libopencv_java430.so @@LOCATION@@/lib
  cp build/bin/opencv-430.jar @@LOCATION@@/bin
environment =
  PATH=${python3:location}/bin/:${python2.7:location}/bin/:${cmake:location}/bin:${pkgconfig:location}/bin:%(PATH)s
  PKG_CONFIG_PATH=${zlib:location}/lib/pkgconfig:${libpng:location}/lib/pkgconfig:${libjpeg-turbo2:location}/lib/pkgconfig
  JAVA_HOME=${java-jdk:location}
  JRE_HOME=${java-re:location}
  CPPFLAGS=-I${libjpeg-turbo2:location}/include -I${libpng:location}/include
  LDFLAGS=-L${libjpeg-turbo2:location}/lib -Wl,-rpath=${libjpeg-turbo2:location}/lib -Wl,-rpath=${libpng:location}/lib -Wl,-rpath=${zlib:location}/lib -L${zlib:location}/lib -Wl,-rpath=@@LOCATION@@/lib
