# Where is Cargo ? game
ifneq "$(strip $(CARGO_HOME))" ""
	CG=$(CARGO_HOME)
else
	CG=cargo
endif

.PHONY: all

LIBDIR = rustlib/target/release
STATLIB = $(LIBDIR)/librustlib.rlib
PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L. -L$(LIBDIR) -lrustlib

$(SHLIB): $(STATLIB)

# to make things
all: $(SHLIB)

# run cargo
# rustlib/target/release/librustlib.rlib: rustlib/src/*.rs
#	cd rustlib && $(CG) build --release

# -lws2_32 -luserenv -ladvapi32 is needed for linking on windows
# PKG_LIBS= $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS) -L. -Lrustlib/target/release/ -lrustlib

$(STATLIB):
	"${R_HOME}/bin${R_ARCH_BIN}/Rscript" ../tools/staticlib.R "$(TARGET)"

clean:
	rm -Rf $(SHLIB) $(STATLIB) $(OBJECTS)
