add support for mingw64 build

This commit is contained in:
Bence Pőcze 2022-02-21 02:41:36 +01:00
parent eda132ee7d
commit c7cc152dc4
Signed by: bence
GPG Key ID: DC5BD6E95A333E6D
4 changed files with 51 additions and 4 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
build/ build/
mingw-w64-x86_64-xz/

View File

@ -1,7 +1,7 @@
CC=gcc CC=gcc
CXX=g++ CXX=g++
CFLAGS=-O3 CFLAGS=$(MINGWPATHS) -O3
CXXFLAGS=-O3 CXXFLAGS=-std=c++17 $(MINGWPATHS) -O3
DEPS = src/compress.h src/stringutils.h DEPS = src/compress.h src/stringutils.h
LIBS=-llzma LIBS=-llzma
OBJECTS = build/compress.o build/stringutils.o OBJECTS = build/compress.o build/stringutils.o
@ -17,11 +17,11 @@ build/%.o: src/%.c $(DEPS)
build/%.o: src/%.cpp $(DEPS) build/%.o: src/%.cpp $(DEPS)
$(MAKE_BUILD_FOLDER) $(MAKE_BUILD_FOLDER)
$(CXX) -c -o $@ $< $(CFLAGS) $(CXX) -c -o $@ $< $(CXXFLAGS)
build/compress_measurements: $(OBJECTS) src/compress_measurements.cpp build/compress_measurements: $(OBJECTS) src/compress_measurements.cpp
$(MAKE_BUILD_FOLDER) $(MAKE_BUILD_FOLDER)
$(CXX) -o $@ $^ $(LIBS) $(CFLAGS) $(CXX) -static -o $@ $^ $(LIBS) $(CXXFLAGS)
clean: clean:
-rm -rf build -rm -rf build

6
build-linux.sh Executable file
View File

@ -0,0 +1,6 @@
#!/bin/bash
set -e
make clean
make

40
build-windows.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
set -e
XZ_DIR="mingw-w64-x86_64-xz"
XZ_PACKAGE_VERSION_FILE="${XZ_DIR}/version"
XZ_PACKAGE_VERSION="mingw-w64-x86_64-xz-5.2.5-2-any.pkg.tar.zst"
if [ -f "${XZ_DIR}/version" ]; then
XZ_PACKAGE_INSTALLED_VERSION=$(<$XZ_PACKAGE_VERSION_FILE)
else
XZ_PACKAGE_INSTALLED_VERSION=""
fi
if [ "${XZ_PACKAGE_VERSION}" != "${XZ_PACKAGE_INSTALLED_VERSION}" ]; then
rm -rf ${XZ_DIR}
mkdir ${XZ_DIR}
(cd mingw-w64-x86_64-xz && \
wget -qO- https://mirror.msys2.org/mingw/mingw64/${XZ_PACKAGE_VERSION} | \
unzstd - | \
tar -xf -)
echo ${XZ_PACKAGE_VERSION} > ${XZ_PACKAGE_VERSION_FILE}
fi
export MINGWPATHS="-Imingw-w64-x86_64-xz/mingw64/include -Lmingw-w64-x86_64-xz/mingw64/lib"
case "$(uname -s)" in
Linux)
export CC="x86_64-w64-mingw32-gcc"
export CXX="x86_64-w64-mingw32-g++"
;;
MINGW*)
export CC="gcc"
export CXX="g++"
;;
esac
make clean
make