fzf/src/Makefile

117 lines
3.3 KiB
Makefile
Raw Normal View History

2015-10-13 16:40:40 +00:00
ifndef GOOS
2015-01-01 19:49:30 +00:00
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
2015-01-05 17:04:06 +00:00
GOOS := darwin
2015-01-01 19:49:30 +00:00
else ifeq ($(UNAME_S),Linux)
2015-01-05 17:04:06 +00:00
GOOS := linux
2015-01-01 19:49:30 +00:00
endif
2015-10-13 16:40:40 +00:00
endif
2015-01-01 19:49:30 +00:00
SOURCES := $(wildcard *.go */*.go)
ROOTDIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
BINDIR := $(shell dirname $(ROOTDIR))/bin
GOPATH := $(shell dirname $(ROOTDIR))/gopath
SRCDIR := $(GOPATH)/src/github.com/junegunn/fzf/src
DOCKEROPTS := -i -t -v $(ROOTDIR):/fzf/src
2015-10-13 16:40:40 +00:00
BINARY32 := fzf-$(GOOS)_386
BINARY64 := fzf-$(GOOS)_amd64
BINARYARM7 := fzf-$(GOOS)_arm7
VERSION := $(shell awk -F= '/version =/ {print $$2}' constants.go | tr -d "\" ")
RELEASE32 := fzf-$(VERSION)-$(GOOS)_386
RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd64
RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm7
export GOPATH
2015-01-01 19:49:30 +00:00
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
BINARY := $(BINARY64)
else ifeq ($(UNAME_M),i686)
BINARY := $(BINARY32)
else
$(error "Build on $(UNAME_M) is not supported, yet.")
endif
2015-01-01 19:49:30 +00:00
all: fzf/$(BINARY)
release: test fzf/$(BINARY32) fzf/$(BINARY64)
2015-08-26 18:28:05 +00:00
-cd fzf && cp $(BINARY32) $(RELEASE32) && tar -czf $(RELEASE32).tgz $(RELEASE32)
cd fzf && cp $(BINARY64) $(RELEASE64) && tar -czf $(RELEASE64).tgz $(RELEASE64) && \
rm -f $(RELEASE32) $(RELEASE64)
$(SRCDIR):
mkdir -p $(shell dirname $(SRCDIR))
ln -s $(ROOTDIR) $(SRCDIR)
deps: $(SRCDIR) $(SOURCES)
cd $(SRCDIR) && go get
2015-01-01 19:49:30 +00:00
android-build: $(SRCDIR)
cd $(SRCDIR) && GOARCH=arm GOARM=7 CGO_ENABLED=1 go get
cd $(SRCDIR)/fzf && GOARCH=arm GOARM=7 CGO_ENABLED=1 go build -a -ldflags="-w -extldflags=-pie" -o $(BINARYARM7)
cd $(SRCDIR)/fzf && cp $(BINARYARM7) $(RELEASEARM7) && tar -czf $(RELEASEARM7).tgz $(RELEASEARM7) && \
2015-10-13 16:40:40 +00:00
rm -f $(RELEASEARM7)
test: deps
SHELL=/bin/sh go test -v ./...
2015-01-01 19:49:30 +00:00
install: $(BINDIR)/fzf
2015-01-11 05:19:50 +00:00
uninstall:
rm -f $(BINDIR)/fzf $(BINDIR)/$(BINARY)
2015-01-11 05:19:50 +00:00
clean:
2015-08-26 18:28:05 +00:00
cd fzf && rm -f fzf-*
2015-01-11 05:19:50 +00:00
fzf/$(BINARY32): deps
cd fzf && GOARCH=386 CGO_ENABLED=1 go build -a -ldflags -w -tags "$(TAGS)" -o $(BINARY32)
2015-01-05 17:04:06 +00:00
fzf/$(BINARY64): deps
cd fzf && go build -a -ldflags -w -tags "$(TAGS)" -o $(BINARY64)
2015-01-05 17:04:06 +00:00
$(BINDIR)/fzf: fzf/$(BINARY) | $(BINDIR)
cp -f fzf/$(BINARY) $(BINDIR)
cd $(BINDIR) && ln -sf $(BINARY) fzf
2015-01-01 19:49:30 +00:00
2015-01-11 05:19:50 +00:00
$(BINDIR):
mkdir -p $@
2015-01-05 17:04:06 +00:00
2015-08-26 18:28:05 +00:00
docker-arch:
docker build -t junegunn/arch-sandbox - < Dockerfile.arch
2015-01-01 19:49:30 +00:00
2015-08-26 18:28:05 +00:00
docker-ubuntu:
2015-08-27 13:48:42 +00:00
docker build -t junegunn/ubuntu-sandbox - < Dockerfile.ubuntu
2015-01-05 17:04:06 +00:00
2015-09-19 15:17:44 +00:00
docker-centos:
docker build -t junegunn/centos-sandbox - < Dockerfile.centos
2015-10-13 16:40:40 +00:00
docker-android:
docker build -t junegunn/android-sandbox - < Dockerfile.android
2015-08-26 18:28:05 +00:00
arch: docker-arch
docker run $(DOCKEROPTS) junegunn/$@-sandbox \
sh -c 'cd /fzf/src; /bin/bash'
2015-01-05 17:04:06 +00:00
2015-08-26 18:28:05 +00:00
ubuntu: docker-ubuntu
docker run $(DOCKEROPTS) junegunn/$@-sandbox \
sh -c 'cd /fzf/src; /bin/bash'
2015-01-05 17:04:06 +00:00
2015-09-19 15:17:44 +00:00
centos: docker-centos
docker run $(DOCKEROPTS) junegunn/$@-sandbox \
sh -c 'cd /fzf/src; /bin/bash'
2015-09-19 15:17:44 +00:00
linux: docker-centos
docker run $(DOCKEROPTS) junegunn/centos-sandbox \
/bin/bash -ci 'cd /fzf/src; make TAGS=static release'
2015-08-26 18:28:05 +00:00
2015-10-13 16:40:40 +00:00
ubuntu-android: docker-android
docker run $(DOCKEROPTS) junegunn/android-sandbox \
sh -c 'cd /fzf/src; /bin/bash'
2015-10-13 16:40:40 +00:00
android: docker-android
docker run $(DOCKEROPTS) junegunn/android-sandbox \
/bin/bash -ci 'cd /fzf/src; GOOS=android make android-build'
2015-10-13 16:40:40 +00:00
.PHONY: all deps release test install uninstall clean \
2015-10-13 16:40:40 +00:00
linux arch ubuntu centos docker-arch docker-ubuntu docker-centos \
android-build docker-android ubuntu-android android