1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

chore(build): add Windows cross-compilation instructions

This commit is contained in:
Maxim Biro 2017-07-25 06:55:40 -04:00
parent 4f25e01b96
commit c37529b101
8 changed files with 1025 additions and 271 deletions

View File

@ -34,6 +34,8 @@
- [Compile qTox](#compile-qtox)
- [OS X](#osx)
- [Windows](#windows)
- [Cross-compile from Linux](#cross-compile-from-linux)
- [Native](#native)
- [Compile-time switches](#compile-time-switches)
## Dependencies
@ -762,7 +764,13 @@ becoming a hacker
## Windows
### Qt
### Cross-compile from Linux
See [`windows/cross-compile`](windows/cross-compile).
### Native
#### Qt
Download the Qt online installer for Windows from
[qt.io](https://www.qt.io/download-open-source/). While installation you have
@ -773,7 +781,7 @@ needed to compile and install OpenAL. Thus you can - if needed - deselect the
tab `Tools`. The following steps assume that Qt is installed at `C:\Qt`. If you
decided to choose another location, replace corresponding parts.
### MinGW
#### MinGW
Download the MinGW installer for Windows from
[sourceforge.net](http://sourceforge.net/projects/mingw/files/Installer/). Make
@ -784,21 +792,21 @@ location, replace corresponding parts. Select `mingw-developer-toolkit`,
packages using MinGW Installation Manager (`mingw-get.exe`). Check that the
version of MinGW, corresponds to the version of the QT component!
### Wget
#### Wget
Download the Wget installer for Windows from
http://gnuwin32.sourceforge.net/packages/wget.htm. Install them. The following
steps assume that Wget is installed at `C:\Program Files (x86)\GnuWin32\`. If you
decided to choose another location, replace corresponding parts.
### UnZip
#### UnZip
Download the UnZip installer for Windows from
http://gnuwin32.sourceforge.net/packages/unzip.htm. Install it. The following
steps assume that UnZip is installed at `C:\Program Files (x86)\GnuWin32\`. If you
decided to choose another location, replace corresponding parts.
### Setting up Path
#### Setting up Path
Add MinGW/MSYS/CMake binaries to the system path to make them globally
accessible. Open `Control Panel` -> `System and Security` -> `System` ->
@ -813,7 +821,7 @@ by installer automatically. Make sure that paths containing alternative `sh`,
`bash` implementations such as `C:\Program Files\OpenSSH\bin` are at the end of
`PATH` or build may fail.
### Cloning the Repository
#### Cloning the Repository
Clone the repository (https://github.com/qTox/qTox.git) with your preferred Git
client. [SmartGit](http://www.syntevo.com/smartgit/) or
@ -822,7 +830,7 @@ client. [SmartGit](http://www.syntevo.com/smartgit/) or
following steps assume that you cloned the repository at `C:\qTox`. If you
decided to choose another location, replace corresponding parts.
### Getting dependencies
#### Getting dependencies
Run `bootstrap.bat` in the previously cloned `C:\qTox` repository. The script will
download the other necessary dependencies, compile them and put them into their

View File

@ -1,4 +0,0 @@
@echo off
sh bootstrap.sh
@pause

View File

@ -19,14 +19,6 @@
set -eu -o pipefail
# windows check
if cmd.exe /c ver 2>/dev/null
then
cd windows
./bootstrap.sh
exit $?
fi
################ parameters ################
# directory where the script is located

View File

@ -1,113 +0,0 @@
#!/bin/sh
QTOX_DIR=`pwd`/..
if [ -d $QTOX_DIR/libs ]; then
echo "Remove ./libs and redownload/recompile dependencies?"
read -p "m/a/N (missing/all/no): " yn
yn=$(echo $yn | tr "[:upper:]" "[:lower:]")
if [ "$yn" == "a" ]; then
rm -rf $QTOX_DIR/libs
elif [ "$yn" == "n" ]; then
exit 1
elif [ "$yn" != "m" ]; then
exit 1
fi
fi
mkdir -p $QTOX_DIR/libs
cd $QTOX_DIR/libs
## toxcore
if [ ! -f "libtoxcore_build_windows_x86_shared_release.zip" ]; then
wget --no-check-certificate https://build.tox.chat/view/libtoxcore/job/libtoxcore_build_windows_x86_shared_release/lastSuccessfulBuild/artifact/libtoxcore_build_windows_x86_shared_release.zip
rm -rf include/tox
fi
if [ ! -d "include/tox" ]; then
unzip -o libtoxcore_build_windows_x86_shared_release.zip -d ./
fi
## qrencode
if [ ! -f "qrencode-3.4.4.tar.gz" ]; then
wget https://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz
fi
if [ ! -f "qrencode-3.4.4.tar.gz" ]; then
echo "Warning: Failed to download libqrencode."
echo "Warning: This is usually due to https certificate issues."
echo
echo "Would you like to continue without verifying the certificate?"
read -p "(yes/No) y/N: " input
input=$(echo $input | tr "[:upper:]" "[:lower:]")
if [ "${input%es}" == y ]; then
wget --no-check-certificate https://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.gz
else
echo "Error: Could not download libqrencode."
exit 1
fi
fi
if [ ! -d "$QTOX_DIR/libs/qrencode-3.4.4" ]; then
tar -xvf qrencode-3.4.4.tar.gz
rm -rf lib/qrcodelib.dll
fi
if [ ! -f "lib/libqrencode.a" ]; then
pushd $QTOX_DIR/libs/qrencode-3.4.4
./autogen.sh
./configure --prefix=$QTOX_DIR/libs --without-tests --without-libiconv-prefix --without-tools
make
make install
popd
fi
## OpenAL
if [ ! -f "openal-soft-1.16.0.tar.bz2" ]; then
wget http://kcat.strangesoft.net/openal-releases/openal-soft-1.16.0.tar.bz2
rm -rf openal-soft-1.16.0
fi
if [ ! -d "openal-soft-1.16.0" ]; then
tar -xvf openal-soft-1.16.0.tar.bz2
rm bin/OpenAL32.dll
fi
if [ ! -f "bin/OpenAL32.dll" ]; then
pushd openal-soft-1.16.0/build
CFLAGS="-D_TIMESPEC_DEFINED" cmake -G "MSYS Makefiles" -DQT_QMAKE_EXECUTABLE=NOTFOUND -DCMAKE_BUILD_TYPE=Release -DALSOFT_REQUIRE_DSOUND=NO -DCMAKE_INSTALL_PREFIX=$QTOX_DIR/libs ..
make
make install
popd
fi
## ffmpeg
if [ ! -f "ffmpeg-2.7.tar.bz2" ]; then
wget http://ffmpeg.org/releases/ffmpeg-2.7.tar.bz2 -O ffmpeg-2.7.tar.bz2
rm -rf ffmpeg-2.7
fi
if [ ! -d "ffmpeg-2.7" ]; then
tar -xvf ffmpeg-2.7.tar.bz2
rm bin/avcodec-56.dll
pushd ffmpeg-2.7
patch -p1 < $QTOX_DIR/windows/ffmpeg-2.7-mingw.diff
popd
fi
if [ ! -f "bin/avcodec-56.dll" ]; then
pushd ffmpeg-2.7
./configure --target-os=mingw32 --prefix=$QTOX_DIR/libs \
--enable-memalign-hack --disable-swscale-alpha --disable-programs --disable-doc --disable-postproc \
--disable-avfilter --disable-avresample --disable-swresample --disable-protocols --disable-filters \
--disable-network --disable-muxers --disable-sdl --disable-iconv --disable-bzlib --disable-lzma \
--disable-zlib --disable-xlib --disable-encoders --enable-shared --disable-static --disable-yasm
make
make install
popd
fi
echo **Done**

View File

@ -1,18 +0,0 @@
#!/bin/bash
# Builds qTox for Windows and prepares a redistribuable .zip archive
export PATH=/root/mxe/usr/bin:$PATH
tar xvf libs.tar.gz
tar xvf libtoxcore-win32.tar.gz -C libs
/root/mxe/usr/i686-pc-mingw32.shared/qt5/bin/qmake
make clean
make -j4 || { echo 'make failed, aborting' ; exit 1; }
rm -rf qTox-win32
rm -rf qTox-win32.zip
mkdir qTox-win32
tar xvf qtox-dlls.tar.gz -C qTox-win32
cp libs/bin/* qTox-win32
cp release/qtox.exe qTox-win32
rm -rf qTox-win32.zip
zip -r qTox-win32.zip qTox-win32
chmod 777 qTox-win32.zip

View File

@ -0,0 +1,125 @@
# Cross-compile from Linux
## Intro
Following these instructions you will be able to cross-compile qTox to Windows.
This script can be used by qTox power users to cross-compile qTox themselves,as
well as by qTox developers to make sure their local changes don't break
cross-compilation to Windows.
Note that the compilation script doesn't build the updater and doesn't produce
an installer.
## Usage
[Install Docker](https://docs.docker.com/engine/installation/linux/).
You should have 3 directories available (names don't have to match the given
ones):
1. `workspace` -- a directory that will contain a cache of qTox dependencies
and the final qTox cross-compilation build. You should create this directory.
2. `script` -- a directory that contains the `build.sh` script. You can use
this directory for this, there is no need to create a new one.
3. `qtox` -- a root directory of a qTox repository. This directory contains
qTox source code that will be cross-compiled. You can use the root of this qTox
repository, there is no need to create a new one.
These directories will be mounted inside a Docker container at `/workspace`,
`/script` and `/qtox`.
The contents of `qtox` and `script` directories wouldn't be modified. The
`build.sh` script actually makes a copy of `qtox` directory and works on that
copy.
Once you sort out the directories, you are ready to run the `build.sh` script
in a Docker container.
Note that the `build.sh` script takes 2 arguments: architecture and build type.
Valid values for the architecture are `i686` for 32-bit and `x86_64` for
64-bit. Valid values for the build type are `release` and `debug`. All case
sensitive.
Now, to start the cross-compilation, for example, for a 32-bit release qTox, run
```sh
sudo docker run --rm \
-v /absolute/path/to/your/workspace:/workspace \
-v /absolute/path/to/your/script:/script \
-v /absolute/path/to/your/qtox:/qtox \
ubuntu:16.04 \
/bin/bash /script/build.sh i686 release
```
If you are a qTox developer, you might want to instead run
```sh
# Get shell inside Ubuntu 16.04 container so that you can poke around if needed
sudo docker run -it \
--rm \
-v /absolute/path/to/your/workspace:/workspace \
-v /absolute/path/to/your/script:/script \
-v /absolute/path/to/your/qtox:/qtox \
ubuntu:16.04 \
/bin/bash
# Run the script
bash /script/build.sh i686 release
```
This will cross-compile all of the qTox dependencies and qTox itself, storing
them in the `workspace` directory. The first time you run it for each
architecture, it will take a long time for the cross-compilation to finish, as
qTox has a lot of dependencies that need to be cross-compiled. It takes my
Intel Core i7 processor about 125 minutes for the cross-compilation to get done
on a single core, and about 30 minutes using all 8 hyperthreads. But once you
do it once for each architecture, the dependencies will get cached inside the
`workspace` directory, and the next time you build qTox, the `build.sh` script
will skip recompiling them, going straight to compiling qTox, which is a lot
faster -- about 8 minutes on a single core and 2 minutes using 8 hyperthreads.
The structure of `workspace` directory that the `build.sh` script will create
is as follows:
```
workspace
├── i686
│ ├── dep-cache
│ │ ├── libffmpeg
│ │ ├── libfilteraudio
│ │ ├── libopenal
│ │ ├── libopenssl
│ │ ├── libopus
│ │ ├── libqrencode
│ │ ├── libqt5
│ │ ├── libsodium
│ │ ├── libsqlcipher
│ │ ├── libtoxcore
│ │ └── libvpx
│ └── qtox
│ ├── debug
│ └── release
└── x86_64
├── dep-cache
│ ├── libffmpeg
│ ├── libfilteraudio
│ ├── libopenal
│ ├── libopenssl
│ ├── libopus
│ ├── libqrencode
│ ├── libqt5
│ ├── libsodium
│ ├── libsqlcipher
│ ├── libtoxcore
│ └── libvpx
└── qtox
├── debug
└── release
```
The `dep-cache` directory is where all cross-compiled qTox dependencies will be
cached for the future runs. You can remove any directory inside `deps`, which
will result in the `build.sh` re-compiling the missing dependency.
The `qtox` directory, split into `debug` and `release`, is where the
cross-compiled qTox will be stored.

View File

@ -0,0 +1,885 @@
#!/usr/bin/env bash
# MIT License
#
# Copyright (c) 2017 Maxim Biro <nurupo.contributions@gmail.com>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
# Known issues:
# - Doesn't build qTox updater, because it wasn't ported to cmake yet and
# because it requires static Qt, which means we'd need to build Qt twice,
# and building Qt takes really long time.
#
# - Doesn't create an installer because there is no NSIS 3 in Ubuntu. We could
# switch to Debian instead and backport it from Experimental, which is what
# we do on Jenkins, but since we don't build an updater, we might as well
# just do the nightly qTox build: no updater, no installer.
#
# - Qt from 5.8.0 to 5.9.1 doesn't cross-compile to Windows due to
# https://bugreports.qt.io/browse/QTBUG-61740. Should be fixed in 5.9.2. You
# can easily patch it though, just one sed command, but I guess we will wait
# for 5.9.2.
#
# - FFmpeg 3.3 doesn't cross-compile correctly, qTox build fails when linking
# against the 3.3 FFmpeg. They have removed `--enable-memalign-hack` switch,
# which might be what causes this.
#
# - Toxcore v0.1.9 doesn't cross-compile to Windows due to a linking order
# issue in monolith_test https://github.com/TokTok/c-toxcore/pull/564. It's
# fixed in master, so we just wait checking out a stable master commit point
# until the next release. Once the next release occurs, we will be checking
# out that instead.
set -euo pipefail
# Common directory paths
readonly WORKSPACE_DIR="/workspace"
readonly SCRIPT_DIR="/script"
readonly QTOX_SRC_DIR="/qtox"
# Make sure we run in an expected environment
if ! grep -q 'buntu 16\.04' /etc/lsb-release
then
echo "Error: This script should be run on Ubuntu 16.04."
exit 1
fi
if [ ! -d "$WORKSPACE_DIR" ] || [ ! -d "$SCRIPT_DIR" ] || [ ! -d "$QTOX_SRC_DIR" ]
then
echo "Error: At least one of $WORKSPACE_DIR, $SCRIPT_DIR or $QTOX_SRC_DIR directories is missing."
exit 1
fi
if [ ! -d "$QTOX_SRC_DIR/src" ]
then
echo "Error: $QTOX_SRC_DIR/src directory is missing, make sure $QTOX_SRC_DIR contains qTox source code."
exit 1
fi
if [ "$(id -u)" != "0" ]
then
echo "Error: This script must be run as root."
exit 1
fi
# Check arguments
readonly ARCH=$1
readonly BUILD_TYPE=$2
if [ -z "$ARCH" ]
then
echo "Error: No architecture was specified. Please specify either 'i686' or 'x86_64', case sensitive, as the first argument to the script."
exit 1
fi
if [[ "$ARCH" != "i686" ]] && [[ "$ARCH" != "x86_64" ]]
then
echo "Error: Incorrect architecture was specified. Please specify either 'i686' or 'x86_64', case sensitive, as the first argument to the script."
exit 1
fi
if [ -z "$BUILD_TYPE" ]
then
echo "Error: No build type was specified. Please specify either 'release' or 'debug', case sensitive, as the second argument to the script."
exit 1
fi
if [[ "$BUILD_TYPE" != "release" ]] && [[ "$BUILD_TYPE" != "debug" ]]
then
echo "Error: Incorrect build type was specified. Please specify either 'release' or 'debug', case sensitive, as the second argument to the script."
exit 1
fi
# More directory variables
readonly BUILD_DIR="/build"
readonly DEP_DIR="$WORKSPACE_DIR/$ARCH/dep-cache"
set -x
# Get packages
apt-get update
apt-get install -y --no-install-recommends \
autoconf \
automake \
build-essential \
ca-certificates \
cmake \
git \
libtool \
pkg-config \
tclsh \
unzip \
wget \
yasm
if [[ "$ARCH" == "i686" ]]
then
apt-get install -y --no-install-recommends \
g++-mingw-w64-i686 \
gcc-mingw-w64-i686
elif [[ "$ARCH" == "x86_64" ]]
then
apt-get install -y --no-install-recommends \
g++-mingw-w64-x86-64 \
gcc-mingw-w64-x86-64
fi
# Create the expected directory structure
# Just make sure those exist
mkdir -p "$WORKSPACE_DIR"
mkdir -p "$DEP_DIR"
# Build dir should be empty
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
cd "$BUILD_DIR"
# Use all cores for building
MAKEFLAGS=j$(nproc)
export MAKEFLAGS
# OpenSSL
OPENSSL_PREFIX_DIR="$DEP_DIR/libopenssl"
if [ ! -f "$OPENSSL_PREFIX_DIR/done" ]
then
rm -rf "$OPENSSL_PREFIX_DIR"
mkdir -p "$OPENSSL_PREFIX_DIR"
OPENSSL_VERSION=1.0.2l
OPENSSL_SHA256_HASH=ce07195b659e75f4e1db43552860070061f156a98bb37b672b101ba6e3ddf30c
wget https://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
if ! ( echo "$OPENSSL_SHA256_HASH openssl-$OPENSSL_VERSION.tar.gz" | sha256sum -c --status - )
then
echo "Error: sha256 of openssl-$OPENSSL_VERSION.tar.gz doesn't match the known one."
exit 1
else
echo "sha256 matches the expected one: $OPENSSL_SHA256_HASH"
fi
tar -xf openssl*.tar.gz
rm openssl*.tar.gz
cd openssl*
CONFIGURE_OPTIONS="--prefix=$OPENSSL_PREFIX_DIR shared"
if [[ "$ARCH" == "x86_64" ]]
then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS mingw64 --cross-compile-prefix=x86_64-w64-mingw32-"
elif [[ "$ARCH" == "i686" ]]
then
CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS mingw --cross-compile-prefix=i686-w64-mingw32-"
fi
./Configure $CONFIGURE_OPTIONS
make
make install
touch $OPENSSL_PREFIX_DIR/done
CONFIGURE_OPTIONS=""
cd ..
rm -rf ./openssl*
fi
# Qt
QT_PREFIX_DIR="$DEP_DIR/libqt5"
if [ ! -f "$QT_PREFIX_DIR/done" ]
then
rm -rf "$QT_PREFIX_DIR"
mkdir -p "$QT_PREFIX_DIR"
QT_MIRROR=http://qt.mirror.constant.com
QT_MAJOR=5
QT_MINOR=6
QT_PATCH=2
QT_VERSION=$QT_MAJOR.$QT_MINOR.$QT_PATCH
wget $QT_MIRROR/official_releases/qt/$QT_MAJOR.$QT_MINOR/$QT_VERSION/single/qt-everywhere-opensource-src-$QT_VERSION.tar.xz
tar -xf qt*.tar.xz
rm qt*.tar.xz
cd qt*
export PKG_CONFIG_PATH="$OPENSSL_PREFIX_DIR/lib/pkgconfig"
export OPENSSL_LIBS="$(pkg-config --libs openssl)"
./configure -prefix $QT_PREFIX_DIR \
-release \
-shared \
-device-option CROSS_COMPILE=$ARCH-w64-mingw32- \
-xplatform win32-g++ \
-openssl \
$(pkg-config --cflags openssl) \
-opensource -confirm-license \
-pch \
-nomake examples \
-nomake tools \
-nomake tests \
-skip translations \
-skip doc \
-skip qtdeclarative \
-skip activeqt \
-skip qtwebsockets \
-skip qtscript \
-skip qtquickcontrols \
-skip qtconnectivity \
-skip qtenginio \
-skip qtsensors \
-skip qtserialport \
-skip qtlocation \
-skip qtgraphicaleffects \
-skip qtimageformats \
-skip webchannel \
-skip multimedia \
-no-dbus \
-no-icu \
-no-qml-debug \
-no-compile-examples \
-qt-libjpeg \
-qt-libpng \
-qt-zlib \
-qt-pcre
make
make install
touch $QT_PREFIX_DIR/done
unset PKG_CONFIG_PATH
unset OPENSSL_LIBS
cd ..
rm -rf ./qt*
fi
# SQLCipher
SQLCIPHER_PREFIX_DIR="$DEP_DIR/libsqlcipher"
if [ ! -f "$SQLCIPHER_PREFIX_DIR/done" ]
then
rm -rf "$SQLCIPHER_PREFIX_DIR"
mkdir -p "$SQLCIPHER_PREFIX_DIR"
git clone \
--branch v3.4.1 \
--depth 1 \
https://github.com/sqlcipher/sqlcipher \
sqlcipher
cd sqlcipher
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
sed -i s/'LIBS="-lcrypto $LIBS"'/'LIBS="-lcrypto -lgdi32 $LIBS"'/g configure
sed -i s/'if test "$TARGET_EXEEXT" = ".exe"'/'if test ".exe" = ".exe"'/g configure
> Makefile.in-patch cat << "EOF"
--- Makefile.in 2017-07-24 04:33:46.944080013 +0000
+++ Makefile.in-patch 2017-07-24 04:50:47.340596990 +0000
@@ -1074,7 +1074,7 @@
$(TOP)/ext/fts5/fts5_varint.c \
$(TOP)/ext/fts5/fts5_vocab.c \
-fts5parse.c: $(TOP)/ext/fts5/fts5parse.y lemon
+fts5parse.c: $(TOP)/ext/fts5/fts5parse.y lemon$(BEXE)
cp $(TOP)/ext/fts5/fts5parse.y .
rm -f fts5parse.h
./lemon$(BEXE) $(OPTS) fts5parse.y
EOF
patch -l < Makefile.in-patch
./configure --host="$ARCH-w64-mingw32" \
--prefix="$SQLCIPHER_PREFIX_DIR" \
--disable-shared \
--enable-tempstore=yes \
CFLAGS="-O2 -g0 -DSQLITE_HAS_CODEC -I$OPENSSL_PREFIX_DIR/include/" \
LDFLAGS="$OPENSSL_PREFIX_DIR/lib/libcrypto.a -lcrypto -lgdi32 -L$OPENSSL_PREFIX_DIR/lib/"
sed -i s/"TEXE = $"/"TEXE = .exe"/ Makefile
make
make install
touch $SQLCIPHER_PREFIX_DIR/done
cd ..
rm -rf ./sqlcipher
fi
# FFmpeg
FFMPEG_PREFIX_DIR="$DEP_DIR/libffmpeg"
if [ ! -f "$FFMPEG_PREFIX_DIR/done" ]
then
rm -rf "$FFMPEG_PREFIX_DIR"
mkdir -p "$FFMPEG_PREFIX_DIR"
wget https://www.ffmpeg.org/releases/ffmpeg-3.2.6.tar.xz
tar -xf ffmpeg*.tar.xz
cd ffmpeg*
if [[ "$ARCH" == "x86_64"* ]]
then
CONFIGURE_OPTIONS="--arch=x86_64"
elif [[ "$ARCH" == "i686" ]]
then
CONFIGURE_OPTIONS="--arch=x86"
fi
./configure $CONFIGURE_OPTIONS \
--prefix="$FFMPEG_PREFIX_DIR" \
--target-os="mingw32" \
--cross-prefix="$ARCH-w64-mingw32-" \
--pkg-config="pkg-config" \
--extra-cflags="-static -O2 -g0" \
--extra-ldflags="-lm -static" \
--pkg-config-flags="--static" \
--disable-shared \
--disable-programs \
--disable-protocols \
--disable-doc \
--disable-sdl \
--disable-avfilter \
--disable-avresample \
--disable-filters \
--disable-iconv \
--disable-network \
--disable-muxers \
--disable-postproc \
--disable-swresample \
--disable-swscale-alpha \
--disable-dct \
--disable-dwt \
--disable-lsp \
--disable-lzo \
--disable-mdct \
--disable-rdft \
--disable-fft \
--disable-faan \
--disable-vaapi \
--disable-vdpau \
--disable-zlib \
--disable-xlib \
--disable-bzlib \
--disable-lzma \
--disable-encoders \
--disable-decoders \
--disable-demuxers \
--disable-parsers \
--enable-demuxer=h264 \
--enable-demuxer=mjpeg \
--enable-parser=h264 \
--enable-parser=mjpeg \
--enable-decoder=h264 \
--enable-decoder=mjpeg \
--enable-memalign-hack
make
make install
touch $FFMPEG_PREFIX_DIR/done
CONFIGURE_OPTIONS=""
cd ..
rm -rf ./ffmpeg*
fi
# Openal-soft (irungentoo's fork)
OPENAL_PREFIX_DIR="$DEP_DIR/libopenal"
if [ ! -f "$OPENAL_PREFIX_DIR/done" ]
then
rm -rf "$OPENAL_PREFIX_DIR"
mkdir -p "$OPENAL_PREFIX_DIR"
git clone https://github.com/irungentoo/openal-soft-tox openal-soft-tox
cd openal*
git checkout b80570bed017de60b67c6452264c634085c3b148
echo "
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER $ARCH-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER $ARCH-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER $ARCH-w64-mingw32-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/$ARCH-w64-mingw32)
# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
" > toolchain.cmake
CFLAGS="-fPIC" cmake -DCMAKE_INSTALL_PREFIX="$OPENAL_PREFIX_DIR" \
-DCMAKE_BUILD_TYPE=Release \
-DALSOFT_UTILS=OFF \
-DALSOFT_EXAMPLES=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake \
-DDSOUND_INCLUDE_DIR=/usr/$ARCH-w64-mingw32/include \
-DDSOUND_LIBRARY=/usr/$ARCH-w64-mingw32/lib/libdsound.a
make
make install
touch $OPENAL_PREFIX_DIR/done
cd ..
rm -rf ./openal*
fi
# Filteraudio
FILTERAUDIO_PREFIX_DIR="$DEP_DIR/libfilteraudio"
if [ ! -f "$FILTERAUDIO_PREFIX_DIR/done" ]
then
rm -rf "$FILTERAUDIO_PREFIX_DIR"
mkdir -p "$FILTERAUDIO_PREFIX_DIR"
git clone https://github.com/irungentoo/filter_audio filter_audio
cd filter*
git checkout ada2f4fdc04940cdeee47caffe43add4fa017096
$ARCH-w64-mingw32-gcc -O2 -g0 -c \
aec/aec_core.c \
aec/aec_core_sse2.c \
aec/aec_rdft.c \
aec/aec_rdft_sse2.c \
aec/aec_resampler.c \
aec/echo_cancellation.c \
agc/analog_agc.c \
agc/digital_agc.c \
ns/ns_core.c \
ns/nsx_core_c.c \
ns/nsx_core.c \
ns/noise_suppression_x.c \
ns/noise_suppression.c \
other/get_scaling_square.c \
other/resample_by_2.c \
other/spl_sqrt.c \
other/delay_estimator.c \
other/complex_bit_reverse.c \
other/dot_product_with_scale.c \
other/cross_correlation.c \
other/min_max_operations.c \
other/resample_48khz.c \
other/high_pass_filter.c \
other/energy.c \
other/randomization_functions.c \
other/speex_resampler.c \
other/copy_set_operations.c \
other/downsample_fast.c \
other/complex_fft.c \
other/vector_scaling_operations.c \
other/resample_by_2_internal.c \
other/delay_estimator_wrapper.c \
other/real_fft.c \
other/spl_sqrt_floor.c \
other/resample_fractional.c \
other/ring_buffer.c \
other/splitting_filter.c \
other/fft4g.c \
other/division_operations.c \
other/spl_init.c \
other/float_util.c \
zam/filters.c \
vad/vad_sp.c \
vad/vad_core.c \
vad/webrtc_vad.c \
vad/vad_gmm.c \
vad/vad_filterbank.c \
filter_audio.c \
-lpthread \
-lm
ar rcs libfilteraudio.a \
aec_core.o \
aec_core_sse2.o \
aec_rdft.o \
aec_rdft_sse2.o \
aec_resampler.o \
echo_cancellation.o \
analog_agc.o \
digital_agc.o \
ns_core.o \
nsx_core_c.o \
nsx_core.o \
noise_suppression_x.o \
noise_suppression.o \
get_scaling_square.o \
resample_by_2.o \
spl_sqrt.o \
delay_estimator.o \
complex_bit_reverse.o \
dot_product_with_scale.o \
cross_correlation.o \
min_max_operations.o \
resample_48khz.o \
high_pass_filter.o \
energy.o \
randomization_functions.o \
speex_resampler.o \
copy_set_operations.o \
downsample_fast.o \
complex_fft.o \
vector_scaling_operations.o \
resample_by_2_internal.o \
delay_estimator_wrapper.o \
real_fft.o \
spl_sqrt_floor.o \
resample_fractional.o \
ring_buffer.o \
splitting_filter.o \
fft4g.o \
division_operations.o \
spl_init.o \
float_util.o \
filters.o \
vad_sp.o \
vad_core.o \
webrtc_vad.o \
vad_gmm.o \
vad_filterbank.o \
filter_audio.o
mkdir $FILTERAUDIO_PREFIX_DIR/include
mkdir $FILTERAUDIO_PREFIX_DIR/lib
cp filter_audio.h $FILTERAUDIO_PREFIX_DIR/include
cp libfilteraudio.a $FILTERAUDIO_PREFIX_DIR/lib
touch $FILTERAUDIO_PREFIX_DIR/done
cd ..
rm -rf ./filter*
fi
# QREncode
QRENCODE_PREFIX_DIR="$DEP_DIR/libqrencode"
if [ ! -f "$QRENCODE_PREFIX_DIR/done" ]
then
rm -rf "$QRENCODE_PREFIX_DIR"
mkdir -p "$QRENCODE_PREFIX_DIR"
wget https://fukuchi.org/works/qrencode/qrencode-3.4.4.tar.bz2
tar -xf qrencode*.tar.bz2
rm qrencode*.tar.bz2
cd qrencode*
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$QRENCODE_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-sdltest \
--without-tools \
--without-debug
make
make install
touch $QRENCODE_PREFIX_DIR/done
cd ..
rm -rf ./qrencode*
fi
# Opus
OPUS_PREFIX_DIR="$DEP_DIR/libopus"
if [ ! -f "$OPUS_PREFIX_DIR/done" ]
then
rm -rf "$OPUS_PREFIX_DIR"
mkdir -p "$OPUS_PREFIX_DIR"
git clone \
--branch v1.2.1 \
--depth 1 \
git://git.opus-codec.org/opus.git \
opus
cd opus
./autogen.sh
CFLAGS="-O2 -g0" ./configure --host="$ARCH-w64-mingw32" \
--prefix="$OPUS_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-extra-programs \
--disable-doc
make
make install
touch $OPUS_PREFIX_DIR/done
cd ..
rm -rf ./opus
fi
# Sodium
SODIUM_PREFIX_DIR="$DEP_DIR/libsodium"
if [ ! -f "$SODIUM_PREFIX_DIR/done" ]
then
rm -rf "$SODIUM_PREFIX_DIR"
mkdir -p "$SODIUM_PREFIX_DIR"
git clone \
--branch 1.0.13 \
--depth 1 \
https://github.com/jedisct1/libsodium \
libsodium
cd libsodium
./autogen.sh
./configure --host="$ARCH-w64-mingw32" \
--prefix="$SODIUM_PREFIX_DIR" \
--disable-shared \
--enable-static \
--with-pic
make
make install
touch $SODIUM_PREFIX_DIR/done
cd ..
rm -rf ./libsodium
fi
# VPX
VPX_PREFIX_DIR="$DEP_DIR/libvpx"
if [ ! -f "$VPX_PREFIX_DIR/done" ]
then
rm -rf "$VPX_PREFIX_DIR"
mkdir -p "$VPX_PREFIX_DIR"
git clone \
--branch v1.6.1 \
--depth 1 \
https://github.com/webmproject/libvpx \
libvpx
cd libvpx
if [[ "$ARCH" == "x86_64" ]]
then
VPX_TARGET=x86_64-win64-gcc
elif [[ "$ARCH" == "i686" ]]
then
VPX_TARGET=x86-win32-gcc
fi
CROSS="$ARCH-w64-mingw32-" ./configure --target="$VPX_TARGET" \
--prefix="$VPX_PREFIX_DIR" \
--disable-shared \
--enable-static \
--disable-examples \
--disable-tools \
--disable-docs \
--disable-unit-tests
make
make install
touch $VPX_PREFIX_DIR/done
cd ..
rm -rf ./libvpx
fi
# Toxcore
TOXCORE_PREFIX_DIR="$DEP_DIR/libtoxcore"
if [ ! -f "$TOXCORE_PREFIX_DIR/done" ]
then
rm -rf "$TOXCORE_PREFIX_DIR"
mkdir -p "$TOXCORE_PREFIX_DIR"
git clone https://github.com/TokTok/c-toxcore
cd c-toxcore
git checkout 1b290c0d84d92fd28fc1f64f33bf4455d73e2e2e
export PKG_CONFIG_PATH="$OPUS_PREFIX_DIR/lib/pkgconfig:$SODIUM_PREFIX_DIR/lib/pkgconfig:$VPX_PREFIX_DIR/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="/usr/$ARCH-w64-mingw32"
echo "
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER $ARCH-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER $ARCH-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER $ARCH-w64-mingw32-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/$ARCH-w64-mingw32 $OPUS_PREFIX_DIR $SODIUM_PREFIX_DIR $VPX_PREFIX_DIR)
" > toolchain.cmake
cmake -DCMAKE_INSTALL_PREFIX=$TOXCORE_PREFIX_DIR \
-DBOOTSTRAP_DAEMON=OFF \
-DWARNINGS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DENABLE_STATIC=ON \
-DENABLE_SHARED=OFF \
-DCMAKE_TOOLCHAIN_FILE=toolchain.cmake
make
make install
touch $TOXCORE_PREFIX_DIR/done
unset PKG_CONFIG_PATH
unset PKG_CONFIG_LIBDIR
cd ..
rm -rf ./c-toxcore
fi
# Strip to reduce file size, we don't need this information anyway.
set +e
for PREFIX_DIR in $DEP_DIR/*; do
strip --strip-unneeded $PREFIX_DIR/bin/*
$ARCH-w64-mingw32-strip --strip-unneeded $PREFIX_DIR/bin/*
$ARCH-w64-mingw32-strip --strip-unneeded $PREFIX_DIR/lib/*
done
set -e
# qTox
QTOX_PREFIX_DIR="$WORKSPACE_DIR/$ARCH/qtox/$BUILD_TYPE"
rm -rf "$QTOX_PREFIX_DIR"
mkdir -p "$QTOX_PREFIX_DIR"
rm -rf ./qtox
mkdir -p qtox
cd qtox
cp -a $QTOX_SRC_DIR/. .
mkdir build
cd build
PKG_CONFIG_PATH=""
PKG_CONFIG_LIBDIR=""
CMAKE_FIND_ROOT_PATH=""
for PREFIX_DIR in $DEP_DIR/*; do
if [ -d $PREFIX_DIR/lib/pkgconfig ]
then
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:$PREFIX_DIR/lib/pkgconfig"
export PKG_CONFIG_LIBDIR="$PKG_CONFIG_LIBDIR:$PREFIX_DIR/lib/pkgconfig"
CMAKE_FIND_ROOT_PATH="$CMAKE_FIND_ROOT_PATH $PREFIX_DIR"
fi
done
echo "
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_C_COMPILER $ARCH-w64-mingw32-gcc)
SET(CMAKE_CXX_COMPILER $ARCH-w64-mingw32-g++)
SET(CMAKE_RC_COMPILER $ARCH-w64-mingw32-windres)
SET(CMAKE_FIND_ROOT_PATH /usr/$ARCH-w64-mingw32 $CMAKE_FIND_ROOT_PATH)
" > toolchain.cmake
if [[ "$BUILD_TYPE" == "release" ]]
then
cmake -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake \
-DCMAKE_BUILD_TYPE=Release \
..
elif [[ "$BUILD_TYPE" == "debug" ]]
then
cmake -DCMAKE_TOOLCHAIN_FILE=./toolchain.cmake \
-DCMAKE_BUILD_TYPE=Debug \
..
fi
make
cp qtox.exe $QTOX_PREFIX_DIR
cp $QT_PREFIX_DIR/bin/Qt5Core.dll \
$QT_PREFIX_DIR/bin/Qt5Gui.dll \
$QT_PREFIX_DIR/bin/Qt5Network.dll \
$QT_PREFIX_DIR/bin/Qt5Sql.dll \
$QT_PREFIX_DIR/bin/Qt5Svg.dll \
$QT_PREFIX_DIR/bin/Qt5Widgets.dll \
$QT_PREFIX_DIR/bin/Qt5Xml.dll \
$QTOX_PREFIX_DIR
cp -r $QT_PREFIX_DIR/plugins/imageformats \
$QT_PREFIX_DIR/plugins/platforms \
$QT_PREFIX_DIR/plugins/sqldrivers \
$QT_PREFIX_DIR/plugins/iconengines \
$QTOX_PREFIX_DIR
cp $OPENAL_PREFIX_DIR/bin/OpenAL32.dll $QTOX_PREFIX_DIR
cp $OPENSSL_PREFIX_DIR/bin/ssleay32.dll \
$OPENSSL_PREFIX_DIR/bin/libeay32.dll \
$QTOX_PREFIX_DIR
cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/libgcc_s_*.dll $QTOX_PREFIX_DIR
cp /usr/lib/gcc/$ARCH-w64-mingw32/*-posix/libstdc++-6.dll $QTOX_PREFIX_DIR
cp /usr/$ARCH-w64-mingw32/lib/libwinpthread-1.dll $QTOX_PREFIX_DIR
cd ..
# Setup gdb
if [[ "$BUILD_TYPE" == "debug" ]]
then
# Copy over qTox source code so that dbg could pick it up
mkdir -p "$QTOX_PREFIX_DIR/$PWD/src"
cp -r "$PWD/src" "$QTOX_PREFIX_DIR/$PWD"
# Get dbg executable and the debug scripts
git clone https://github.com/nurupo/mingw-w64-debug-scripts
cd mingw-w64-debug-scripts
git checkout 7341e1ffdea352e5557f3fcae51569f13e1ef270
make $ARCH EXE_NAME=qtox.exe
mv output/$ARCH/* "$QTOX_PREFIX_DIR/"
cd ..
fi
# Strip
set +e
if [[ "$BUILD_TYPE" == "release" ]]
then
$ARCH-w64-mingw32-strip -s $QTOX_PREFIX_DIR/*.exe
fi
$ARCH-w64-mingw32-strip -s $QTOX_PREFIX_DIR/*.dll
$ARCH-w64-mingw32-strip -s $QTOX_PREFIX_DIR/*/*.dll
set -e
cd ..
rm -rf ./qtox
# Chmod since everything is root:root
chmod 777 -R "$WORKSPACE_DIR"

View File

@ -1,121 +0,0 @@
diff -rupN ffmpeg-2.7/libavutil/file.c ffmpeg-2.7-patched/libavutil/file.c
--- ffmpeg-2.7/libavutil/file.c 2015-06-10 02:27:53 +0300
+++ ffmpeg-2.7-patched/libavutil/file.c 2015-06-25 19:25:32 +0300
@@ -23,17 +23,17 @@
#include "mem.h"
#include <fcntl.h>
#include <sys/stat.h>
+#if HAVE_MMAP
+#include <sys/mman.h>
+#elif HAVE_MAPVIEWOFFILE
+#include <windows.h>
+#endif
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#if HAVE_IO_H
#include <io.h>
#endif
-#if HAVE_MMAP
-#include <sys/mman.h>
-#elif HAVE_MAPVIEWOFFILE
-#include <windows.h>
-#endif
typedef struct FileLogContext {
const AVClass *class;
diff -rupN ffmpeg-2.7/libavutil/file_open.c ffmpeg-2.7-patched/libavutil/file_open.c
--- ffmpeg-2.7/libavutil/file_open.c 2015-06-10 02:27:53 +0300
+++ ffmpeg-2.7-patched/libavutil/file_open.c 2015-06-25 19:26:52 +0300
@@ -22,12 +22,6 @@
#include <stdarg.h>
#include <fcntl.h>
#include <sys/stat.h>
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#if HAVE_IO_H
-#include <io.h>
-#endif
#if defined(_WIN32) && !defined(__MINGW32CE__)
#undef open
@@ -63,6 +57,13 @@ fallback:
#define open win32_open
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#if HAVE_IO_H
+#include <io.h>
+#endif
+
int avpriv_open(const char *filename, int flags, ...)
{
int fd;
diff -rupN ffmpeg-2.7/libavutil/log.c ffmpeg-2.7-patched/libavutil/log.c
--- ffmpeg-2.7/libavutil/log.c 2015-06-10 02:27:53 +0300
+++ ffmpeg-2.7-patched/libavutil/log.c 2015-06-25 19:28:20 +0300
@@ -26,9 +26,6 @@
#include "config.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#if HAVE_IO_H
#include <io.h>
#endif
@@ -120,6 +117,9 @@ static const uint32_t color[16 + AV_CLAS
};
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
static int use_color = -1;
static void check_color_terminal(void)
diff -rupN ffmpeg-2.7/libavutil/random_seed.c ffmpeg-2.7-patched/libavutil/random_seed.c
--- ffmpeg-2.7/libavutil/random_seed.c 2015-05-17 04:26:38 +0300
+++ ffmpeg-2.7-patched/libavutil/random_seed.c 2015-06-25 19:28:30 +0300
@@ -20,9 +20,6 @@
#include "config.h"
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#if HAVE_IO_H
#include <io.h>
#endif
@@ -30,6 +27,9 @@
#include <windows.h>
#include <wincrypt.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include <fcntl.h>
#include <math.h>
#include <time.h>
diff -rupN ffmpeg-2.7/libavutil/time.c ffmpeg-2.7-patched/libavutil/time.c
--- ffmpeg-2.7/libavutil/time.c 2015-06-10 02:27:53 +0300
+++ ffmpeg-2.7-patched/libavutil/time.c 2015-06-25 19:28:37 +0300
@@ -26,12 +26,12 @@
#if HAVE_GETTIMEOFDAY
#include <sys/time.h>
#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif
#if HAVE_WINDOWS_H
#include <windows.h>
#endif
+#if HAVE_UNISTD_H
+#include <unistd.h>
+#endif
#include "time.h"
#include "error.h"