# The package uses C++17 features, among them implicitly inline `static
# constexpr` members. Without this the compiler default applies, which is C++14
# on the current Apple toolchain, and the fit only links because -O2 folds the
# constants away; a -O0 build, such as pkgbuild's, fails to link.
CXX_STD = CXX17

PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

# Not set: `PKG_CPPFLAGS = -DARMA_DONT_CHECK_CONFORMANCE`, which removes
# Armadillo's bounds check from every element access and, with it, the size
# checks on whole-matrix operations. Measured in the 2026-09-21 review at 1.006
# to 1.032 times faster across eleven families -- about 2% -- which is not worth
# turning a dimension mistake anywhere in the compiled code from an R error into
# undefined behavior. (`ARMA_NO_DEBUG`, the switch usually cited, does nothing
# in Armadillo 12+: it only undefines `ARMA_DEBUG`, which is never on.) See
# _dev/REVIEW.md for the surgical alternative.

# Every object depends on every header. R's own rules track only the source
# file, so after a header changes an object whose source did not is reused --
# and links against a signature that no longer exists, or reads a struct whose
# layout has moved. `random.cpp` has done this twice: it constructs a `Hypers`
# and a `Tree` and its object file went stale against both constructors while
# its own source stayed put. `$(OBJECTS)` is set on make's command line by
# `R CMD INSTALL`, so it is defined by the time this file is read.
#
# `all` first, because make takes the first target of the first rule it reads
# as its default goal and this file is read before R's own `shlib.mk`. Without
# it the goal became the first object alphabetically, that one object was
# checked, and the old shared library was installed as it stood.
#
# The headers are listed by name rather than found with `$(wildcard *.h)`,
# which is a GNU make extension: R CMD check warns about it unless
# `SystemRequirements: GNU make` is declared, and CRAN notes that declaration in
# turn. A new header has to be added here.
all: $(SHLIB)

$(OBJECTS): family.h hypers.h mcmc.h node.h polyagamma.h random.h slice.h \
  utils.h
