CXX_STD = CXX11

PKGOBJECTS = RcppExports.o mlpack_mst.o

OBJECTS= $(PKGOBJECTS)

PKG_CPPFLAGS=-DBOOST_MATH_PROMOTE_DOUBLE_POLICY=false -I. 
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)

all: $(SHLIB) userLibrary 

## we place it inside the inst/ directory so that it gets installed by the package
USERDIR =	../inst/lib

USERLIB	=	libRcppMLPACK$(DYLIB_EXT)
USERLIBST =	libRcppMLPACK.a

userLibrary: 	$(USERLIB) $(USERLIBST)
		-@if test ! -e $(USERDIR)$(R_ARCH); then mkdir -p $(USERDIR)$(R_ARCH); fi
		cp $(USERLIB) $(USERDIR)$(R_ARCH)
		cp $(USERLIBST) $(USERDIR)$(R_ARCH)
		rm $(USERLIB) $(USERLIBST)

$(USERLIB): 	$(OBJECTS)
		$(SHLIB_CXXLD) -o $(USERLIB) $(OBJECTS) $(SHLIB_CXXLDFLAGS) $(ALL_LIBS)
		@if test -e "/usr/bin/install_name_tool"; then /usr/bin/install_name_tool -id $(R_PACKAGE_DIR)/lib$(R_ARCH)/$(USERLIB) $(USERLIB); fi

$(USERLIBST): 	$(OBJECTS)
		$(AR) qc $(USERLIBST) $(OBJECTS)
		@if test -n "$(RANLIB)"; then $(RANLIB) $(USERLIBST); fi

.PHONY: 	all clean userLibrary 

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


