Skip to content
Myr

Build partially-static binary for linux (#350)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Instead of building a separate statically-linked binary, build partially-static binary that only contains ncurses to avoid compatibility issues in libc.

authored by Junegunn Choi · committed by Junegunn Choi · parent 9398878 · Browse files · 2 files+10 added−27 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+10 added−27 removed

  • other:+10 added−27 removed

2 files+10 added−27 removed

modified:src/curses/curses.go+3 added-1 removed
1 unmodified line
23/*4#include <ncurses.h>5#include <locale.h>6#cgo LDFLAGS: -lncurses6#cgo darwin LDFLAGS: -lncurses7#cgo linux,386 LDFLAGS: -lncurses8#cgo linux,amd64 LDFLAGS: -l:libncurses.a -l:libtinfo.a -l:libgpm.a9*/10import "C"1112import (
546 unmodified lines
modified:src/Makefile+7 added-26 removed
3 unmodified lines
45UNAME_S := $(shell uname -s)6ifeq ($(UNAME_S),Darwin)7 GOOS := darwin8 LDFLAGS :=9ifdef STATIC10$(error Static linking not possible on OS X)11endif8else ifeq ($(UNAME_S),Linux)9 GOOS := linux14ifdef STATIC15 SUFFIX := -static16 LDFLAGS := --ldflags '-extldflags "-static -ltinfo -lgpm"'17else18 SUFFIX :=19 LDFLAGS :=10endif21endif1112ifneq ($(shell uname -m),x86_64)13$(error "Build on $(UNAME_M) is not supported, yet.")14endif1516SOURCES := $(wildcard *.go */*.go)17BINDIR := ../bin1830BINARY32 := fzf-$(GOOS)_386$(SUFFIX)31BINARY64 := fzf-$(GOOS)_amd64$(SUFFIX)19BINARY32 := fzf-$(GOOS)_38620BINARY64 := fzf-$(GOOS)_amd6421VERSION = $(shell fzf/$(BINARY64) --version)33RELEASE32 = fzf-$(VERSION)-$(GOOS)_386$(SUFFIX)34RELEASE64 = fzf-$(VERSION)-$(GOOS)_amd64$(SUFFIX)22RELEASE32 = fzf-$(VERSION)-$(GOOS)_38623RELEASE64 = fzf-$(VERSION)-$(GOOS)_amd642425all: release2627release: build28 -cd fzf && cp $(BINARY32) $(RELEASE32) && tar -czf $(RELEASE32).tgz $(RELEASE32)29 cd fzf && cp $(BINARY64) $(RELEASE64) && tar -czf $(RELEASE64).tgz $(RELEASE64) && \30 rm -f $(RELEASE32) $(RELEASE64)3143ifndef STATIC32build: test fzf/$(BINARY32) fzf/$(BINARY64)45else46build: test fzf/$(BINARY64)47endif3334test:35 go get36 go test -v ./...
32 unmodified lines
69ubuntu: docker-ubuntu70 docker run -i -t -v $(GOPATH):/go junegunn/$@-sandbox \71 sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'7288linux: docker-arch89 docker run -i -t -v $(GOPATH):/go junegunn/arch-sandbox \73linux: docker-ubuntu74 docker run -i -t -v $(GOPATH):/go junegunn/ubuntu-sandbox \75 /bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make'7692linux-static: docker-ubuntu93 docker run -i -t -v $(GOPATH):/go junegunn/ubuntu-sandbox \94 /bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make STATIC=1'9577.PHONY: all build release test install uninstall clean docker \97 linux linux-static arch ubuntu docker-arch docker-ubuntu78 linux arch ubuntu docker-arch docker-ubuntu