As of Sunday 11-Oct-2020, Wine 5.19 was released on Friday 09-Oct-2020. For the 2 past years I was used to download/use wine builds provided by Kron4ek (https://github.com/Kron4ek/Wine-Builds). Kron4ek took decision to support wine-tkg a couple months ago. Being a bit curious, it was the occasion for me to have a look and to see if I will be able to build wine myself based on Kron4ek's work. First of all, I am pretty happy to see that he spends time on sharing wine builds for distro like Ubuntu. I am on Xubuntu and his builds help me a lot, so I can play games on Linux. Thanks for his time and this work.

Steps are listed below
  1. Using scripts from wine-tkg we will generate some customized wine sources with all patches we want to cover our needs. wine-tkg is supposed to build wine BUT we will stop the process. It will be done automatically, due to a variable provided in our configuration file.
  2. We will set up the environment to build wine. This environment is based on two chroots (32-Bit and 64-Bit). I will use a script provided in Kron4ek's github repository.
  3. We will build wine. Kron4ek provided a script to build wine but I will not use it. I will use my own commands. My commands are based on his commands.

1. Prerequisites: Download wine-tkg sources and prepare the configuration file

  • Download sources
    cd
    _timestamp=$(date '+%Y-%m-%d_%H%M%S')
    _commit=593a3bc699278dbcf4d221c1ee3c59ea3ba866fa
    
    git clone https://github.com/Frogging-Family/wine-tkg-git.git wine-tkg-git_5.19_${_timestamp}
    cd wine-tkg-git_5.19_${_timestamp}
    git checkout ${_commit}
    
  • Copy the sample for external config outside the folder and rename it for 5.19
    cp wine-tkg-git/wine-tkg-profiles/sample-external-config.cfg ${HOME}/wine-tkg-external-config-5.19.cfg
    
    Edit the file and modify it to cover your own needs. Take your time because it may broke the whole system. For my own personal needs here is its output without comments
    david@david-Alienware-17-R4:~$ grep -vE '^(#|$)' ${HOME}/wine-tkg-external-config-5.19.cfg
    _nomakepkg_prefix_path="/home/david"
    _nomakepkg_nover="false"
    _nomakepkg_midbuild_prompt="false"
    _nomakepkg_dep_resolution_distro="debuntu"
    _LOCAL_PRESET=""
    _PKGNAME_OVERRIDE=""
    CUSTOM_MINGW_PATH=""
    CUSTOM_GCC_PATH=""
    _LOCAL_OPTIMIZED="true"
    _GCC_FLAGS="-pipe -O2 -ftree-vectorize"
    _LD_FLAGS="-Wl,-O1,--sort-common,--as-needed"
    _CROSS_FLAGS="-pipe -O2 -ftree-vectorize"
    _CROSS_LD_FLAGS="-Wl,-O1,--sort-common,--as-needed"
    _ENABLE_TESTS="false"
    _pkg_strip="true"
    _NUKR="true"
    _generate_patchsets="false"
    _NOLIB32="false"
    _NOLIB64="false"
    _NOMINGW="false"
    _NOCOMPILE="true"
    _NOINITIALPROMPT="false"
    _user_makedeps=""
    _faudio_ignorecheck="false"
    _nopatchmsg="true"
    _EXTERNAL_INSTALL="false"
    _DEFAULT_EXTERNAL_PATH="/opt"
    _EXTERNAL_NOVER="false"
    _GENERATE_DEBIAN_PACKAGE="false"
    _custom_wine_source=""
    _localbuild=""
    _plain_version="wine-5.19"
    _plain_mirrorsrc="true"
    _configure_userargs64="--with-x --with-gstreamer --with-xattr"
    _configure_userargs32="--with-x --with-gstreamer --with-xattr"
    _use_esync="true"
    _esync_version=""
    _use_fsync="true"
    _fsync_spincounts="true"
    _use_staging="true"
    _staging_version="v5.19"
    _use_vkd3dlib="false"
    _dxvk_dxgi="true"
    _use_legacy_gallium_nine="false"
    _sims3_fix="false"
    _mtga_fix="true"
    _mwo_fix="true"
    _re4_fix="true"
    _childwindow_fix="true"
    _lol920_fix="true"
    _assettocorsa_hudperf_fix="true"
    _mk11_fix="true"
    _staging_pulse_disable="false"
    _ffxivlauncher_fix="true"
    _kof98_2002_BGM_fix="true"
    _CSMT_toggle="true"
    _GLSL_toggle="true"
    _MIME_NOPE="true"
    _FOAS_NOPE="true"
    _lowlatency_audio="false"
    _launch_with_dedicated_gpu="true"
    _plasma_systray_fix="true"
    _stg_shared_mem_default="true"
    _nvidia_hate="true"
    _use_josh_flat_theme="true"
    _clock_monotonic="true"
    _FS_bypass_compositor="true"
    _proton_fs_hack="true"
    _proton_mf_hacks="true"
    _proton_rawinput="true"
    _msvcrt_nativebuiltin="true"
    _large_address_aware="true"
    _win10_default="true"
    _protonify="true"
    _use_pba="true"
    _sims2_fix="false"
    _server_send_hwmsg_disable="true"
    _poe_fix="false"
    _warframelauncher_fix="true"
    _OW_fix="true"
    _318python_fix="true"
    _f4skyrimse_fix="true"
    _steam_fix="true"
    _highcorecount_fix="true"
    _c6b6935_revert="true"
    _nativedotnet_fix="true"
    _usvfs_fix="true"
    _use_faudio="true"
    _kernelbase_reverts="false"
    _update_winevulkan="true"
    _fake_refresh_rate=""
    _community_patches="amdags.mypatch GNUTLShack.mypatch winex11-fs-no_above_state.mypatch winex11_limit_resources-nmode.mypatch FinalFantasyXVHack.mypatch origin_downloads_e4ca5dbe_revert.mypatch kernel32-implement-Windows-NT-style-GMEM_MOVEABLE-LM-staging.mypatch MWSE_hack.mypatch blackops2_unhandled_exception_fix.mypatch NFSWLauncherfix.mypatch  0001-powershell-add-wrapper-for-powershell-using-Powershe.patch shell32-Move-file-SHFileOperation-allow-from-wildchar-move.mypatchstaging.mypatch"
    _user_patches="true"
    _user_patches_no_confirm="false"
    _hotfixes_no_confirm="true"
    
  • Modify this file to point to the external config file
    vim ${HOME}/wine-tkg-git/wine-tkg-profiles/advanced-customization.cfg
    You should modify variable below
    # External config file to use - If the given file exists in path, it will override default config (customization.cfg) - Default is ~/.config/frogminer/wine-tkg.cfg
    #_EXT_CONFIG_PATH=~/.config/frogminer/wine-tkg.cfg
    _EXT_CONFIG_PATH=~/wine-tkg-external-config-5.19.cfg
    

2. Generate customized Wine sources

cd ${HOME}/cd wine-tkg-git_5.19_${_timestamp}/wine-tkg-git
./non-makepkg-build.sh
NOTICE: Once this has been completed -- script executed successfully -- then wine sources will be in located in subfolder ${HOME}/wine-tkg-git_5.19_${_timestamp}/wine-tkg-git/src/wine-mirror-git

3. Prepare the chroot environments for both 32-Bit and 64-Bit

I strongly recommend to have a look on work done at https://github.com/Kron4ek/Wine-Builds. It offers sone builds ready to be used
  • Create some folders
    mkdir -pv /opt/Sources/chroots /opt/montage
    • /opt/Sources/chroots: where both 64-Bit and 32-Bit chroots will be located
    • /opt/montage: this path will be mounted for both chroots
  • Download sources
    cd /opt/Sources # Create folders if not exits 
    git clone https://github.com/Kron4ek/Wine-Builds.git
    cd Wine-Builds/
  • Modify the script create_ubuntu_chroots.sh to cover your own needs. For mine, I've just modified this line below
    export MAINDIR="/opt/Sources/chroots"
    
  • Then execute the script
    create_ubuntu_chroots.sh

4. Build wine

Outside of chroots - Move the sources to /opt/montage and prepare folders

sudo cp -r ${HOME}/wine-tkg-git_5.19_${_timestamp}/wine-tkg-git/src/wine-mirror-git /opt/montage
sudo mv  /opt/montage/wine-mirror-git /opt/montage/wine-sources
sudo mkdir -pv /opt/montage/{wine64-build,wine32-build,wine-tools}


cat << _EOF_ > /opt/montage/flags_64.cfg
export CC="gcc-8"
export CXX="g++-8"
#export CFLAGS="$(gcc -march=native -O2 -v -E - < /dev/null 2>&1 |grep cc1 | perl -pe 's/^.* - //g;'| perl -pe 's/ -mno-\S+//g;')"
#CFLAGS+=" -O2 -pipe -ftree-vectorize"
export CFLAGS="-march=x86-64 -msse3 -mfpmath=sse -O2 -ftree-vectorize"
export CXXFLAGS="\${CFLAGS}"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed"
export CROSSCFLAGS="\${CFLAGS}"
export CROSSLDFLAGS="-Wl,-O1,--sort-common,--as-needed"
_EOF_

cat << _EOF_ > /opt/montage/flags_32.cfg
export CC="gcc-8"
export CXX="g++-8"
#export CFLAGS="$(gcc -march=native -O2 -v -E - < /dev/null 2>&1 |grep cc1 | perl -pe 's/^.* - //g;'| perl -pe 's/ -mno-\S+//g;')"
#CFLAGS+=" -O2 -pipe -ftree-vectorize"
export CFLAGS="-march=i686 -msse2 -mfpmath=sse -O2 -ftree-vectorize"
export CXXFLAGS="\${CFLAGS}"
export LDFLAGS="-Wl,-O1,--sort-common,--as-needed"
export CROSSCFLAGS="\${CFLAGS}"
export CROSSLDFLAGS="-Wl,-O1,--sort-common,--as-needed"
_EOF_

Outside of chroots - Prepare to enter the 64-Bit chroot

export CHROOT_PATH=/opt/Sources/chroots/bionic64_chroot/

echo "Mounting directories for chroots"
mount --bind "${CHROOT_PATH}" "${CHROOT_PATH}"
mount --bind /dev "${CHROOT_PATH}"/dev
mount --bind /dev/shm "${CHROOT_PATH}"/dev/shm
mount --bind /dev/pts "${CHROOT_PATH}"/dev/pts
mount --bind /proc "${CHROOT_PATH}"/proc
mount --bind /sys "${CHROOT_PATH}"/sys
mount --bind /opt/montage "${CHROOT_PATH}"/opt/montage


chroot "${CHROOT_PATH}" /usr/bin/env LANG=en_US.UTF-8 TERM=xterm PATH="/bin:/sbin:/usr/bin:/usr/sbin" /bin/bash

Inside the 64-Bit chroot - Build wine and install

source  /opt/montage/flags_64.cfg

# Build wine64-build and install
cd /opt/montage/wine64-build
../wine-sources/configure --prefix=/opt/wine-5.19-staging-tkg-customized-amd64/ --without-curses --without-oss --without-mingw --disable-winemenubuilder --disable-win16 --disable-tests --enable-win64
make -j$(nproc) && make install

Outside of chroots - Prepare to enter the 32-Bit chroot

export CHROOT_PATH=/opt/Sources/chroots/bionic32_chroot/

echo "Mounting directories for chroots"
mount --bind "${CHROOT_PATH}" "${CHROOT_PATH}"
mount --bind /dev "${CHROOT_PATH}"/dev
mount --bind /dev/shm "${CHROOT_PATH}"/dev/shm
mount --bind /dev/pts "${CHROOT_PATH}"/dev/pts
mount --bind /proc "${CHROOT_PATH}"/proc
mount --bind /sys "${CHROOT_PATH}"/sys
mount --bind /opt/montage "${CHROOT_PATH}"/opt/montage

chroot "${CHROOT_PATH}" /usr/bin/env LANG=en_US.UTF-8 TERM=xterm PATH="/bin:/sbin:/usr/bin:/usr/sbin" /bin/bash

Inside the 32-Bit chroot - Build wine and install

source  /opt/montage/flags_32.cfg

# Build wine-tools BUT DON'T INSTALL!!!
cd /opt/montage/wine-tools
../wine-sources/configure --prefix=/opt/wine-5.19-staging-tkg-customized-amd64/ --without-curses --without-oss --without-mingw --disable-winemenubuilder --disable-win16 --disable-tests
make -j$(nproc)

# Build wine32-build and install
cd /opt/montage/wine32-build
../wine-sources/configure --prefix=/opt/wine-5.19-staging-tkg-customized-amd64/ --without-curses --without-oss --without-mingw --disable-winemenubuilder --disable-win16 --disable-tests --with-wine64=/opt/montage/wine64-build --with-wine-tools=/opt/montage/wine-tools/
make -j$(nproc) && make install

Outside of chroots - Copy binaries and strip

mkdir -pv /opt/wine-5.19-staging-tkg-customized-amd64/

cp -avf /opt/Sources/chroots/bionic32_chroot/opt/wine-5.19-staging-tkg-customized-amd64/* /opt/wine-5.19-staging-tkg-customized-amd64/

cp -avf /opt/Sources/chroots/bionic64_chroot/opt/wine-5.19-staging-tkg-customized-amd64/* /opt/wine-5.19-staging-tkg-customized-amd64/

find /opt/wine-5.19-staging-tkg-customized-amd64/ -type f -exec strip --strip-unneeded {} \; 2>/dev/null