Skip to content

Commit

Permalink
Change root makefile (really does not update anything)
Browse files Browse the repository at this point in the history
  • Loading branch information
asergeyev committed Jan 28, 2019
1 parent a3c48d4 commit a67173f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 31 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ websocketd
*.swo
go
go-v*
go-workspace
44 changes: 14 additions & 30 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,33 @@
# To manually invoke the locally installed Go, use ./go

# Go installation config.
#GO_VERSION=1.2.1.linux-amd64
GO_VER=1.4
GO_VER=1.11.5
SYSTEM_NAME:=$(shell uname -s | tr '[:upper:]' '[:lower:]')
SYSTEM_ARCH:=$(shell uname -m)
GO_ARCH:=$(if $(filter x86_64, $(SYSTEM_ARCH)),amd64,386)
GO_VERSION:=$(GO_VER).$(SYSTEM_NAME)-$(GO_ARCH)$(if $(filter darwin,$(SYSTEM_NAME)),-osx10.8)
GO_DOWNLOAD_URL=http://golang.org/dl/go$(GO_VERSION).tar.gz
GO_VERSION:=$(GO_VER).$(SYSTEM_NAME)-$(GO_ARCH)
GO_DOWNLOAD_URL:=http://golang.org/dl/go$(GO_VERSION).tar.gz
GO_WORKDIR:=go-v$(GO_VERSION)

# Build websocketd binary
websocketd: go $(wildcard *.go) $(wildcard libwebsocketd/*.go) go-workspace/src/github.com/joewalnes/websocketd
./go get ./go-workspace/src/github.com/joewalnes/websocketd
./go fmt github.com/joewalnes/websocketd/libwebsocketd github.com/joewalnes/websocketd
./go build

# Create local go workspace and symlink websocketd into the right location.
go-workspace/src/github.com/joewalnes/websocketd:
mkdir -p go-workspace/src/github.com/joewalnes
ln -s ../../../../ go-workspace/src/github.com/joewalnes/websocketd

# Setup ./go wrapper to use local GOPATH/GOROOT.
# Need to set PATH for gofmt.
go: go-v$(GO_VERSION)/.done
@echo '#!/bin/sh' > $@
@echo export PATH=$(abspath go-v$(GO_VERSION)/bin):$(PATH) >> $@
@echo mkdir -p $(abspath go-workspace) >> $@
@echo GOPATH=$(abspath go-workspace) GOROOT=$(abspath go-v$(GO_VERSION)) $(abspath go-v$(GO_VERSION)/bin/go) \$$@ >> $@
chmod +x $@
@echo 'Created ./$@ wrapper'
websocketd: $(GO_WORKDIR)/bin/go $(wildcard *.go) $(wildcard libwebsocketd/*.go)
$(GO_WORKDIR)/bin/go build

# Download and unpack Go distribution.
go-v$(GO_VERSION)/.done:
mkdir -p $(dir $@)
$(GO_WORKDIR)/bin/go:
mkdir -p $(GO_WORKDIR)
rm -f $@
@echo Downloading and unpacking Go $(GO_VERSION) to $(dir $@)
wget -q -O - $(GO_DOWNLOAD_URL) | tar xzf - --strip-components=1 -C $(dir $@)
touch $@
@echo Downloading and unpacking Go $(GO_VERSION) to $(GO_WORKDIR)
wget -q -O - $(GO_DOWNLOAD_URL) | tar xzf - --strip-components=1 -C $(GO_WORKDIR)

# Clean up binary
clean:
rm -rf websocketd go-workspace
rm -rf websocketd

.PHONY: clean

# Also clean up downloaded Go
clobber: clean
rm -rf go $(wildcard go-v*)
rm -rf $(wildcard go-v*)

.PHONY: clobber

0 comments on commit a67173f

Please sign in to comment.