intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.

lib{lodepng}: libul{lodepng}

# Same upstream TU: C++ by default (lodepng.cpp), pure C via lodepng.c symlink
# when config.liblodepng.cpp=false (upstream: rename .cpp to .c for C builds).
#
libul{lodepng}: hxx{lodepng} $impl_libs $intf_libs
libul{lodepng}: cxx{lodepng}: include = ( $config.liblodepng.cpp)
libul{lodepng}: c{lodepng}:   include = (!$config.liblodepng.cpp)

libs{lodepng}: def{lodepng}: include = ($cc.target.system == 'win32-msvc')
def{lodepng}: libul{lodepng}

# Build options (cc.* applies to both c and cxx).
#
cc.poptions =+ "-I$out_base" "-I$src_base"

obja{*}: cc.poptions += -DLIBLODEPNG_STATIC_BUILD
objs{*}: cc.poptions += -DLIBLODEPNG_SHARED_BUILD

if ($cc.target.system == 'mingw32')
  cc.loptions += -Wl,--export-all-symbols

# Export options. When built as C, also push LODEPNG_NO_COMPILE_CPP so C++
# consumers do not see lodepng:: APIs that are not in this binary.
#
lib{lodepng}:
{
  cc.export.poptions = "-I$out_base" "-I$src_base"
  cc.export.libs = $intf_libs

  export.metadata = 1 liblodepng
  liblodepng.cpp = [bool] $config.liblodepng.cpp
}

liba{lodepng}: cc.export.poptions += -DLIBLODEPNG_STATIC
libs{lodepng}: cc.export.poptions += -DLIBLODEPNG_SHARED

if (!$config.liblodepng.cpp)
  lib{lodepng}: cc.export.poptions += -DLODEPNG_NO_COMPILE_CPP

# For pre-releases use the complete version to make sure they cannot
# be used in place of another pre-release or the final version. See
# the version module for details on the version.* variable values.
#
if $version.pre_release
  lib{lodepng}: bin.lib.version = "-$version.project_id"
else
  lib{lodepng}: bin.lib.version = "-$version.major.$version.minor"

# Install into include/ (upstream include style is <lodepng.h>).
#
hxx{*}:
{
  install         = include/
  install.subdirs = true
}
