build_win32.sh 936 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. #!/usr/bin/env bash
  2. DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
  3. # Accomodate both linux windows mingw locations
  4. if [ -z "$ARCH" ]; then
  5. ARCH=32
  6. fi
  7. MINGW=/mingw$ARCH
  8. if [ -z "$MSYSCON" ]; then
  9. MINGW=/opt$MINGW
  10. DISTRO=$(lsb_release -si)
  11. DISTRO_VERSION=$(lsb_release -sr)
  12. if [ "$DISTRO" != "Ubuntu" ]; then
  13. echo "This script only supports Ubuntu"
  14. exit 1
  15. fi
  16. if [ "$DISTRO_VERSION" == "14.04" ]; then
  17. TOOLCHAIN="$DIR/toolchains/Ubuntu-MinGW-X-Trusty-$ARCH.cmake"
  18. else
  19. TOOLCHAIN="$DIR/toolchains/Ubuntu-MinGW-W64-$ARCH.cmake"
  20. fi
  21. else
  22. TOOLCHAIN="$DIR/toolchains/MSYS-$ARCH.cmake"
  23. fi
  24. export PATH=$MINGW/bin:$PATH
  25. export CXXFLAGS="$CFLAGS"
  26. if [ "$ARCH" == "32" ]; then
  27. export CFLAGS="-march=pentium3 -mtune=generic -mpreferred-stack-boundary=5 -mfpmath=sse"
  28. fi
  29. CMAKE_OPTS="-DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"
  30. # shellcheck disable=SC2086
  31. cmake "$DIR/.." -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN" $CMAKE_OPTS