# Implementation of OPC UA (OPC Unified Architecture). https://open62541.org/

[buildout]
parts =
  open62541
extends =
  ../cmake/buildout.cfg
  ../git/buildout.cfg
  ../mbedtls/buildout.cfg
  ../patch/buildout.cfg
  ../python3/buildout.cfg
  ../defaults.cfg

[gcc]
# we should remove this when open62541 compiles with gcc 12
max_version = 11

[open62541]
recipe = slapos.recipe.cmmi
shared = true
tag = v1.3.15
url = https://github.com/open62541/open62541/archive/refs/tags/${:tag}.zip
md5sum = b459e2369e3550dd47e53cdbc62ec8a5
patch-options = -p1
patches =
  ${:_profile_base_location_}/ipv6_bugfix.patch#355bec02adee4ea73ff5a56ba6971ad2
pre-configure =
  # remove old FindPython3 which does not know about python > 3.8 to
  # use FindPython3 bundled with slapos' cmake
  rm tools/cmake/FindPython3.cmake tools/cmake/FindPython/Support.cmake
  ${git:location}/bin/git clone -b v1.1.6 https://github.com/LiamBindle/MQTT-C.git deps/mqtt-c
configure-command =
  ${cmake:location}/bin/cmake
configure-options =
  -DBUILD_SHARED_LIBS=ON
  -DCMAKE_BUILD_TYPE=Release
  -DCMAKE_INSTALL_PREFIX=@@LOCATION@@
  -DUA_ENABLE_PUBSUB=ON
  -DUA_ENABLE_PUBSUB_MONITORING=ON
  -DUA_ENABLE_PUBSUB_ETH_UADP=ON
  -DUA_ENABLE_SUBSCRIPTIONS=ON
  -DUA_NAMESPACE_ZERO=REDUCED
  -DUA_ENABLE_ENCRYPTION=MBEDTLS
  -DUA_ENABLE_ENCRYPTION_MBEDTLS=ON
  -DMBEDTLS_INCLUDE_DIRS=${mbedtls:location}/include
  -DMBEDTLS_LIBRARY=${mbedtls:location}/lib/libmbedtls.so
  -DMBEDX509_LIBRARY=${mbedtls:location}/lib/libmbedx509.so
  -DMBEDCRYPTO_LIBRARY=${mbedtls:location}/lib/libmbedcrypto.so
  -DUA_ENABLE_PUBSUB_INFORMATIONMODEL=ON
  -DUA_ENABLE_PUBSUB_MQTT=ON
post-install =
  cp src/pubsub/*.h deps/open62541_queue.h @@LOCATION@@/include
environment =
  PATH=${gcc:prefix}/bin:${python3:location}/bin:${patch:location}/bin:%(PATH)s
  LDFLAGS=-L${mbedtls:location}/lib -Wl,-rpath=${mbedtls:location}/lib
