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

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

include $pub

pub_hdrs = $($pub/ pub_hdrs)

lib{jsoncpp}: $pub/{$pub_hdrs}

# Private headers and sources as well as dependencies.
#
lib{jsoncpp}: json/{hxx cxx}{**} $impl_libs $intf_libs

# Included by json_value.cpp.
#
lib{jsoncpp}: json/hxx{json_valueiterator.inl}: include = adhoc

# Build options.
#
out_pfx_inc = [dir_path] $out_root/include/
src_pfx_inc = [dir_path] $src_root/include/
out_pfx_src = [dir_path] $out_root/src/
src_pfx_src = [dir_path] $src_root/src/

cxx.poptions =+ "-I$out_pfx_src" "-I$src_pfx_src" \
                "-I$out_pfx_inc" "-I$src_pfx_inc"

objs{*}: cxx.poptions += -DJSON_DLL_BUILD

# Harmless GCC/Clang warnings in upstream code.
#
if ($cxx.class == 'gcc')
{
  # On MinGW, JSON_DLL_BUILD makes the public headers use MSVC's #pragma
  # warning(...), which GCC does not recognize.
  #
  if ($cxx.target.class == 'windows')
    json/obj{json_reader json_value json_writer}: cxx.coptions += -Wno-unknown-pragmas

  # Value::swapPayload()'s inlined std::swap<ValueHolder> trips
  # -Wuninitialized at -O3 on the union-backed ValueHolder, a known
  # false-positive class for union-based tagged types.
  #
  json/obj{json_value}: cxx.coptions += -Wno-uninitialized
}

# Export options.
#
lib{jsoncpp}:
{
  cxx.export.poptions = "-I$out_pfx_inc" "-I$src_pfx_inc"
  cxx.export.libs = $intf_libs
}

libs{jsoncpp}: cxx.export.poptions += -DJSON_DLL

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

# Don't install private headers.
#
json/hxx{*}: install = false
