intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.
#import xxxx_libs += libhello%lib{hello}

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

include $pub

pub_hdrs = $($pub/ pub_hdrs)

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

# Private headers and sources as well as dependencies.
#
# Multi-dot names (clock.posix.c) need the ... form so build2 does not treat
# .posix as the file extension.
#
lib{reproc}: {h c}{** -*.windows... -*.posix...} $impl_libs $intf_libs

# Platform-specific sources.
#
lib{reproc}: c{*.windows...}: include = ($c.target.class == 'windows')
lib{reproc}: c{*.posix...}:   include = ($c.target.class != 'windows')

# 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/

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

if $config.libreproc.multithreaded
  c.poptions += -DREPROC_MULTITHREADED

if ($c.target.class == 'windows')
  c.poptions += -DWIN32_LEAN_AND_MEAN

if ($c.target.system == 'win32-msvc')
  c.poptions += -D_CRT_SECURE_NO_WARNINGS

objs{*}: c.poptions += -DREPROC_BUILDING -DREPROC_SHARED

# Upstream: C_VISIBILITY_PRESET hidden for shared builds.
#
if ($c.class != 'msvc')
  objs{*}: c.coptions += -fvisibility=hidden

# System libraries.
#
if ($c.target.class == 'windows')
{
  if ($c.target.system == 'mingw32')
    c.libs += -lws2_32
  else
    c.libs += ws2_32.lib
}
else
{
  if $config.libreproc.multithreaded
    c.libs += -pthread

  # clock_gettime
  #
  if ($c.target.class == 'linux')
    c.libs += -lrt
}

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

libs{reproc}: c.export.poptions += -DREPROC_SHARED

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

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