diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 14:19:50 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2015-01-11 14:19:50 +0900 |
commit | 6c3489087c2067f42158b558c1d0a2217e1b16b3 (patch) | |
tree | 9d7869cd050c2b1435430d26c07f8df77e693bef /src/Makefile | |
parent | 313578a1a07e79aba273f47a281247e76e6329d6 (diff) |
Refactor Makefile and Dockerfiles
Diffstat (limited to 'src/Makefile')
-rw-r--r-- | src/Makefile | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/src/Makefile b/src/Makefile index 12767d3a..7108f0d9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,3 +1,7 @@ +ifndef GOPATH +$(error GOPATH is undefined) +endif + UNAME_S := $(shell uname -s) ifeq ($(UNAME_S),Darwin) GOOS := darwin @@ -9,7 +13,7 @@ ifneq ($(shell uname -m),x86_64) $(error "Build on $(UNAME_M) is not supported, yet.") endif -SOURCES := $(wildcard *.go fzf/*.go) +SOURCES := $(wildcard *.go */*.go) BINDIR := ../bin BINARY32 := fzf-$(GOOS)_386 @@ -17,7 +21,7 @@ BINARY64 := fzf-$(GOOS)_amd64 RELEASE32 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_386 RELEASE64 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_amd64 -all: release +all: test release release: build cd fzf && \ @@ -27,22 +31,30 @@ release: build build: fzf/$(BINARY32) fzf/$(BINARY64) -test: $(SOURCES) +test: go get go test -v -fzf/$(BINARY32): test +install: $(BINDIR)/fzf + +uninstall: + rm -f $(BINDIR)/fzf $(BINDIR)/$(BINARY64) + +clean: + cd fzf && rm -f $(BINARY32) $(BINARY64) $(RELEASE32).tgz $(RELEASE64).tgz + +fzf/$(BINARY32): $(SOURCES) cd fzf && GOARCH=386 CGO_ENABLED=1 go build -o $(BINARY32) -fzf/$(BINARY64): test +fzf/$(BINARY64): $(SOURCES) cd fzf && go build -o $(BINARY64) -install: fzf/$(BINARY64) - mkdir -p $(BINDIR) - cp -f fzf/$(BINARY64) $(BINDIR)/fzf +$(BINDIR)/fzf: fzf/$(BINARY64) | $(BINDIR) + cp -f fzf/$(BINARY64) $(BINDIR) + cd $(BINDIR) && ln -sf $(BINARY64) fzf -clean: - cd fzf && rm -f $(BINARY32) $(BINARY64) $(RELEASE32).tgz $(RELEASE64).tgz +$(BINDIR): + mkdir -p $@ # Linux distribution to build fzf on DISTRO := arch @@ -51,11 +63,11 @@ docker: docker build -t junegunn/$(DISTRO)-sandbox - < Dockerfile.$(DISTRO) linux: docker - docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \ + docker run -i -t -v $(GOPATH):/go junegunn/$(DISTRO)-sandbox \ /bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make' $(DISTRO): docker - docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \ + docker run -i -t -v $(GOPATH):/go junegunn/$(DISTRO)-sandbox \ sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash' -.PHONY: build release install linux clean docker $(DISTRO) +.PHONY: all build release test install uninstall clean docker linux $(DISTRO) |