Skip to content

Commit

Permalink
Initial changes for MSYS support
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Sep 21, 2015
1 parent 1755962 commit 5704db0
Show file tree
Hide file tree
Showing 13 changed files with 346 additions and 60 deletions.
12 changes: 9 additions & 3 deletions cmake/build_mingw32.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
#!/bin/sh

MINGW=/opt/mingw32
# Accomodate both linux windows mingw locations
MINGW=/mingw32
if [ -z "$MSYSCON" ]; then
MINGW=/opt$MINGW
else
CMAKE_OPTS="$CMAKE_OPTS -DLMMS_BUILD_MSYS=1"
fi

export PATH=$PATH:$MINGW/bin
#export CFLAGS="-march=pentium3 -mtune=generic -mpreferred-stack-boundary=5 -fno-tree-vectorize"
export CFLAGS="-march=pentium3 -mtune=generic -mpreferred-stack-boundary=5 -mfpmath=sse"
export CXXFLAGS="$CFLAGS"

if [ "$1" = "-qt5" ] ; then
CMAKE_OPTS="-DWANT_QT5=ON -DCMAKE_PREFIX_PATH=$MINGW"
CMAKE_OPTS="-DWANT_QT5=ON -DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"
fi

cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/modules/Win32Toolchain.cmake -DCMAKE_MODULE_PATH=`pwd`/../cmake/modules/ $CMAKE_OPTS
Expand Down
13 changes: 9 additions & 4 deletions cmake/build_mingw64.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
#!/bin/sh

MINGW=/opt/mingw64
# Accomodate both linux windows mingw locations
MINGW=/mingw64
if [ -z "$MSYSCON" ]; then
MINGW=/opt$MINGW
else
CMAKE_OPTS="$CMAKE_OPTS -DLMMS_BUILD_MSYS=1"
fi

export PATH=$PATH:$MINGW/bin
#export CFLAGS="-fno-tree-vectorize"
export CXXFLAGS="$CFLAGS"

if [ "$1" = "-qt5" ] ; then
CMAKE_OPTS="-DWANT_QT5=ON -DCMAKE_PREFIX_PATH=$MINGW"
CMAKE_OPTS="-DWANT_QT5=ON -DCMAKE_PREFIX_PATH=$MINGW $CMAKE_OPTS"
fi

cmake .. -DCMAKE_TOOLCHAIN_FILE=../cmake/modules/Win64Toolchain.cmake -DCMAKE_MODULE_PATH=`pwd`/../cmake/modules/ $CMAKE_OPTS
Expand Down
2 changes: 2 additions & 0 deletions cmake/modules/DetectMachine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ IF(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
SET(LMMS_BUILD_CLANG 1)
ENDIF()

# See build_mingwXX.sh for LMMS_BUILD_MSYS

MESSAGE("PROCESSOR: ${CMAKE_SYSTEM_PROCESSOR}")
SET(LMMS_HOST_X86 FALSE)
SET(LMMS_HOST_X86_64 FALSE)
Expand Down
127 changes: 92 additions & 35 deletions cmake/modules/MinGWCrossCompile.cmake
Original file line number Diff line number Diff line change
@@ -1,41 +1,98 @@
# this one is important
SET(CMAKE_SYSTEM_NAME Windows)
#this one not so much
SET(CMAKE_SYSTEM_VERSION 1)

# where is the target environment
SET(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
SET(CMAKE_INSTALL_PREFIX ${MINGW_PREFIX})

SET(MINGW_TOOL_PREFIX ${MINGW_PREFIX}/bin/${CMAKE_SYSTEM_PROCESSOR}-w64-mingw32-)

# specify the cross compiler
SET(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
SET(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++)
SET(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}gcc)

IF(WIN64)
# specify the cross compiler
SET(MINGW_TOOL_PREFIX32 ${MINGW_PREFIX32}/bin/${CMAKE_SYSTEM_PROCESSOR32}-w64-mingw32-)
SET(CMAKE_C_COMPILER32 ${MINGW_TOOL_PREFIX32}gcc)
SET(CMAKE_CXX_COMPILER32 ${MINGW_TOOL_PREFIX32}g++)
ENDIF()
# Required by cmake if `uname -s` is inadaquate
SET(CMAKE_SYSTEM_NAME Windows)
SET(CMAKE_SYSTEM_VERSION 1)

# The target environment
SET(CMAKE_FIND_ROOT_PATH ${MINGW_PREFIX})
SET(CMAKE_INSTALL_PREFIX ${MINGW_PREFIX})

# Windows msys mingw ships with a mostly-suitable preconfigured environment
IF(LMMS_BUILD_MSYS)
SET(STRIP ${MINGW_PREFIX}/bin/strip)
SET(WINDRES ${MINGW_PREFIX}/bin/windres)
SET(CMAKE_RC_COMPILER ${WINDRES})
SET(CMAKE_C_COMPILER ${MINGW_PREFIX}/bin/gcc)
SET(CMAKE_CXX_COMPILER ${MINGW_PREFIX}/bin/g++)

# specify location of some tools
SET(STRIP ${MINGW_TOOL_PREFIX}strip)
SET(WINDRES ${MINGW_TOOL_PREFIX}windres)
SET(PKG_CONFIG_EXECUTABLE ${MINGW_TOOL_PREFIX}pkg-config)
SET(PKG_CONFIG_FOUND TRUE)
# For 32-bit vst support
IF(WIN64)
# Specify the 32-bit cross compiler
SET(CMAKE_C_COMPILER32 ${MINGW_PREFIX32}/bin/gcc)
SET(CMAKE_CXX_COMPILER32 ${MINGW_PREFIX32}/bin/g++)
ENDIF()

# Msys compiler does not support @CMakeFiles/Include syntax
SET(CMAKE_C_USE_RESPONSE_FILE_FOR_INCLUDES OFF)
SET(CMAKE_CXX_USE_RESPONSE_FILE_FOR_INCLUDES OFF)

SET(QT_BINARY_DIR ${MINGW_PREFIX}/bin)
SET(QT_QMAKE_EXECUTABLE ${QT_BINARY_DIR}/qmake)
# FIXME: There should be a cleaner way to do this
# Allows "Debug" msys builds to link against Qt "Release" libraries
IF(LMMS_BUILD_MSYS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
SET(QT_LIBRARIES
optimized;${MINGW_PREFIX}/bin/QtGui4.dll;
optimized;${MINGW_PREFIX}/bin/QtCore4.dll;
optimized;${MINGW_PREFIX}/bin/QtXml4.dll;
debug;${MINGW_PREFIX}/bin/QtGui4.dll;
debug;${MINGW_PREFIX}/bin/QtCore4.dll;
debug;${MINGW_PREFIX}/bin/QtXml4.dll;
)
ENDIF()
# Linux mingw requires explicitly defined tools to prevent clash with native system tools
ELSE()
SET(MINGW_TOOL_PREFIX ${MINGW_PREFIX}/bin/${CMAKE_SYSTEM_PROCESSOR}-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)
# Specify the cross compiler
SET(CMAKE_C_COMPILER ${MINGW_TOOL_PREFIX}gcc)
SET(CMAKE_CXX_COMPILER ${MINGW_TOOL_PREFIX}g++)
SET(CMAKE_RC_COMPILER ${MINGW_TOOL_PREFIX}gcc)

# Mingw tools
SET(STRIP ${MINGW_TOOL_PREFIX}strip)
SET(WINDRES ${MINGW_TOOL_PREFIX}windres)
SET(PKG_CONFIG_EXECUTABLE ${MINGW_TOOL_PREFIX}pkg-config)
SET(PKG_CONFIG_FOUND TRUE)

# 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)

# For 32-bit vst support
IF(WIN64)
# Specify the 32-bit cross compiler
SET(MINGW_TOOL_PREFIX32 ${MINGW_PREFIX32}/bin/${CMAKE_SYSTEM_PROCESSOR32}-w64-mingw32-)
SET(CMAKE_C_COMPILER32 ${MINGW_TOOL_PREFIX32}gcc)
SET(CMAKE_CXX_COMPILER32 ${MINGW_TOOL_PREFIX32}g++)
ENDIF()

INCLUDE_DIRECTORIES(${MINGW_PREFIX}/include)
ENDIF()

INCLUDE_DIRECTORIES(${MINGW_PREFIX}/include)
LINK_DIRECTORIES(${MINGW_PREFIX}/lib ${MINGW_PREFIX}/bin)

# Qt tools
SET(QT_BINARY_DIR ${MINGW_PREFIX}/bin)
SET(QT_QMAKE_EXECUTABLE ${QT_BINARY_DIR}/qmake)

# Echo modified cmake vars to screen for debugging purposes
IF(NOT DEFINED ENV{MINGW_DEBUG_INFO})
MESSAGE("")
MESSAGE("Custom cmake vars: (blank = system default)")
MESSAGE("-----------------------------------------")
MESSAGE("* CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}")
MESSAGE("* CMAKE_CXX_COMPILER : ${CMAKE_CXX_COMPILER}")
MESSAGE("* CMAKE_RC_COMPILER : ${CMAKE_RC_COMPILER}")
MESSAGE("* WINDRES : ${WINDRES}")
MESSAGE("* PKG_CONFIG_EXECUTABLE : ${PKG_CONFIG_EXECUTABLE}")
MESSAGE("* MINGW_TOOL_PREFIX32 : ${MINGW_TOOL_PREFIX32}")
MESSAGE("* CMAKE_C_COMPILER32 : ${CMAKE_C_COMPILER32}")
MESSAGE("* CMAKE_CXX_COMPILER32 : ${CMAKE_CXX_COMPILER32}")
MESSAGE("* STRIP : ${STRIP}")
MESSAGE("* QT_BINARY_DIR : ${QT_BINARY_DIR}")
MESSAGE("* QT_QMAKE_EXECUTABLE : ${QT_QMAKE_EXECUTABLE}")
MESSAGE("")
# So that the debug info only appears once
SET(ENV{MINGW_DEBUG_INFO} SHOWN)
ENDIF()

8 changes: 6 additions & 2 deletions cmake/modules/Win32Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
SET(MINGW_PREFIX /opt/mingw32)
IF(LMMS_BUILD_MSYS)
SET(MINGW_PREFIX /mingw32)
ELSE()
SET(MINGW_PREFIX /opt/mingw32)
ENDIF()

SET(CMAKE_SYSTEM_PROCESSOR i686)
SET(CMAKE_SYSTEM_PROCESSOR i686)

INCLUDE(MinGWCrossCompile)

15 changes: 10 additions & 5 deletions cmake/modules/Win64Toolchain.cmake
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
SET(MINGW_PREFIX /opt/mingw64)
SET(MINGW_PREFIX32 /opt/mingw32)
IF(LMMS_BUILD_MSYS)
SET(MINGW_PREFIX /mingw64)
SET(MINGW_PREFIX32 /mingw32)
ELSE()
SET(MINGW_PREFIX /opt/mingw64)
SET(MINGW_PREFIX32 /opt/mingw32)
ENDIF()

SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_SYSTEM_PROCESSOR32 i686)
SET(CMAKE_SYSTEM_PROCESSOR x86_64)
SET(CMAKE_SYSTEM_PROCESSOR32 i686)

SET(WIN64 TRUE)
SET(WIN64 TRUE)


INCLUDE(MinGWCrossCompile)
Expand Down
17 changes: 17 additions & 0 deletions cmake/msys/extract_debs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
ppa_dir=./ppa/

pushd $ppa_dir

for f in *.deb; do
echo "Extracting $f..."
ar xv $f
rm debian-binary
rm control.tar.*
tar xf data.tar.*
rm data.tar.*
done

popd

echo "Your extracted files should be located in $ppa_dir"
48 changes: 48 additions & 0 deletions cmake/msys/fetch_ppa.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#!/bin/bash

# Trusty=14.04, Precise=12.04
PPA_DISTRO=trusty

# Architecture=i386, amd64
PPA_ARCH=amd64

# These shouldn't change
PPA_HOST=http://ppa.launchpad.net
PPA_USER=tobydox
PPA_PROJECT=mingw-x-trusty
PPA_ROOT=$PPA_HOST/$PPA_USER/$PPA_PROJECT/ubuntu

PPA_URL=$PPA_ROOT/dists/$PPA_DISTRO/main/binary-$PPA_ARCH/Packages

ppa_dir=./ppa/

temp_file=/tmp/ppa_listing_$$

echo "Connecting to $PPA_HOST to get list of packages..."
wget -qO- $PPA_URL |grep "Filename:" > $temp_file

line_count=`wc -l $temp_file |awk '{print $1}'`

echo "Found $line_count packages for download..."

echo "Downloading packages. They will be saved to $ppa_dir"

mkdir $ppa_dir

for j in `cat $temp_file` ; do
if [ "$j" = "Filename:" ] ; then
continue
fi
echo "Downloading $j..."
wget -O $ppa_dir$(basename $j) $PPA_ROOT/$j
done


echo "Cleaning up temporary files..."
rm -rf $temp_file

echo "Packages have been saved to $ppa_dir. Please run extract_debs.sh"




95 changes: 95 additions & 0 deletions cmake/msys/msys_helper.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#!/bin/bash

# Console colors
red="\\x1B[1;31m"
green="\\x1B[1;32m"
yellow="\\x1B[1;33m"
plain="\\x1B[0m"

function info() { echo -e "\n${green}$1${plain}"; }
function warn() { echo -e "\n${yellow}$1${plain}"; }
function err() { echo -e "\n${red}$1${plain}"; exit 1;}

info "Checking for mingw environment"
env |grep MINGW
if [ $? -ne 0 ]; then
err " - Failed. Please relaunch using MinGW shell"
fi

info "Preparing the git directory..."
mkdir $HOME/.git; touch $HOME/.git/config > /dev/null &2>1
git config --global http.sslverify false

info "Cloning the repository..."
if [ -d ./lmms ]; then
warn " - Skipping, ./lmms already exists"
else
#FIXME change "tresf" to "lmms"
git clone -b master https://github.com/tresf/lmms.git
fi


info "Fetching ppa using cmake/msys/fetch_ppas.sh..."
if [ -d $HOME/ppa ]; then
warn " - Skipping, $HOME/ppa already exists"
else
./lmms/cmake/msys/fetch_ppa.sh
fi


info "Extracting debs to $HOME/ppa/opt/, etc..."
if [ -d $HOME/ppa/opt ]; then
warn " - Skipping, $HOME/ppa/opt already exists"
else
./lmms/cmake/msys/extract_debs.sh
fi

info "Preparing library merge, making all qt headers writable..."
chmod u+w /mingw64/include/qt4 -R
chmod u+w /mingw32/include/qt4 -R

info "Merging mingw headers and libraries from ppa over existing system libraries..."
find /mingw64 |grep sndfile.h

if [ $? -ne 0 ]; then
\cp -r $HOME/ppa/opt/mingw* /
else
warn " - Skipping, sndfile.h has already been merged"
fi

fltkver="1.3.3"

info "Downloading and building fltk $fltkver"

mingw_root="/$(echo $MSYSTEM|tr '[:upper:]' '[:lower:]')"
which fluid
if [ $? -ne 0 ]; then
wget http://fltk.org/pub/fltk/$fltkver/fltk-$fltkver-source.tar.gz -O $HOME/fltk-source.tar.gz
if [ $? -ne 0 ]; then
err "ERROR: Could not download fltk. Exiting."
fi
tar zxf $HOME/fltk-source.tar.gz -C $HOME/
pushd $HOME/fltk-$fltkver

info " - Compiling fltk $fltkver..."
./configure

make

info " - Installing fltk..."
make install DESTDIR=$mingw_root

if [ $? -ne 0 ]; then
err "ERROR: Could not build/install fltk -- Zyn needs this. Exiting."
fi

ln -s $mingw_root/usr/local/bin/fluid.exe $mingw_root/bin/fluid.exe
else
warn " - Skipping, fluid binary already exists"
fi

popd

info "Cleaning up..."
rm -rf $HOME/fltk-$fltkver
info "Done."
Loading

0 comments on commit 5704db0

Please sign in to comment.