#  GNUMakefile
 
# Just a snippet to stop executing under other make(1) commands
# that won't understand these lines
ifneq (,)
This makefile requires GNU Make.
endif
	
CXX_STD = CXX11
PKG_CPPFLAGS =-DROUT -I../inst/include -DBOOST_NO_AUTO_PTR 

#somehow the implicit $CC isn't available/accurate, so we have to re-fetch it
compilerinfo = ${shell R CMD config CXX}
compiler = $(findstring clang++, $(compilerinfo))
#$(info "$(compiler)")
ifneq (,$(compiler))
	fslib = c++fs
else
	fslib = stdc++fs
endif
	


PKG_LIBS = $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) `${R_HOME}/bin/Rscript -e "cytolib:::cytolib_LdFlags()"`  

USERDIR = ${R_PACKAGE_DIR}/lib${R_ARCH}
PKGLIB = ${USERDIR}/libflowWorkspace.a

 
all:  $(SHLIB)
	if [ `uname -s` = 'Darwin' ]; then install_name_tool -change /usr/local/clang4/lib/libc++.1.dylib /usr/lib/libc++.1.dylib $(SHLIB); fi

$(SHLIB): $(PKGLIB)


#expose static lib for other package to link to 
$(PKGLIB): $(OBJECTS)
	mkdir -p "${USERDIR}"
	$(AR) rs "${PKGLIB}" $(OBJECTS)


.PHONY: 	all clean 

clean:
		rm -f $(OBJECTS) $(SHLIB)
 
