2019-05-22 21:16:55 +00:00
|
|
|
GOOS ?= $(shell go env GOOS)
|
|
|
|
GOARCH ?= $(shell go env GOARCH)
|
|
|
|
GOOS_GOARCH := $(GOOS)_$(GOARCH)
|
|
|
|
GOOS_GOARCH_NATIVE := $(shell go env GOHOSTOS)_$(shell go env GOHOSTARCH)
|
|
|
|
LIBZSTD_NAME := libzstd_$(GOOS_GOARCH).a
|
2019-08-15 09:57:09 +00:00
|
|
|
ZSTD_VERSION ?= master
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
.PHONY: libzstd.a
|
|
|
|
|
|
|
|
libzstd.a: $(LIBZSTD_NAME)
|
|
|
|
|
|
|
|
$(LIBZSTD_NAME):
|
|
|
|
ifeq ($(GOOS_GOARCH),$(GOOS_GOARCH_NATIVE))
|
2019-08-15 09:57:09 +00:00
|
|
|
cd zstd/lib && ZSTD_LEGACY_SUPPORT=0 MOREFLAGS=$(MOREFLAGS) $(MAKE) clean libzstd.a
|
2019-05-22 21:16:55 +00:00
|
|
|
mv zstd/lib/libzstd.a $(LIBZSTD_NAME)
|
|
|
|
else
|
|
|
|
ifeq ($(GOOS_GOARCH),linux_arm)
|
2019-08-15 09:57:09 +00:00
|
|
|
cd zstd/lib && CC=arm-linux-gnueabi-gcc ZSTD_LEGACY_SUPPORT=0 MOREFLAGS=$(MOREFLAGS) $(MAKE) clean libzstd.a
|
2019-05-22 21:16:55 +00:00
|
|
|
mv zstd/lib/libzstd.a libzstd_linux_arm.a
|
|
|
|
endif
|
|
|
|
ifeq ($(GOOS_GOARCH),linux_arm64)
|
2019-08-15 09:57:09 +00:00
|
|
|
cd zstd/lib && CC=aarch64-linux-gnu-gcc ZSTD_LEGACY_SUPPORT=0 MOREFLAGS=$(MOREFLAGS) $(MAKE) clean libzstd.a
|
2019-05-22 21:16:55 +00:00
|
|
|
mv zstd/lib/libzstd.a libzstd_linux_arm64.a
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(LIBZSTD_NAME)
|
2019-08-27 22:04:44 +00:00
|
|
|
cd zstd && $(MAKE) clean
|
2019-05-22 21:16:55 +00:00
|
|
|
|
|
|
|
update-zstd:
|
|
|
|
rm -rf zstd-tmp
|
2019-08-15 09:57:09 +00:00
|
|
|
git clone --branch $(ZSTD_VERSION) --depth 1 https://github.com/Facebook/zstd zstd-tmp
|
2019-05-22 21:16:55 +00:00
|
|
|
rm -rf zstd-tmp/.git
|
|
|
|
rm -rf zstd
|
|
|
|
mv zstd-tmp zstd
|
|
|
|
$(MAKE) clean libzstd.a
|
|
|
|
cp zstd/lib/zstd.h .
|
|
|
|
cp zstd/lib/dictBuilder/zdict.h .
|
|
|
|
cp zstd/lib/common/zstd_errors.h .
|
|
|
|
|
|
|
|
test:
|
|
|
|
CGO_ENABLED=1 GODEBUG=cgocheck=2 go test -v
|
|
|
|
|
|
|
|
bench:
|
|
|
|
CGO_ENABLED=1 go test -bench=.
|