2017-08-13 01:57:08 +00:00
|
|
|
#
|
|
|
|
# Makefile for archive
|
|
|
|
#
|
|
|
|
|
2017-09-06 06:18:17 +00:00
|
|
|
VERSION:=3.0.1
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
SOURCES:=Makefile \
|
|
|
|
static \
|
|
|
|
cmd $(wildcard cmd/archive-server/*.go) \
|
|
|
|
$(wildcard *.go)
|
|
|
|
|
2017-08-13 05:14:03 +00:00
|
|
|
GOFLAGS := -ldflags='-s -w -X code.ivysaur.me/archive.SERVER_VERSION=archive/${VERSION}' -gcflags='-trimpath=$(GOPATH)' -asmflags='-trimpath=$(GOPATH)'
|
2017-08-13 01:57:08 +00:00
|
|
|
|
|
|
|
#
|
|
|
|
# Phony targets
|
|
|
|
#
|
|
|
|
|
|
|
|
.PHONY: all dist clean
|
|
|
|
|
|
|
|
all: build/linux64/archive-server build/win32/archive-server.exe
|
|
|
|
|
|
|
|
dist: \
|
|
|
|
_dist/archive-$(VERSION)-linux64.tar.gz \
|
|
|
|
_dist/archive-$(VERSION)-win32.7z \
|
|
|
|
_dist/archive-$(VERSION)-src.zip
|
|
|
|
|
|
|
|
clean:
|
|
|
|
if [ -f ./staticResources.go ] ; then rm ./staticResources.go ; fi
|
|
|
|
if [ -d ./build ] ; then rm -r ./build ; fi
|
|
|
|
if [ -f ./archive ] ; then rm ./archive ; fi
|
|
|
|
|
|
|
|
#
|
|
|
|
# Generated files
|
|
|
|
#
|
|
|
|
|
|
|
|
staticResources.go: static/ static/*
|
|
|
|
go-bindata -o staticResources.go -prefix static -pkg archive static
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Release artefacts
|
|
|
|
#
|
|
|
|
|
|
|
|
build/linux64/archive-server: $(SOURCES) staticResources.go
|
|
|
|
mkdir -p build/linux64
|
|
|
|
(cd cmd/archive-server ; \
|
|
|
|
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
|
|
|
|
go build $(GOFLAGS) -o ../../build/linux64/archive-server \
|
|
|
|
)
|
|
|
|
|
|
|
|
build/win32/archive-server.exe: $(SOURCES) staticResources.go
|
|
|
|
mkdir -p build/win32
|
|
|
|
(cd cmd/archive-server ; \
|
|
|
|
PATH=/usr/lib/mxe/usr/bin:$(PATH) CC=i686-w64-mingw32.static-gcc \
|
|
|
|
CGO_ENABLED=1 GOOS=windows GOARCH=386 \
|
|
|
|
go build $(GOFLAGS) -o ../../build/win32/archive-server.exe \
|
|
|
|
)
|
|
|
|
|
2017-08-13 04:54:44 +00:00
|
|
|
build/linux64/config.json.SAMPLE: cmd/archive-server/config.json.SAMPLE
|
|
|
|
cp cmd/archive-server/config.json.SAMPLE build/linux64/config.json.SAMPLE
|
|
|
|
|
|
|
|
build/win32/config.json.SAMPLE: cmd/archive-server/config.json.SAMPLE
|
|
|
|
cp cmd/archive-server/config.json.SAMPLE build/win32/config.json.SAMPLE
|
|
|
|
|
|
|
|
_dist/archive-$(VERSION)-linux64.tar.gz: build/linux64/archive-server build/linux64/config.json.SAMPLE
|
2017-08-13 01:57:08 +00:00
|
|
|
mkdir -p _dist
|
2017-08-13 04:54:44 +00:00
|
|
|
tar caf _dist/archive-$(VERSION)-linux64.tar.gz -C build/linux64 archive-server config.json.SAMPLE --owner=0 --group=0
|
2017-08-13 01:57:08 +00:00
|
|
|
|
2017-08-13 04:54:44 +00:00
|
|
|
_dist/archive-$(VERSION)-win32.7z: build/win32/archive-server.exe build/win32/config.json.SAMPLE
|
2017-08-13 01:57:08 +00:00
|
|
|
mkdir -p _dist
|
|
|
|
( cd build/win32 ; \
|
|
|
|
if [ -f dist.7z ] ; then rm dist.7z ; fi ; \
|
2017-08-13 04:54:44 +00:00
|
|
|
7z a dist.7z archive-server.exe config.json.SAMPLE ; \
|
2017-08-13 01:57:08 +00:00
|
|
|
mv dist.7z ../../_dist/archive-$(VERSION)-win32.7z \
|
|
|
|
)
|
|
|
|
|
|
|
|
_dist/archive-$(VERSION)-src.zip: $(SOURCES)
|
2017-08-13 04:54:49 +00:00
|
|
|
hg archive --type=zip _dist/archive-$(VERSION)-src.zip
|
2017-08-13 01:57:08 +00:00
|
|
|
|