diff --git a/install b/install index 3a708a1..e331d31 100755 --- a/install +++ b/install @@ -3,8 +3,6 @@ cd `dirname $BASH_SOURCE` fzf_base=`pwd` -ARCHI=$(uname -sm) - ask() { read -p "$1 ([y]/n) " -n 1 -r echo @@ -22,7 +20,7 @@ download() { return 1 fi - local url=https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tar.gz + local url=https://github.com/junegunn/fzf-bin/releases/download/snapshot/${1}.tgz if which curl > /dev/null; then curl -fL $url | tar -xz elif which wget > /dev/null; then @@ -41,19 +39,20 @@ download() { } # Try to download binary executable -binary_available=0 +archi=$(uname -sm) downloaded=0 -if [ "$ARCHI" = "Darwin x86_64" ]; then +binary_available=0 +if [ "$archi" = "Darwin x86_64" ]; then binary_available=1 - download fzf_darwin_amd64 && downloaded=1 -elif [ "$ARCHI" = "Linux x86_64" ]; then + download fzf-0.9.0-darwin_amd64 && downloaded=1 +elif [ "$archi" = "Linux x86_64" ]; then binary_available=1 - download fzf_linux_amd64 && downloaded=1 + download fzf-0.9.0-linux_amd64 && downloaded=1 fi if [ $downloaded -ne 1 ]; then if [ $binary_available -eq 0 ]; then - echo -n "No prebuilt binary for $ARCHI ... " + echo -n "No prebuilt binary for $archi ... " else echo -n "Failed to download binary executable ... " fi diff --git a/src/Makefile b/src/Makefile index fecf7d2..10429a1 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,52 +1,51 @@ -BINARY := fzf/fzf - UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) - BINARY := $(BINARY)_darwin + SUFFIX := darwin else ifeq ($(UNAME_S),Linux) - BINARY := $(BINARY)_linux + SUFFIX := linux endif UNAME_M := $(shell uname -m) -ifneq ($(filter i386 i686,$(UNAME_M)),) -$(error "filtered is not supported, yet.") -endif - ifeq ($(UNAME_M),x86_64) - BINARY := $(BINARY)_amd64 + SUFFIX := $(SUFFIX)_amd64 else ifneq ($(filter i386 i686,$(UNAME_M)),) - BINARY := $(BINARY)_386 + SUFFIX := $(SUFFIX)_386 else # TODO $(error "$(UNAME_M) is not supported, yet.") endif -BINDIR = ../bin -SOURCES = $(wildcard *.go fzf/*.go) +BINARY := fzf-$(SUFFIX) +BINDIR := ../bin +SOURCES := $(wildcard *.go fzf/*.go) +RELEASE = fzf-$(shell fzf/$(BINARY) --version)-$(SUFFIX) -all: build +all: release -build: $(BINARY).tar.gz +release: build + cd fzf && \ + cp $(BINARY) $(RELEASE) && \ + tar -czf $(RELEASE).tgz $(RELEASE) && \ + rm $(RELEASE) -$(BINARY).tar.gz: $(BINARY) - cd fzf && tar -czf $(notdir $(BINARY)).tar.gz $(notdir $(BINARY)) +build: fzf/$(BINARY) -$(BINARY): $(SOURCES) +fzf/$(BINARY): $(SOURCES) go get go test -v - cd fzf && go build -o $(notdir $(BINARY)) + cd fzf && go build -o $(BINARY) -install: $(BINARY) +install: fzf/$(BINARY) mkdir -p $(BINDIR) - cp -f $(BINARY) $(BINDIR)/fzf + cp -f fzf/$(BINARY) $(BINDIR)/fzf clean: - rm -f $(BINARY) $(BINARY).tar.gz + cd fzf && rm -f $(BINARY) $(RELEASE).tgz docker: docker build -t junegunn/ubuntu-sandbox . linux64: docker run -i -t -u jg -v $(shell cd ..; pwd):/fzf junegunn/ubuntu-sandbox \ - /bin/bash -ci 'cd ~jg/go/src/github.com/junegunn/fzf/src; make build' + /bin/bash -ci 'cd ~jg/go/src/github.com/junegunn/fzf/src; make' -.PHONY: build install linux64 clean docker run +.PHONY: build release install linux64 clean docker run