73 lines
2.1 KiB
Makefile
73 lines
2.1 KiB
Makefile
|
|
export PATH := /usr/lib/mxe/usr/bin:$(PATH)
|
|
GOFLAGS := -ldflags='-s -w' -gcflags='-trimpath=$(CURDIR)' -asmflags='-trimpath=$(CURDIR)'
|
|
VERSION := 1.0.2
|
|
|
|
.PHONY: all libs dist clean
|
|
|
|
all: \
|
|
build/linux/qbolt \
|
|
build/win32/release/qbolt.exe
|
|
|
|
libs: \
|
|
build/linux/qbolt.a \
|
|
build/win32/qbolt.a
|
|
|
|
dist: \
|
|
build/dist/qbolt-${VERSION}-win32.zip \
|
|
build/dist/qbolt-${VERSION}-linux_amd64.tar.xz
|
|
|
|
clean:
|
|
if [ -f qbolt/qbolt.a ] ; then rm qbolt/qbolt.a ; fi
|
|
if [ -f qbolt ] ; then rm qbolt ; fi
|
|
if [ -d build ] ; then rm -r build ; fi
|
|
|
|
# Build core golang shared library (linux)
|
|
|
|
build/linux/qbolt.a: *.go
|
|
mkdir -p build/linux
|
|
go build ${GOFLAGS} -buildmode=c-archive -o build/linux/qbolt.a
|
|
|
|
# Build core golang shared library (win32)
|
|
|
|
build/win32/qbolt.a: *.go
|
|
mkdir -p build/win32
|
|
CC=/usr/lib/mxe/usr/bin/i686-w64-mingw32.static-gcc CGO_ENABLED=1 GOARCH=386 GOOS=windows \
|
|
go build ${GOFLAGS} -buildmode=c-archive -o build/win32/qbolt.a
|
|
|
|
# Linux binaries
|
|
|
|
build/linux/qbolt: build/linux/qbolt.a qbolt/*
|
|
cd build/linux && qmake ../../qbolt/qbolt.pro && make
|
|
|
|
# Linux distribution
|
|
|
|
build/dist/qbolt-${VERSION}-linux_amd64.tar.xz: build/linux/qbolt
|
|
XZ_OPTS=-9 tar caf build/dist/qbolt-${VERSION}-linux_amd64.tar.xz -C build/linux qbolt --owner=0 --group=0
|
|
|
|
# Windows binaries
|
|
|
|
build/win32/release/qbolt.exe: build/win32/qbolt.a qbolt/*
|
|
cd build/win32 && i686-w64-mingw32.static-qmake-qt5 ../../qbolt/qbolt.pro && make
|
|
|
|
# Dockerized Windows build
|
|
|
|
.PHONY: build-docker-build-environment
|
|
build-docker-build-environment:
|
|
cd docker && docker build -t win32-cross-qt-mxe:latest -f win32-cross-qt-mxe.Dockerfile
|
|
|
|
.PHONY: build-windows-in-docker
|
|
build-windows-in-docker:
|
|
docker run --rm -v $(CURDIR):/qbolt win32-cross-qt-mxe:latest /bin/sh -c 'cd /qbolt && make build/win32/release/qbolt.exe'
|
|
|
|
# Windows distribution
|
|
|
|
build/win32/dist/qbolt.exe: build/win32/release/qbolt.exe
|
|
mkdir -p build/win32/dist
|
|
cp build/win32/release/qbolt.exe build/win32/dist/qbolt.exe
|
|
# upx --lzma build/win32/dist/qbolt.exe
|
|
|
|
build/dist/qbolt-${VERSION}-win32.zip: build/win32/dist/qbolt.exe
|
|
mkdir -p build/dist
|
|
zip -0 -j build/dist/qbolt-${VERSION}-win32.zip build/win32/dist/qbolt.exe
|