## With Rcpp 0.11.0 and later, we no longer need to set PKG_LIBS as there is
## no user-facing library. The include path to headers is already set by R.
#PKG_LIBS =
#PKG_CPPFLAGS = -I /usr/local/include

## With R 3.1.0 or later, you can uncomment the following line to tell R to 
## enable compilation with C++11 (or even C++14) where available
CXX_STD = CXX14

ifeq ($(shell uname), Linux)
PKG_CPPFLAGS += -fopenmp
LDFLAGS += -fopenmp
endif

ifeq ($(shell uname), Darwin)
OMP_PREFIX := $(firstword $(wildcard /opt/homebrew/opt/libomp /usr/local/opt/libomp))

ifneq ($(OMP_PREFIX),)
ifneq ($(wildcard $(OMP_PREFIX)/include/omp.h),)
PKG_CPPFLAGS += -Xclang -fopenmp -I$(OMP_PREFIX)/include
PKG_LIBS += -L$(OMP_PREFIX)/lib -lomp
endif
endif
endif
