Update Makefile and installer to use version number

This commit is contained in:
Junegunn Choi 2015-01-05 01:25:54 +09:00
parent 7557737569
commit 8e5ecf6b38
2 changed files with 30 additions and 32 deletions

17
install
View File

@ -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

View File

@ -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