
SHARKOBJECTS=\
utils.o \
##OBJECTS##

CXX_STD = CXX11

PKGOBJECTS = RcppExports.o BSGDWrapper.o DeepNetworkWrapper.o init.o

OBJECTS= $(SHARKOBJECTS) $(PKGOBJECTS)

PKG_CPPFLAGS= -I . $(CLINK_CPPFLAGS) -I $(R_INCLUDE_DIR) 
PKG_CXXFLAGS= $(CXXFLAGS) -D BOOST_DISABLE_ASSERTS  -I .  $(FPICFLAGS) -DNDEBUG -std=c++11
PKG_LIBS= $(LDFLAGS) $(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	=	libRcppShark$(DYLIB_EXT)
USERLIBST =	libRcppShark.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

utils.o:
		$(CXX) $(PKG_CPPFLAGS)  $(PKG_CXXFLAGS)   -c ./utils.cpp

##RULES##		
		
.PHONY: 	all clean userLibrary 

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

