From ed8db48b40a3c68b9ed465b392982c473fe9c6aa Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 19:28:29 +0200 Subject: [PATCH 1/8] Set CMAKE_FIND_ROOT_PATH, use i686-w64-mingw32 The project now uses the MinGW headers instead of wine's headers. --- CMakeLists_mingw.txt | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 7fb25965c1..4e0880c2e8 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -1,20 +1,11 @@ SET(CMAKE_SYSTEM_NAME Windows) -if (APPLE) - SET(COMPILER_PREFIX i586-mingw32) - SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) - SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) - SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) - SET(CMAKE_PKGCONFIG_EXECUTABLE i686-w64-mingw32-pkg-config) - SET(PKG_CONFIG_EXECUTABLE i686-w64-mingw32-pkg-config) -else() - SET(COMPILER_PREFIX i686-w64-mingw32) - SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) - SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) - SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) - SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) - SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) -endif (APPLE) +SET(COMPILER_PREFIX i686-w64-mingw32) +SET(CMAKE_C_COMPILER ${COMPILER_PREFIX}-gcc) +SET(CMAKE_CXX_COMPILER ${COMPILER_PREFIX}-c++) +SET(CMAKE_RC_COMPILER ${COMPILER_PREFIX}-windres) +SET(CMAKE_PKGCONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) +SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) # potential flags to make code more similar to MSVC: # -fshort-wchar -fshort-enums -mms-bitfields @@ -22,15 +13,13 @@ endif (APPLE) set(CMAKE_C_FLAGS "-masm=intel -std=gnu99 -fpack-struct=2" CACHE STRING "" FORCE) set(CMAKE_SHARED_LINKER_FLAGS "-static-libgcc" CACHE STRING "" FORCE) -include_directories("/usr/include/wine/windows/") - # find and include SDL2 INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) # here is the target environment located -#SET(CMAKE_FIND_ROOT_PATH /usr/${COMPILER_PREFIX}) +SET(CMAKE_FIND_ROOT_PATH /Users/skip/Downloads/mingw-w32-bin_i686-darwin_20130531/i686-w64-mingw32) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search From fd1943d3cb5f6f3d2744d8074d4ee24d93f6810f Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 20:17:15 +0200 Subject: [PATCH 2/8] install.sh: Download mingw from sourceforge. It will automatically extract to /usr/local/ --- CMakeLists_mingw.txt | 2 +- install.sh | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 4e0880c2e8..1bca99bfeb 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -19,7 +19,7 @@ PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /Users/skip/Downloads/mingw-w32-bin_i686-darwin_20130531/i686-w64-mingw32) +SET(CMAKE_FIND_ROOT_PATH /usr/local/mingw-w32-bin_i686-darwin_20130531/i686-w64-mingw32) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search diff --git a/install.sh b/install.sh index 3439d41eef..1ac6a64fe0 100755 --- a/install.sh +++ b/install.sh @@ -49,18 +49,18 @@ if [[ `uname` == "Darwin" ]]; then sudo ln -s $wine_path /usr/include fi - mingw_dmg=gcc-4.8.0-qt-4.8.4-for-mingw32.dmg - mingw_path=/usr/local/gcc-4.8.0-qt-4.8.4-for-mingw32/win32-gcc/bin - if [[ ! -f $cachedir/$mingw_dmg ]]; then - wget http://crossgcc.rts-software.org/download/gcc-4.8.0-qt-4.8.4-win32/$mingw_dmg --output-document $cachedir/$mingw_dmg + mingw_name=mingw-w32-bin_i686-darwin_20130531 + mingw_tar=$mingw_name.tar.bz2 + mingw_install_dir=/usr/local/ + mingw_path=$mingw_install_dir$mingw_name/ + if [[ ! -f $cachedir/$mingw_tar ]]; then + wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar fi - - if [[ ! -d $mingw_path ]]; then - echo "Open the DMG file and install its contents" - open $cachedir/$mingw_dmg + if [[ ! -d $ming_path ]]; then + echo "Extracting contents of $mingw_tar to $mingw_install_dir" + echo "Don't forget to add $mingw_path to your $PATH variable!" + tar -xyf $cachedir/$mingw_tar -C $mingw_install_dir fi - - echo "You will need to add $mingw_path to your \$PATH" elif [[ `uname` == "Linux" ]]; then sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 fi From 22f090a688f1f1d7dbb818d86b6ef23c1195861e Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 20:31:52 +0200 Subject: [PATCH 3/8] Extract with root privileges --- install.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index 1ac6a64fe0..7f2c870352 100755 --- a/install.sh +++ b/install.sh @@ -58,8 +58,8 @@ if [[ `uname` == "Darwin" ]]; then fi if [[ ! -d $ming_path ]]; then echo "Extracting contents of $mingw_tar to $mingw_install_dir" - echo "Don't forget to add $mingw_path to your $PATH variable!" - tar -xyf $cachedir/$mingw_tar -C $mingw_install_dir + echo "Don't forget to add $mingw_path to your PATH variable!" + sudo tar -xyf $cachedir/$mingw_tar -C $mingw_install_dir fi elif [[ `uname` == "Linux" ]]; then sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 From dc9a3d361fd0bc3525715e5c8807a424b0ee9fea Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 20:37:05 +0200 Subject: [PATCH 4/8] Extract to subdirectory... --- install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install.sh b/install.sh index 7f2c870352..e5fb25bc3c 100755 --- a/install.sh +++ b/install.sh @@ -51,7 +51,7 @@ if [[ `uname` == "Darwin" ]]; then mingw_name=mingw-w32-bin_i686-darwin_20130531 mingw_tar=$mingw_name.tar.bz2 - mingw_install_dir=/usr/local/ + mingw_install_dir=/usr/local/mingw_w32-bin_i686-darwin mingw_path=$mingw_install_dir$mingw_name/ if [[ ! -f $cachedir/$mingw_tar ]]; then wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar From 0986ed6eb039a9c6bd75679a3dbad077b243ecc1 Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 21:05:25 +0200 Subject: [PATCH 5/8] mkdir if it isn't present --- install.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.sh b/install.sh index e5fb25bc3c..5a9071e566 100755 --- a/install.sh +++ b/install.sh @@ -51,15 +51,15 @@ if [[ `uname` == "Darwin" ]]; then mingw_name=mingw-w32-bin_i686-darwin_20130531 mingw_tar=$mingw_name.tar.bz2 - mingw_install_dir=/usr/local/mingw_w32-bin_i686-darwin - mingw_path=$mingw_install_dir$mingw_name/ + mingw_path=/usr/local/mingw_w32-bin_i686-darwin if [[ ! -f $cachedir/$mingw_tar ]]; then wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar fi if [[ ! -d $ming_path ]]; then - echo "Extracting contents of $mingw_tar to $mingw_install_dir" + mkdir -p $mingw_path + echo "Extracting contents of $mingw_tar to $mingw_path" echo "Don't forget to add $mingw_path to your PATH variable!" - sudo tar -xyf $cachedir/$mingw_tar -C $mingw_install_dir + sudo tar -xyfp $cachedir/$mingw_tar -C $mingw_path fi elif [[ `uname` == "Linux" ]]; then sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 From 0a37d51b4eac72f96ae1ab9df4eb70d33d2af9a8 Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 21:38:11 +0200 Subject: [PATCH 6/8] Set the correct permissions after extracting. --- CMakeLists_mingw.txt | 2 +- install.sh | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 1bca99bfeb..5808593b04 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -19,7 +19,7 @@ PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /usr/local/mingw-w32-bin_i686-darwin_20130531/i686-w64-mingw32) +SET(CMAKE_FIND_ROOT_PATH /usr/local/mingw-w32-bin_i686-darwin/i686-w64-mingw32) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search diff --git a/install.sh b/install.sh index 5a9071e566..73c1a9ea97 100755 --- a/install.sh +++ b/install.sh @@ -49,17 +49,27 @@ if [[ `uname` == "Darwin" ]]; then sudo ln -s $wine_path /usr/include fi - mingw_name=mingw-w32-bin_i686-darwin_20130531 - mingw_tar=$mingw_name.tar.bz2 - mingw_path=/usr/local/mingw_w32-bin_i686-darwin + mingw_name=mingw-w32-bin_i686-darwin + mingw_tar=$mingw_name"_20130531".tar.bz2 + mingw_path=/usr/local/$mingw_name if [[ ! -f $cachedir/$mingw_tar ]]; then wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar fi if [[ ! -d $ming_path ]]; then - mkdir -p $mingw_path + pushd /usr/local/ + sudo mkdir $mingw_name + popd + echo "Extracting contents of $mingw_tar to $mingw_path" echo "Don't forget to add $mingw_path to your PATH variable!" - sudo tar -xyfp $cachedir/$mingw_tar -C $mingw_path + sudo tar -xyf $cachedir/$mingw_tar -C $mingw_path + #sudo gnutar -xjf $cachedir/$mingw_tar -C $mingw_path --no-same-permissions + pushd /usr/local + sudo chmod 755 $mingw_name + pushd $mingw_name + sudo find . -type d -exec chmod 755 {} \; + popd + popd fi elif [[ `uname` == "Linux" ]]; then sudo apt-get install -y --force-yes binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686 From d5c19fa56eecd1e278db7c34b6f4f7e982661315 Mon Sep 17 00:00:00 2001 From: Balletie Date: Sat, 23 Aug 2014 21:42:02 +0200 Subject: [PATCH 7/8] Clean the code up (indentation) --- install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/install.sh b/install.sh index 73c1a9ea97..f4d69fb956 100755 --- a/install.sh +++ b/install.sh @@ -56,19 +56,20 @@ if [[ `uname` == "Darwin" ]]; then wget "https://downloads.sourceforge.net/project/mingw-w64/Toolchains targetting Win32/Automated Builds/$mingw_tar" --output-document $cachedir/$mingw_tar fi if [[ ! -d $ming_path ]]; then + pushd /usr/local/ - sudo mkdir $mingw_name + sudo mkdir $mingw_name popd echo "Extracting contents of $mingw_tar to $mingw_path" echo "Don't forget to add $mingw_path to your PATH variable!" sudo tar -xyf $cachedir/$mingw_tar -C $mingw_path - #sudo gnutar -xjf $cachedir/$mingw_tar -C $mingw_path --no-same-permissions + pushd /usr/local - sudo chmod 755 $mingw_name - pushd $mingw_name - sudo find . -type d -exec chmod 755 {} \; - popd + sudo chmod 755 $mingw_name + pushd $mingw_name + sudo find . -type d -exec chmod 755 {} \; + popd popd fi elif [[ `uname` == "Linux" ]]; then From 271290c308e7feccd05ce6d3f1bfa5f9db33a76f Mon Sep 17 00:00:00 2001 From: Balletie Date: Sun, 24 Aug 2014 16:40:57 +0200 Subject: [PATCH 8/8] Make toolchain compatible for both OSX and Linux --- CMakeLists_mingw.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 5808593b04..f3df7c65fe 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -18,8 +18,14 @@ INCLUDE(FindPkgConfig) PKG_SEARCH_MODULE(SDL2 REQUIRED sdl2) INCLUDE_DIRECTORIES(${SDL2_INCLUDE_DIRS}) +if(APPLE) + SET(TARGET_ENVIRONMENT /usr/local/mingw-w32-bin_i686-darwin/i686-w64-mingw32) +else() + SET(TARGET_ENVIRONMENT /usr/i686-w64-mingw32) +endif(APPLE) + # here is the target environment located -SET(CMAKE_FIND_ROOT_PATH /usr/local/mingw-w32-bin_i686-darwin/i686-w64-mingw32) +SET(CMAKE_FIND_ROOT_PATH ${TARGET_ENVIRONMENT}) # adjust the default behaviour of the FIND_XXX() commands: # search headers and libraries in the target environment, search