2018-12-13 05:36:15 +00:00
|
|
|
GO ?= go
|
|
|
|
GOOS ?= $(word 1, $(subst /, " ", $(word 4, $(shell go version))))
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-07-16 09:55:06 +00:00
|
|
|
MAKEFILE := $(realpath $(lastword $(MAKEFILE_LIST)))
|
|
|
|
ROOT_DIR := $(shell dirname $(MAKEFILE))
|
2018-12-13 05:36:15 +00:00
|
|
|
SOURCES := $(wildcard *.go src/*.go src/*/*.go) $(MAKEFILE)
|
2018-07-16 09:55:06 +00:00
|
|
|
|
|
|
|
REVISION := $(shell git log -n 1 --pretty=format:%h -- $(SOURCES))
|
2020-04-21 01:07:39 +00:00
|
|
|
BUILD_FLAGS := -a -ldflags "-X main.revision=$(REVISION) -w '-extldflags=$(LDFLAGS)'" -tags "$(TAGS)"
|
2018-07-16 09:55:06 +00:00
|
|
|
|
|
|
|
BINARY64 := fzf-$(GOOS)_amd64
|
|
|
|
BINARYARM5 := fzf-$(GOOS)_arm5
|
|
|
|
BINARYARM6 := fzf-$(GOOS)_arm6
|
|
|
|
BINARYARM7 := fzf-$(GOOS)_arm7
|
|
|
|
BINARYARM8 := fzf-$(GOOS)_arm8
|
|
|
|
BINARYPPC64LE := fzf-$(GOOS)_ppc64le
|
|
|
|
VERSION := $(shell awk -F= '/version =/ {print $$2}' src/constants.go | tr -d "\" ")
|
|
|
|
RELEASE64 := fzf-$(VERSION)-$(GOOS)_amd64
|
|
|
|
RELEASEARM5 := fzf-$(VERSION)-$(GOOS)_arm5
|
|
|
|
RELEASEARM6 := fzf-$(VERSION)-$(GOOS)_arm6
|
|
|
|
RELEASEARM7 := fzf-$(VERSION)-$(GOOS)_arm7
|
|
|
|
RELEASEARM8 := fzf-$(VERSION)-$(GOOS)_arm8
|
|
|
|
RELEASEPPC64LE := fzf-$(VERSION)-$(GOOS)_ppc64le
|
2017-06-02 07:32:15 +00:00
|
|
|
|
|
|
|
# https://en.wikipedia.org/wiki/Uname
|
|
|
|
UNAME_M := $(shell uname -m)
|
|
|
|
ifeq ($(UNAME_M),x86_64)
|
|
|
|
BINARY := $(BINARY64)
|
|
|
|
else ifeq ($(UNAME_M),amd64)
|
|
|
|
BINARY := $(BINARY64)
|
|
|
|
else ifeq ($(UNAME_M),armv5l)
|
|
|
|
BINARY := $(BINARYARM5)
|
|
|
|
else ifeq ($(UNAME_M),armv6l)
|
|
|
|
BINARY := $(BINARYARM6)
|
|
|
|
else ifeq ($(UNAME_M),armv7l)
|
|
|
|
BINARY := $(BINARYARM7)
|
2018-06-27 09:56:02 +00:00
|
|
|
else ifeq ($(UNAME_M),armv8l)
|
|
|
|
BINARY := $(BINARYARM8)
|
2019-10-11 13:11:06 +00:00
|
|
|
else ifeq ($(UNAME_M),aarch64)
|
|
|
|
BINARY := $(BINARYARM8)
|
2018-07-16 09:55:06 +00:00
|
|
|
else ifeq ($(UNAME_M),ppc64le)
|
|
|
|
BINARY := $(BINARYPPC64LE)
|
2017-06-02 07:32:15 +00:00
|
|
|
else
|
|
|
|
$(error "Build on $(UNAME_M) is not supported, yet.")
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: target/$(BINARY)
|
|
|
|
|
|
|
|
target:
|
|
|
|
mkdir -p $@
|
|
|
|
|
|
|
|
ifeq ($(GOOS),windows)
|
2020-10-07 10:07:09 +00:00
|
|
|
release: target/$(BINARY64)
|
2017-06-02 08:57:28 +00:00
|
|
|
cd target && cp -f $(BINARY64) fzf.exe && zip $(RELEASE64).zip fzf.exe
|
2017-06-02 07:32:15 +00:00
|
|
|
cd target && rm -f fzf.exe
|
|
|
|
else ifeq ($(GOOS),linux)
|
2020-10-07 10:07:09 +00:00
|
|
|
release: target/$(BINARY64) target/$(BINARYARM5) target/$(BINARYARM6) target/$(BINARYARM7) target/$(BINARYARM8) target/$(BINARYPPC64LE)
|
2017-06-02 07:32:15 +00:00
|
|
|
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
|
|
|
cd target && cp -f $(BINARYARM5) fzf && tar -czf $(RELEASEARM5).tgz fzf
|
|
|
|
cd target && cp -f $(BINARYARM6) fzf && tar -czf $(RELEASEARM6).tgz fzf
|
|
|
|
cd target && cp -f $(BINARYARM7) fzf && tar -czf $(RELEASEARM7).tgz fzf
|
|
|
|
cd target && cp -f $(BINARYARM8) fzf && tar -czf $(RELEASEARM8).tgz fzf
|
2018-07-16 09:55:06 +00:00
|
|
|
cd target && cp -f $(BINARYPPC64LE) fzf && tar -czf $(RELEASEPPC64LE).tgz fzf
|
2017-06-02 07:32:15 +00:00
|
|
|
cd target && rm -f fzf
|
|
|
|
else
|
2020-10-07 10:07:09 +00:00
|
|
|
release: target/$(BINARY64)
|
2017-06-02 07:32:15 +00:00
|
|
|
cd target && cp -f $(BINARY64) fzf && tar -czf $(RELEASE64).tgz fzf
|
|
|
|
cd target && rm -f fzf
|
|
|
|
endif
|
|
|
|
|
|
|
|
release-all: clean test
|
|
|
|
GOOS=darwin make release
|
|
|
|
GOOS=linux make release
|
|
|
|
GOOS=freebsd make release
|
|
|
|
GOOS=openbsd make release
|
|
|
|
GOOS=windows make release
|
|
|
|
|
2018-12-13 05:36:15 +00:00
|
|
|
test: $(SOURCES)
|
|
|
|
SHELL=/bin/sh GOOS= $(GO) test -v -tags "$(TAGS)" \
|
2017-06-02 07:32:15 +00:00
|
|
|
github.com/junegunn/fzf/src \
|
|
|
|
github.com/junegunn/fzf/src/algo \
|
|
|
|
github.com/junegunn/fzf/src/tui \
|
|
|
|
github.com/junegunn/fzf/src/util
|
|
|
|
|
|
|
|
install: bin/fzf
|
|
|
|
|
|
|
|
clean:
|
2018-12-13 05:36:15 +00:00
|
|
|
$(RM) -r target
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARY64): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=amd64 $(GO) build $(BUILD_FLAGS) -o $@
|
2017-06-02 07:32:15 +00:00
|
|
|
|
|
|
|
# https://github.com/golang/go/wiki/GoArm
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARYARM5): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=arm GOARM=5 $(GO) build $(BUILD_FLAGS) -o $@
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARYARM6): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=arm GOARM=6 $(GO) build $(BUILD_FLAGS) -o $@
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARYARM7): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=arm GOARM=7 $(GO) build $(BUILD_FLAGS) -o $@
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARYARM8): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=arm64 $(GO) build $(BUILD_FLAGS) -o $@
|
2017-06-02 07:32:15 +00:00
|
|
|
|
2018-12-13 06:17:30 +00:00
|
|
|
target/$(BINARYPPC64LE): $(SOURCES)
|
2018-12-13 05:36:15 +00:00
|
|
|
GOARCH=ppc64le $(GO) build $(BUILD_FLAGS) -o $@
|
2018-07-16 09:55:06 +00:00
|
|
|
|
2017-06-02 07:32:15 +00:00
|
|
|
bin/fzf: target/$(BINARY) | bin
|
|
|
|
cp -f target/$(BINARY) bin/fzf
|
|
|
|
|
2018-06-01 09:23:25 +00:00
|
|
|
docker:
|
|
|
|
docker build -t fzf-arch .
|
|
|
|
docker run -it fzf-arch tmux
|
|
|
|
|
|
|
|
docker-test:
|
|
|
|
docker build -t fzf-arch .
|
|
|
|
docker run -it fzf-arch
|
|
|
|
|
2018-12-13 05:36:15 +00:00
|
|
|
update:
|
|
|
|
$(GO) get -u
|
|
|
|
$(GO) mod tidy
|
|
|
|
|
|
|
|
.PHONY: all release release-all test install clean docker docker-test update
|