Build i386 binary as well

This commit is contained in:
Junegunn Choi 2015-01-06 02:04:06 +09:00
parent ee2ee02599
commit 3e6c950e12
7 changed files with 133 additions and 69 deletions

14
install
View File

@ -55,13 +55,13 @@ download() {
archi=$(uname -sm)
binary_available=1
binary_error=""
if [ "$archi" = "Darwin x86_64" ]; then
download fzf-$version-darwin_amd64
elif [ "$archi" = "Linux x86_64" ]; then
download fzf-$version-linux_amd64
else
binary_available=0
fi
case "$archi" in
"Darwin x86_64") download fzf-$version-darwin_amd64 ;;
# "Darwin i[36]86") download fzf-$version-darwin_386 ;;
"Linux x86_64") download fzf-$version-linux_amd64 ;;
# "Linux i[36]86") download fzf-$version-linux_386 ;;
*) binary_available=0 ;;
esac
cd "$fzf_base"
if [ -n "$binary_error" ]; then

View File

@ -1,33 +0,0 @@
FROM ubuntu:14.04
MAINTAINER Junegunn Choi <junegunn.c@gmail.com>
# apt-get
RUN apt-get update && apt-get -y upgrade
RUN apt-get install -y --force-yes git vim-nox curl procps sudo \
build-essential libncurses-dev
# Setup jg user with sudo privilege
RUN useradd -s /bin/bash -m jg && echo 'jg:jg' | chpasswd && \
echo 'jg ALL=(ALL) NOPASSWD: ALL' > /etc/sudoers.d/jg
# Setup dotfiles
USER jg
RUN cd ~ && git clone https://github.com/junegunn/dotfiles.git && \
dotfiles/install > /dev/null
# Install Go 1.4
RUN cd ~ && curl https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | tar -xz && \
mv go go1.4 && \
echo 'export GOROOT=~/go1.4' >> ~/dotfiles/bashrc-extra && \
echo 'export PATH=~/go1.4/bin:$PATH' >> ~/dotfiles/bashrc-extra
# Symlink fzf directory
RUN mkdir -p ~jg/go/src/github.com/junegunn && \
ln -s /fzf ~jg/go/src/github.com/junegunn/fzf
# Volume
VOLUME /fzf
# Default CMD
CMD cd ~jg/go/src/github.com/junegunn/fzf/src && /bin/bash -l

25
src/Dockerfile.arch Normal file
View File

@ -0,0 +1,25 @@
FROM base/archlinux:2014.07.03
MAINTAINER Junegunn Choi <junegunn.c@gmail.com>
# apt-get
RUN pacman-db-upgrade && pacman -Syu --noconfirm base-devel git
# Install Go 1.4
RUN cd / && curl \
https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \
tar -xz && mv go go1.4
ENV GOPATH /go
ENV GOROOT /go1.4
ENV PATH /go1.4/bin:$PATH
# Symlink fzf directory
RUN mkdir -p /go/src/github.com/junegunn && \
ln -s /fzf /go/src/github.com/junegunn/fzf
# Volume
VOLUME /fzf
# Default CMD
CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash

25
src/Dockerfile.centos Normal file
View File

@ -0,0 +1,25 @@
FROM centos:centos7
MAINTAINER Junegunn Choi <junegunn.c@gmail.com>
# yum
RUN yum install -y git gcc make tar ncurses-devel
# Install Go 1.4
RUN cd / && curl \
https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \
tar -xz && mv go go1.4
ENV GOPATH /go
ENV GOROOT /go1.4
ENV PATH /go1.4/bin:$PATH
# Symlink fzf directory
RUN mkdir -p /go/src/github.com/junegunn && \
ln -s /fzf /go/src/github.com/junegunn/fzf
# Volume
VOLUME /fzf
# Default CMD
CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash

30
src/Dockerfile.ubuntu Normal file
View File

@ -0,0 +1,30 @@
FROM ubuntu:14.04
MAINTAINER Junegunn Choi <junegunn.c@gmail.com>
# apt-get
RUN apt-get update && apt-get -y upgrade && \
apt-get install -y --force-yes git curl build-essential libncurses-dev
# Install Go 1.4
RUN cd / && curl \
https://storage.googleapis.com/golang/go1.4.linux-amd64.tar.gz | \
tar -xz && mv go go1.4
ENV GOPATH /go
ENV GOROOT /go1.4
ENV PATH /go1.4/bin:$PATH
# For i386 build
RUN apt-get install -y lib32ncurses5-dev && \
cd $GOROOT/src && GOARCH=386 ./make.bash
# Symlink fzf directory
RUN mkdir -p /go/src/github.com/junegunn && \
ln -s /fzf /go/src/github.com/junegunn/fzf
# Volume
VOLUME /fzf
# Default CMD
CMD cd /go/src/github.com/junegunn/fzf/src && /bin/bash

View File

@ -1,51 +1,68 @@
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
SUFFIX := darwin
GOOS := darwin
else ifeq ($(UNAME_S),Linux)
SUFFIX := linux
GOOS := linux
endif
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
SUFFIX := $(SUFFIX)_amd64
else ifneq ($(filter i386 i686,$(UNAME_M)),)
SUFFIX := $(SUFFIX)_386
else # TODO
$(error "$(UNAME_M) is not supported, yet.")
ifneq ($(shell uname -m),x86_64)
$(error "Build on $(UNAME_M) is not supported, yet.")
endif
BINARY := fzf-$(SUFFIX)
BINDIR := ../bin
SOURCES := $(wildcard *.go fzf/*.go)
RELEASE = fzf-$(shell fzf/$(BINARY) --version)-$(SUFFIX)
SOURCES := $(wildcard *.go fzf/*.go)
BINDIR := ../bin
BINARY32 := fzf-$(GOOS)_386
BINARY64 := fzf-$(GOOS)_amd64
RELEASE32 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_386
RELEASE64 = fzf-$(shell fzf/$(BINARY64) --version)-$(GOOS)_amd64
all: release
release: build
cd fzf && \
cp $(BINARY) $(RELEASE) && \
tar -czf $(RELEASE).tgz $(RELEASE) && \
rm $(RELEASE)
cp $(BINARY32) $(RELEASE32) && tar -czf $(RELEASE32).tgz $(RELEASE32) && \
cp $(BINARY64) $(RELEASE64) && tar -czf $(RELEASE64).tgz $(RELEASE64) && \
rm $(RELEASE32) $(RELEASE64)
build: fzf/$(BINARY)
build: fzf/$(BINARY32) fzf/$(BINARY64)
fzf/$(BINARY): $(SOURCES)
test: $(SOURCES)
go get
go test -v
cd fzf && go build -o $(BINARY)
install: fzf/$(BINARY)
fzf/$(BINARY32): test
cd fzf && GOARCH=386 CGO_ENABLED=1 go build -o $(BINARY32)
fzf/$(BINARY64): test
cd fzf && go build -o $(BINARY64)
install: fzf/$(BINARY64)
mkdir -p $(BINDIR)
cp -f fzf/$(BINARY) $(BINDIR)/fzf
cp -f fzf/$(BINARY64) $(BINDIR)/fzf
clean:
cd fzf && rm -f $(BINARY) $(RELEASE).tgz
cd fzf && rm -f $(BINARY32) $(BINARY64) $(RELEASE32).tgz $(RELEASE64).tgz
DISTRO := ubuntu
docker:
docker build -t junegunn/ubuntu-sandbox .
docker build -t junegunn/$(DISTRO)-sandbox - < Dockerfile.$(DISTRO)
linux64: docker
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'
linux: docker
docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \
/bin/bash -ci 'cd /go/src/github.com/junegunn/fzf/src; make'
.PHONY: build release install linux64 clean docker
$(DISTRO): docker
docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/$(DISTRO)-sandbox \
sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'
arch: docker
docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/arch-sandbox \
sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'
centos: docker
docker run -i -t -v $(shell cd ..; pwd):/fzf junegunn/centos-sandbox \
sh -c 'cd /go/src/github.com/junegunn/fzf/src; /bin/bash'
.PHONY: build release install linux clean docker $(DISTRO)

View File

@ -22,8 +22,8 @@ make
# Install the executable to ../bin directory
make install
# Build executable for Linux x86_64 using Docker
make linux64
# Build executables for Linux using Docker
make linux
```
System requirements