|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +Info() { |
| 6 | + echo -e '\033[1;34m'"WineBuild:\033[0m $*" |
| 7 | +} |
| 8 | + |
| 9 | +Error() { |
| 10 | + echo -e '\033[1;31m'"WineBuild:\033[0m $*" |
| 11 | + exit 1 |
| 12 | +} |
| 13 | + |
| 14 | +Info "Starting Wine build process..." |
| 15 | + |
| 16 | +WINE_VERSION="$(git describe --tags --abbrev=0 2>/dev/null | sed 's/^cachyos-//; s/-[^-]*$//' || echo unknown)" |
| 17 | +Info "Building Wine version: ${WINE_VERSION}" |
| 18 | +BUILD_DIR="/tmp/wine-build" |
| 19 | +mkdir -p "${BUILD_DIR}"/{build64,build32,wine-install} |
| 20 | + |
| 21 | +# initialize git for build tools |
| 22 | +git config --global --add safe.directory "${PWD}" |
| 23 | +git config commit.gpgsign false |
| 24 | +git config user.email "wine@build.dev" |
| 25 | +git config user.name "winebuild" |
| 26 | + |
| 27 | +Info "Generating build files..." |
| 28 | +[ -e dlls/winevulkan/make_vulkan ] && { |
| 29 | + chmod +x dlls/winevulkan/make_vulkan |
| 30 | + dlls/winevulkan/make_vulkan |
| 31 | +} |
| 32 | + |
| 33 | +chmod +x tools/make_requests |
| 34 | +tools/make_requests |
| 35 | + |
| 36 | +[ -e tools/make_specfiles ] && { |
| 37 | + chmod +x tools/make_specfiles |
| 38 | + tools/make_specfiles |
| 39 | +} |
| 40 | + |
| 41 | +autoreconf -fiv |
| 42 | + |
| 43 | +# setup reproducible build |
| 44 | +export SOURCE_DATE_EPOCH=0 |
| 45 | +export PKG_CONFIG="pkg-config" |
| 46 | + |
| 47 | +# gcc-mingw setup |
| 48 | +export GCC_MINGW_PATH="/usr/local/gcc-mingw" |
| 49 | +export PATH="${GCC_MINGW_PATH}/bin:${PATH}" |
| 50 | +export LIBRARY_PATH="/usr/lib/gcc-14/lib/gcc/x86_64-linux-gnu/14:/usr/lib/gcc-14/lib/gcc/x86_64-linux-gnu/14/32:/usr/lib/gcc-14/lib:/usr/lib/gcc-14/lib32:/usr/lib:/usr/lib/x86_64-linux-gnu:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu:/usr/local/i386/lib/i386-linux-gnu:/usr/local/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu" |
| 51 | +export LD_LIBRARY_PATH="/usr/lib/gcc-14/lib/gcc/x86_64-linux-gnu/14:/usr/lib/gcc-14/lib/gcc/x86_64-linux-gnu/14/32:/usr/lib/gcc-14/lib:/usr/lib/gcc-14/lib32:/usr/lib:/usr/lib/x86_64-linux-gnu:/usr/local/lib:/usr/local/lib/x86_64-linux-gnu:/usr/local/i386/lib/i386-linux-gnu:/usr/local/lib/i386-linux-gnu:/usr/lib/i386-linux-gnu" |
| 52 | + |
| 53 | +# compiler settings |
| 54 | +export CC="ccache gcc" |
| 55 | +export CXX="ccache g++" |
| 56 | +export CROSSCC_X32="ccache i686-w64-mingw32-gcc" |
| 57 | +export CROSSCXX_X32="ccache i686-w64-mingw32-g++" |
| 58 | +export CROSSCC_X64="ccache x86_64-w64-mingw32-gcc" |
| 59 | +export CROSSCXX_X64="ccache x86_64-w64-mingw32-g++" |
| 60 | +export x86_64_CC="${CROSSCC_X64}" |
| 61 | +export i386_CC="${CROSSCC_X32}" |
| 62 | + |
| 63 | +# compiler flags |
| 64 | +_GCC_FLAGS="-march=x86-64 -msse3 -mfpmath=sse -O2 -ftree-vectorize -static-libgcc -Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion" |
| 65 | +_LD_FLAGS="-Wl,-O1,--sort-common,--as-needed" |
| 66 | + |
| 67 | +export CFLAGS="${_GCC_FLAGS}" |
| 68 | +export CXXFLAGS="${_GCC_FLAGS}" |
| 69 | +export LDFLAGS="${_LD_FLAGS}" |
| 70 | +export CROSSCFLAGS="${_GCC_FLAGS}" |
| 71 | +export CROSSCXXFLAGS="${_GCC_FLAGS}" |
| 72 | +export CROSSLDFLAGS="${_LD_FLAGS}" |
| 73 | +export i386_CFLAGS="${CROSSCFLAGS}" |
| 74 | +export x86_64_CFLAGS="${CROSSCFLAGS}" |
| 75 | + |
| 76 | +# configure options |
| 77 | +WINE_CONFIGURE_OPTS=( |
| 78 | + --prefix="${BUILD_DIR}/wine-install" |
| 79 | + --disable-tests |
| 80 | + --disable-winemenubuilder |
| 81 | + --disable-win16 |
| 82 | + --with-x |
| 83 | + --with-gstreamer |
| 84 | + --with-ffmpeg |
| 85 | + --with-wayland |
| 86 | + --without-oss |
| 87 | + --without-coreaudio |
| 88 | + --without-cups |
| 89 | + --without-sane |
| 90 | + --without-gphoto |
| 91 | + --without-pcsclite |
| 92 | + --without-pcap |
| 93 | + --without-capi |
| 94 | + --without-v4l2 |
| 95 | + --without-netapi |
| 96 | + --disable-msv1_0 |
| 97 | +) |
| 98 | + |
| 99 | +## 64-bit |
| 100 | +Info "Configuring 64-bit build..." |
| 101 | +cd "${BUILD_DIR}/build64" |
| 102 | + |
| 103 | +export PKG_CONFIG_LIBDIR="/usr/local/x86_64/lib/x86_64-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/x86_64-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig" |
| 104 | +export PKG_CONFIG_PATH="${PKG_CONFIG_LIBDIR}" |
| 105 | +export CROSSCC="${CROSSCC_X64}" |
| 106 | + |
| 107 | +# libunwind support |
| 108 | +if [ -f "/usr/local/lib/libunwind.a" ] && [ -f "/usr/local/lib/liblzma.a" ]; then |
| 109 | + export UNWIND_CFLAGS="" |
| 110 | + export UNWIND_LIBS="-L/usr/local/lib/ -static-libgcc -l:libunwind.a -l:liblzma.a" |
| 111 | +fi |
| 112 | + |
| 113 | +"${GITHUB_WORKSPACE}/configure" \ |
| 114 | + "${WINE_CONFIGURE_OPTS[@]}" \ |
| 115 | + --libdir="${BUILD_DIR}/wine-install/lib" \ |
| 116 | + --enable-win64 \ |
| 117 | + --with-mingw="${x86_64_CC}" |
| 118 | + |
| 119 | +Info "Building 64-bit..." |
| 120 | +make -j$(($(nproc) + 1)) |
| 121 | + |
| 122 | +unset UNWIND_CFLAGS UNWIND_LIBS |
| 123 | + |
| 124 | +## build 32-bit |
| 125 | +Info "Configuring 32-bit build..." |
| 126 | +cd "${BUILD_DIR}/build32" |
| 127 | + |
| 128 | +export PKG_CONFIG_LIBDIR="/usr/local/i386/lib/i386-linux-gnu/pkgconfig:/usr/local/lib/pkgconfig:/usr/lib/i386-linux-gnu/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig" |
| 129 | +export PKG_CONFIG_PATH="${PKG_CONFIG_LIBDIR}" |
| 130 | +export CROSSCC="${CROSSCC_X32}" |
| 131 | + |
| 132 | +"${GITHUB_WORKSPACE}/configure" \ |
| 133 | + "${WINE_CONFIGURE_OPTS[@]}" \ |
| 134 | + --libdir="${BUILD_DIR}/wine-install/lib" \ |
| 135 | + --with-wine64="${BUILD_DIR}/build64" \ |
| 136 | + --with-mingw="${i386_CC}" |
| 137 | + |
| 138 | +Info "Building 32-bit..." |
| 139 | +make -j$(($(nproc) + 1)) |
| 140 | + |
| 141 | +Info "Installing Wine..." |
| 142 | + |
| 143 | +cd "${BUILD_DIR}/build32" |
| 144 | +make -j$(($(nproc) + 1)) \ |
| 145 | + prefix="${BUILD_DIR}/wine-install" \ |
| 146 | + libdir="${BUILD_DIR}/wine-install/lib" \ |
| 147 | + dlldir="${BUILD_DIR}/wine-install/lib/wine" \ |
| 148 | + install-lib |
| 149 | + |
| 150 | +cd "${BUILD_DIR}/build64" |
| 151 | +make -j$(($(nproc) + 1)) \ |
| 152 | + prefix="${BUILD_DIR}/wine-install" \ |
| 153 | + libdir="${BUILD_DIR}/wine-install/lib" \ |
| 154 | + dlldir="${BUILD_DIR}/wine-install/lib/wine" \ |
| 155 | + install-lib |
| 156 | + |
| 157 | +# symlinks |
| 158 | +cd "${BUILD_DIR}/wine-install" |
| 159 | +ln -srf lib lib64 |
| 160 | +ln -srf lib lib32 |
| 161 | + |
| 162 | +[ ! -f bin/wine64 ] && [ -f bin/wine ] && ln -srf bin/wine{,64} |
| 163 | + |
| 164 | +# strip binaries |
| 165 | +Info "Stripping debug symbols..." |
| 166 | +find "${BUILD_DIR}/wine-install/lib/" \ |
| 167 | + -type f '(' -iname '*.a' -o -iname '*.dll' -o -iname '*.so' -o -iname '*.sys' -o -iname '*.drv' -o -iname '*.exe' ')' \ |
| 168 | + -print0 | xargs -0 strip -s 2>/dev/null || true |
| 169 | + |
| 170 | +# cleanup |
| 171 | +rm -rf "${BUILD_DIR}/wine-install"/{include,share/{applications,man}} |
| 172 | + |
| 173 | +Info "Creating archive..." |
| 174 | +cd "${BUILD_DIR}" |
| 175 | + |
| 176 | +BUILD_NAME="wine-cachy-${WINE_VERSION}" |
| 177 | +mv wine-install "${BUILD_NAME}" |
| 178 | + |
| 179 | +ARCHIVE_NAME="${BUILD_NAME}-1-x86_64.tar.xz" |
| 180 | +tar -cJf \ |
| 181 | + "${ARCHIVE_NAME}" \ |
| 182 | + --xattrs --numeric-owner --owner=0 --group=0 "${BUILD_NAME}" |
| 183 | + |
| 184 | +# move to workspace |
| 185 | +mv "${ARCHIVE_NAME}" "${GITHUB_WORKSPACE}/" |
| 186 | +Info "Build completed successfully! Archive: ${ARCHIVE_NAME}" |
0 commit comments