RBIN="${R_HOME}/bin/R"
RSCRIPT="${R_HOME}/bin/Rscript"

CXX=$(shell "${RBIN}" CMD config CXX)
CPPFLAGS=$(shell "${RBIN}" CMD config --cppflags)
CXXFLAGS=$(shell "${RBIN}" CMD config CXXFLAGS)
CXXPICFLAGS=$(shell "${RBIN}" CMD config CXXPICFLAGS)

SWI_HOME=$(shell "${RSCRIPT}" -e "source('../R/plbase.R'); .cat.swipl64()")
ifeq ("$(SWI_HOME)","")
  $(error Please install R package rswipl or SWI-Prolog from https://swi-prolog.org)
else
  $(info Found SWI-Prolog at $(SWI_HOME))
endif

PKG_CPPFLAGS=-I"$(SWI_HOME)/include" -D_REENTRANT -D__SWI_PROLOG__\
  -D__WINDOWS__ -D_WINDOWS -DRPACKAGE
PKG_LIBS=-L"$(SWI_HOME)/bin" -lswipl
