Skip to content

Instantly share code, notes, and snippets.

@awill1988
Created July 20, 2021 18:49
Show Gist options
  • Save awill1988/5f0f844491d9657951cb6a05238f63ac to your computer and use it in GitHub Desktop.
Save awill1988/5f0f844491d9657951cb6a05238f63ac to your computer and use it in GitHub Desktop.
Makefile.polylabel
ifeq ($(OS),Windows_NT)
POLYLABEL_ARCHIVE_FORMAT := zip
POLYLABEL_OS := pc-windows-msvc
ifeq ($(PROCESSOR_ARCHITEW6432),AMD64)
POLYLABEL_ARCH := x86_64
else
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
POLYLABEL_ARCH := x86_64
endif
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
POLYLABEL_ARCH := x86
endif
endif
else
POLYLABEL_ARCHIVE_FORMAT := tar.gz
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
POLYLABEL_OS := unknown-linux-gnu
endif
ifeq ($(UNAME_S),Darwin)
POLYLABEL_OS := apple-darwin
endif
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
POLYLABEL_ARCH := x86_64
endif
ifneq ($(filter %86,$(UNAME_M)),)
POLYLABEL_ARCH := x86
endif
ifneq ($(filter arm%,$(UNAME_M)),)
POLYLABEL_ARCH := arm
endif
endif
ifeq ($(POLYLABEL_ARCH),x86_64)
SUPPORTED_ARCH := 1
else
SUPPORTED_ARCH := 0
endif
POLYLABEL_DOWNLOAD_DIR := /tmp
POLYLABEL_DIR := $(POLYLABEL_DOWNLOAD_DIR)/polylabel
.PHONY := polylabel-lib-fetch
polylabel-lib-fetch: ## fetches the polylabel compiled library
@if $(SUPPORTED_ARCH) != "1" ]; then \
echo 'Unsupported architecture'; exit 1; \
elif [ ! -d $(POLYLABEL_DIR) ] ; then \
curl --show-error --fail -o $(POLYLABEL_DOWNLOAD_DIR)/polylabel.$(POLYLABEL_ARCHIVE_FORMAT) -L https://github.com/urschrei/polylabel-rs/releases/download/v2.0.0/polylabel-rs-v2.0.0-$(POLYLABEL_ARCH)-$(POLYLABEL_OS).$(POLYLABEL_ARCHIVE_FORMAT) && \
mkdir $(POLYLABEL_DIR); \
tar -C $(POLYLABEL_DIR) -xvzf $(POLYLABEL_DOWNLOAD_DIR)/polylabel.$(POLYLABEL_ARCHIVE_FORMAT); \
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment