forked from joewalnes/websocketd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (42 loc) · 1.81 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# Copyright 2013 Joe Walnes and the websocketd team.
# All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
# Self contained Go build file that will download and install (locally) the correct
# version of Go, and build our programs. Go does not need to be installed on the
# system (and if it already is, it will be ignored).
# To manually invoke the locally installed Go, use ./go
# Go installation config.
GO_VERSION=1.1.2.linux-amd64
GO_DOWNLOAD_URL=http://go.googlecode.com/files/go$(GO_VERSION).tar.gz
# 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.
go: go-v$(GO_VERSION)/.done
@echo '#!/bin/sh' > $@
@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'
# Download and unpack Go distribution.
go-v$(GO_VERSION)/.done:
mkdir -p $(dir $@)
rm -f $@
@echo Downloading and unpacking Go $(GO_VERSION) to $(dir $@)
curl --silent --fail $(GO_DOWNLOAD_URL) | tar xzf - --strip-components=1 -C $(dir $@)
touch $@
# Clean up binary
clean:
rm -rf websocketd go-workspace
.PHONY: clean
# Also clean up downloaded Go
clobber: clean
rm -rf go $(wildcard go-v*)
.PHONY: clobber