diff --git a/Makefile b/Makefile index cc0ce4786b9..d2ca31689f1 100644 --- a/Makefile +++ b/Makefile @@ -47,6 +47,16 @@ VERSION ?= $(eval VERSION := $(shell cat versions/VALD_VERSION))$(VERSION) NGT_REPO = github.com/yahoojapan/NGT +NPM_GLOBAL_PREFIX := $(eval NPM_GLOBAL_PREFIX := $(shell npm prefix --location=global))$(NPM_GLOBAL_PREFIX) + +TEST_NOT_IMPL_PLACEHOLDER = NOT IMPLEMENTED BELOW + +TEMP_DIR := $(eval TEMP_DIR := $(shell mktemp -d))$(TEMP_DIR) +BINDIR ?= /usr/local/bin +LIB_PATH ?= /usr/local/lib +$(LIB_PATH): + mkdir -p $(LIB_PATH) + GOPRIVATE = $(GOPKG),$(GOPKG)/apis,$(GOPKG)-client-go GOPROXY = "https://proxy.golang.org,direct" GOPATH := $(eval GOPATH := $(shell go env GOPATH))$(GOPATH) @@ -59,17 +69,11 @@ GO_CLEAN_DEPS := true GOTEST_TIMEOUT = 30m CGO_ENABLED = 1 -RUST_HOME ?= /usr/local/lib/rust +RUST_HOME ?= $(LIB_PATH)/rust RUSTUP_HOME ?= $(RUST_HOME)/rustup CARGO_HOME ?= $(RUST_HOME)/cargo RUST_VERSION := $(eval RUST_VERSION := $(shell cat versions/RUST_VERSION))$(RUST_VERSION) -NPM_GLOBAL_PREFIX := $(eval NPM_GLOBAL_PREFIX := $(shell npm prefix --location=global))$(NPM_GLOBAL_PREFIX) - -TEST_NOT_IMPL_PLACEHOLDER = NOT IMPLEMENTED BELOW - -TEMP_DIR := $(eval TEMP_DIR := $(shell mktemp -d))$(TEMP_DIR) - BUF_VERSION := $(eval BUF_VERSION := $(shell cat versions/BUF_VERSION))$(BUF_VERSION) NGT_VERSION := $(eval NGT_VERSION := $(shell cat versions/NGT_VERSION))$(NGT_VERSION) FAISS_VERSION := $(eval FAISS_VERSION := $(shell cat versions/FAISS_VERSION))$(FAISS_VERSION) @@ -100,8 +104,6 @@ SWAP_DEPLOYMENT_TYPE ?= deployment SWAP_IMAGE ?= "" SWAP_TAG ?= latest -BINDIR ?= /usr/local/bin - UNAME := $(eval UNAME := $(shell uname -s))$(UNAME) OS := $(eval OS := $(shell echo $(UNAME) | tr '[:upper:]' '[:lower:]'))$(OS) ARCH := $(eval ARCH := $(shell uname -m))$(ARCH) @@ -603,8 +605,8 @@ ngt/install: /usr/local/include/NGT/Capi.h .PHONY: faiss/install ## install Faiss -faiss/install: /usr/local/lib/libfaiss.so -/usr/local/lib/libfaiss.so: +faiss/install: $(LIB_PATH)/libfaiss.so +$(LIB_PATH)/libfaiss.so: curl -fsSL https://github.com/facebookresearch/faiss/archive/v$(FAISS_VERSION).tar.gz -o $(TEMP_DIR)/v$(FAISS_VERSION).tar.gz tar zxf $(TEMP_DIR)/v$(FAISS_VERSION).tar.gz -C $(TEMP_DIR)/ cd $(TEMP_DIR)/faiss-$(FAISS_VERSION) && \ diff --git a/Makefile.d/tools.mk b/Makefile.d/tools.mk index d9a57ec74e2..ac960e3087c 100644 --- a/Makefile.d/tools.mk +++ b/Makefile.d/tools.mk @@ -170,3 +170,32 @@ rust/install: $(CARGO_HOME)/bin/cargo $(CARGO_HOME)/bin/cargo: curl --proto '=https' --tlsv1.2 -fsSL https://sh.rustup.rs | CARGO_HOME=${CARGO_HOME} RUSTUP_HOME=${RUSTUP_HOME} sh -s -- --default-toolchain $(RUST_VERSION) -y source "${CARGO_HOME}/env" + +.PHONY: zlib/install + +# zlib/install: $(LIB_PATH)/lib/libz.a +# $(LIB_PATH)/lib/libz.a: $(LIB_PATH) +zlib/install: $(LIB_PATH) + curl -fsSL https://github.com/madler/zlib/releases/download/v$(ZLIB_VERSION)/zlib-$(ZLIB_VERSION).tar.gz -o $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz \ + && mkdir -p $(TEMP_DIR)/zlib \ + && tar -xzvf $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz -C $(TEMP_DIR)/zlib --strip-components 1 \ + && cd $(TEMP_DIR)/zlib \ + && chmod a+x $(TEMP_DIR)/zlib/configure \ + && $(TEMP_DIR)/zlib/configure --prefix=$(TEMP_DIR)/zlib --static \ + && make \ + && make install \ + && cd $(ROOTDIR) \ + && rm -rf $(TEMP_DIR)/zlib-$(ZLIB_VERSION).tar.gz $(TEMP_DIR)/zlib + +.PHONY: hdf5/install +hdf5/install: $(LIB_PATH) \ + zlib/install + mkdir -p $(TEMP_DIR)/hdf5 \ + && curl -fsSL https://github.com/HDFGroup/hdf5/releases/download/$(HDF5_VERSION)/hdf5.tar.gz -o $(TEMP_DIR)/hdf5.tar.gz \ + && tar -xzvf $(TEMP_DIR)/hdf5.tar.gz -C $(TEMP_DIR)/hdf5 --strip-components 2 \ + && cd $(TEMP_DIR)/hdf5 \ + && $(TEMP_DIR)/hdf5/configure --enable-build-mode=production --enable-static-exec --disable-shared --prefix=$(TEMP_DIR)/hdf5 --with-zlib=$(LIB_PATH) LDFLAGS="-Wl,-rpath,$(LIB_DIR)" \ + && make check \ + && make install \ + && cd $(ROOTDIR) \ + && rm -rf $(TEMP_DIR)/hdf5.tar.gz $(TEMP_DIR)/hdf5