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

include $pub

pub_hdrs = $($pub/ pub_hdrs)

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

# Same amalgamation: C by default (wuffs.c), C++ via wuffs.cc when
# config.libwuffs.cpp=true (upstream: compile the .c file as C++).
#
libul{wuffs}: c{wuffs}:   include = (!$config.libwuffs.cpp)
libul{wuffs}: cxx{wuffs}: include = ( $config.libwuffs.cpp)

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

# Build options (cc.* applies to both c and cxx).
#
src_pfx_inc = [dir_path] $src_root/include/

cc.poptions =+ "-I$src_pfx_inc"

# Compile the amalgamation as an implementation translation unit. Do not
# export this macro: consumers include the header without it and link
# lib{wuffs}.
#
obj{wuffs}: cc.poptions += -DWUFFS_IMPLEMENTATION

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

# Export options.
#
lib{wuffs}:
{
  cc.export.poptions = "-I$src_pfx_inc"

  export.metadata = 1 libwuffs
  libwuffs.cpp = [bool] $config.libwuffs.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{wuffs}: bin.lib.version = "-$version.project_id"
else
  lib{wuffs}: bin.lib.version = "-$version.major.$version.minor"

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