
## With R 3.1.0 or later, you can uncomment the following line to tell R to 
## enable compilation with C++11 (where available)
##
## Also, OpenMP support in Armadillo prefers C++11 support. However, for wider
## availability of the package we do not yet enforce this here.  It is however
## recommended for client packages to set it.
##
## And with R 3.4.0, and RcppArmadillo 0.7.960.*, we turn C++11 on as OpenMP
## support within Armadillo prefers / requires it



$(info ## ==================================)
$(info ## SQUIC for Installation Mac & Linux)
$(info ## ==================================)

PLATFORM:=$(shell uname)

$(info ## Platform=${PLATFORM})

ifndef SQUIC_LIB_PATH
SQUIC_LIB_PATH:=${HOME}
$(info ## Environment variable SQUIC_LIB_PATH is not set. Default SQUIC_LIB_PATH=${SQUIC_LIB_PATH}. Use e.g., Sys.setenv(SQUIC_LIB_PATH="/Users/MacUser/Other") to change)
endif
$(info ## SQUIC_LIB_PATH=${SQUIC_LIB_PATH})

# Get filename
FILE_libSQUIC:=
ifneq (,$(findstring arwin,$(PLATFORM)))
 FILE_libSQUIC:=libSQUIC.dylib
 PKG_LIBS = -L${SQUIC_LIB_PATH} -lSQUIC
 $(info	## ${PLATFORM} (MAC) detected - expecting SQUIC shared library ${FILE_libSQUIC} at ${SQUIC_LIB_PATH})
else ifneq (,$(findstring inux,$(PLATFORM)))	
 FILE_libSQUIC:=libSQUIC.so
 PKG_LIBS = -L${SQUIC_LIB_PATH} -lSQUIC -Wl,-rpath,${SQUIC_LIB_PATH}
 $(info	## ${PLATFORM} (Linux) detected - expecting SQUIC shared library ${FILE_libSQUIC} at ${SQUIC_LIB_PATH})
else
 $(error ## Platform=${PLATFORM} not detected or supported)
endif

FILE_SQUIC_LIB_PATH:=${SQUIC_LIB_PATH}/${FILE_libSQUIC}

# check if file exists
ifneq ("$(wildcard $(FILE_SQUIC_LIB_PATH) )","")
 $(info	## ${FILE_SQUIC_LIB_PATH} found !)
else
 $(error ## ${FILE_SQUIC_LIB_PATH} not found)
endif

CXX_STD = CXX11
PKG_CXXFLAGS = # will defualt to -O2

PKG_CPPFLAGS = -DARMA_64BIT_WORD=1

all: $(SHLIB)
	@if command -v install_name_tool; then $(info	## MAC install_name update ...)  install_name_tool -change libSQUIC.dylib ${SQUIC_LIB_PATH}/libSQUIC.dylib $(SHLIB); fi


