import intf_libs = libstud-optional%lib{stud-optional}

lib{stud-json}: {hxx ixx txx cxx}{** -version} hxx{version} $intf_libs

# The pdjson5.c file is included into parser.cxx so exclude it from the
# compilation. Note that pdjson5.h must be installed since it is included in
# parser.hxx.
#
lib{stud-json}: c{pdjson5}: include = adhoc
lib{stud-json}: h{pdjson5}

# Include the generated version header into the distribution (so that we don't
# pick up an installed one) and don't remove it when cleaning in src (so that
# clean results in a state identical to distributed).
#
hxx{version}: in{version} $src_root/manifest
{
  dist  = true
  clean = ($src_root != $out_root)
}

hxx{export}@./: cxx.importable = false

# Build options.
#
cxx.poptions =+ "-I$out_root" "-I$src_root"

obja{*}: cxx.poptions += -DLIBSTUD_JSON_STATIC_BUILD
objs{*}: cxx.poptions += -DLIBSTUD_JSON_SHARED_BUILD

# Export options.
#
lib{stud-json}:
{
  cxx.export.poptions = "-I$out_root" "-I$src_root"
  cxx.export.libs = $intf_libs
}

liba{stud-json}: cxx.export.poptions += -DLIBSTUD_JSON_STATIC
libs{stud-json}: cxx.export.poptions += -DLIBSTUD_JSON_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{stud-json}: bin.lib.version = @"-$version.project_id"
else
  lib{stud-json}: bin.lib.version = @"-$version.major.$version.minor"

# Install into the libstud/json/ subdirectory of, say, /usr/include/
# recreating subdirectories.
#
{h hxx ixx txx}{*}:
{
  install         = include/libstud/json/
  install.subdirs = true
}
