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

# Public headers.
#
pub = [dir_path] ../include/

include $pub

pub_hdrs = $($pub/ pub_hdrs)

lib{iqa}: libul{iqa}: $pub/{$pub_hdrs}

# Private headers and sources as well as dependencies.
#
libul{iqa}: {h c}{**} $impl_libs $intf_libs

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

# Build options.
#
# include/iqa/ unqualified -I are only for this library's TUs
# (upstream writes #include "iqa.h" and #include "convolve.h").
#
src_pfx_inc     = [dir_path] $src_root/include/
src_pfx_inc_unq = [dir_path] $src_root/include/iqa/
src_pfx_src     = [dir_path] $src_root/src/

c.poptions =+ "-I$src_pfx_src" \
              "-I$src_pfx_inc" "-I$src_pfx_inc_unq"

# Upstream puts IQA_INLINE on prototypes in math_utils.h and defines
# the functions in math_utils.c. That is not valid C99 inline usage
# and does not cause inlining. Empty the macro (iqa_os.h keeps the
# default only if we do not define it).
#
c.poptions += "-DIQA_INLINE="

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

# Export options.
#
# Dual inclusion: <iqa/iqa.h> (canonical) and <iqa.h> (upstream style).
#
lib{iqa}:
{
  c.export.poptions = "-I$src_pfx_inc" "-I$src_pfx_inc_unq"
  c.export.libs = $intf_libs
}

lib{iqa}: c.pkgconfig.include = include/ include/iqa/

if ($c.target.class != 'windows')
  lib{iqa}: c.libs += -lm

# 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{iqa}: bin.lib.version = "-$version.project_id"
else
  lib{iqa}: bin.lib.version = "-$version.major.$version.minor"

# Don't install private headers.
#
h{*}: install = false
