contented/Makefile

74 lines
1.8 KiB
Makefile
Raw Normal View History

2017-10-08 03:30:52 +00:00
#
# Makefile for contented
#
2018-06-09 06:13:22 +00:00
VERSION:=1.2.2
2017-10-08 03:30:52 +00:00
SOURCES:=Makefile \
static \
cmd $(wildcard cmd/contented/*.go) \
$(wildcard *.go)
GOFLAGS := -ldflags='-s -w -X code.ivysaur.me/contented.SERVER_HEADER=contented/${VERSION}' -gcflags='-trimpath=$(GOPATH)' -asmflags='-trimpath=$(GOPATH)'
2017-10-08 03:30:52 +00:00
#
# Phony targets
#
.PHONY: all dist clean
all: build/linux64/contented build/win32/contented.exe
dist: \
_dist/contented-$(VERSION)-linux64.tar.gz \
_dist/contented-$(VERSION)-win32.7z \
_dist/contented-$(VERSION)-src.zip
clean:
if [ -f ./staticResources.go ] ; then rm ./staticResources.go ; fi
if [ -d ./build ] ; then rm -r ./build ; fi
if [ -f ./contented ] ; then rm ./contented ; fi
#
# Generated files
#
staticResources.go: static/ static/*
go-bindata -o staticResources.go -prefix static -pkg contented static
#
# Release artefacts
#
build/linux64/contented: $(SOURCES) staticResources.go
mkdir -p build/linux64
(cd cmd/contented ; \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 \
go build $(GOFLAGS) -o ../../build/linux64/contented \
)
build/win32/contented.exe: $(SOURCES) staticResources.go
mkdir -p build/win32
(cd cmd/contented ; \
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/contented.exe \
)
_dist/contented-$(VERSION)-linux64.tar.gz: build/linux64/contented
mkdir -p _dist
tar caf _dist/contented-$(VERSION)-linux64.tar.gz -C build/linux64 contented --owner=0 --group=0
_dist/contented-$(VERSION)-win32.7z: build/win32/contented.exe
mkdir -p _dist
( cd build/win32 ; \
if [ -f dist.7z ] ; then rm dist.7z ; fi ; \
7z a dist.7z contented.exe ; \
mv dist.7z ../../_dist/contented-$(VERSION)-win32.7z \
)
_dist/contented-$(VERSION)-src.zip: $(SOURCES)
hg archive --type=zip _dist/contented-$(VERSION)-src.zip