summaryrefslogtreecommitdiffstats
path: root/win32_deps_build.sh
diff options
context:
space:
mode:
authorMike Latimer <mlatimer@suse.com>2020-03-27 03:43:22 +0100
committerLucian Petrut <lpetrut@cloudbasesolutions.com>2020-12-09 19:01:02 +0100
commitf42e947a85cf58a6c31fd707e0f9da9ab65d380e (patch)
tree66fa60debbc3f1dfd2ed7c48ea2255d01dd68def /win32_deps_build.sh
parentwin32*.sh: Use nproc for CPU count when targeting win32 (diff)
downloadceph-f42e947a85cf58a6c31fd707e0f9da9ab65d380e.tar.xz
ceph-f42e947a85cf58a6c31fd707e0f9da9ab65d380e.zip
cmake,win32*.sh: Add OS=(ubuntu|suse) flag, for distro settings
Distributions such as SUSE and Ubuntu differ significantly in their mingw environments. This adds an OS=(ubuntu|suse) flag, which can be used to specify which environment is being used for the build. Unless set explicitly, the scripts will try to automatically detect it. Depending on the OS selected, various mingw configuration options (binaries, library paths, etc.) as well as required packages are determined. Due to these options being configured at runtime, corresponding cmake files are generated on the fly. Signed-off-by: Mike Latimer <mlatimer@suse.com> Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com> Signed-off-by: Alessandro Pilotti <apilotti@cloudbasesolutions.com>
Diffstat (limited to 'win32_deps_build.sh')
-rwxr-xr-xwin32_deps_build.sh65
1 files changed, 34 insertions, 31 deletions
diff --git a/win32_deps_build.sh b/win32_deps_build.sh
index 81c02d2e5ef..5b53891ce54 100755
--- a/win32_deps_build.sh
+++ b/win32_deps_build.sh
@@ -42,6 +42,11 @@ wnbdTag="master"
wnbdSrcDir="${depsSrcDir}/wnbd"
wnbdLibDir="${depsToolsetDir}/wnbd/lib"
+# Allow for OS specific customizations through the OS flag (normally
+# passed through from win32_build).
+# Valid options are currently "ubuntu" and "suse".
+OS=${OS:-"ubuntu"}
+
function _make() {
make -j $NUM_WORKERS $@
}
@@ -50,26 +55,24 @@ mkdir -p $DEPS_DIR
mkdir -p $depsToolsetDir
mkdir -p $depsSrcDir
-MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake"
-cat > $MINGW_CMAKE_FILE <<EOL
-set(CMAKE_SYSTEM_NAME Windows)
-set(TOOLCHAIN_PREFIX x86_64-w64-mingw32)
-
-# We'll need to use posix threads in order to use
-# C++11 features, such as std::thread.
-set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc-posix)
-set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-g++-posix)
-set(CMAKE_RC_COMPILER \${TOOLCHAIN_PREFIX}-windres)
-
-set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX} /usr/lib/gcc/\${TOOLCHAIN_PREFIX}/7.3-posix)
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
-EOL
-
-sudo apt-get -y install mingw-w64 cmake pkg-config python3-dev python3-pip \
+case "$OS" in
+ ubuntu)
+ sudo apt-get update
+ sudo apt-get -y install mingw-w64 cmake pkg-config python3-dev python3-pip \
autoconf libtool ninja-build zip
-sudo python3 -m pip install cython
+ sudo python3 -m pip install cython
+ ;;
+ suse)
+ for PKG in mingw64-cross-gcc-c++ mingw64-libgcc_s_seh1 mingw64-libstdc++6 \
+ cmake pkgconf python3-devel autoconf libtool ninja zip \
+ python3-Cython gcc patch wget git; do
+ rpm -q $PKG >/dev/null || zypper -n install $PKG
+ done
+ ;;
+esac
+
+MINGW_CMAKE_FILE="$DEPS_DIR/mingw.cmake"
+source "$SCRIPT_DIR/mingw_conf.sh"
cd $depsSrcDir
if [[ ! -d $zlibSrcDir ]]; then
@@ -77,7 +80,7 @@ if [[ ! -d $zlibSrcDir ]]; then
fi
cd $zlibSrcDir
# Apparently the configure script is broken...
-sed -e s/"PREFIX = *$"/"PREFIX = x86_64-w64-mingw32-"/ -i win32/Makefile.gcc
+sed -e s/"PREFIX = *$"/"PREFIX = ${MINGW_PREFIX}"/ -i win32/Makefile.gcc
_make -f win32/Makefile.gcc
_make BINARY_PATH=$zlibDir \
INCLUDE_PATH=$zlibDir/include \
@@ -91,9 +94,9 @@ if [[ ! -d $lz4Dir ]]; then
cd $lz4Dir; git checkout $lz4Tag
fi
cd $lz4Dir
-_make BUILD_STATIC=no CC=x86_64-w64-mingw32-gcc \
- DLLTOOL=x86_64-w64-mingw32-dlltool \
- WINDRES=x86_64-w64-mingw32-windres \
+_make BUILD_STATIC=no CC=${MINGW_CC%-posix*} \
+ DLLTOOL=${MINGW_DLLTOOL} \
+ WINDRES=${MINGW_WINDRES} \
TARGET_OS=Windows_NT
cd $depsSrcDir
@@ -102,7 +105,7 @@ if [[ ! -d $sslSrcDir ]]; then
fi
cd $sslSrcDir
mkdir -p $sslDir
-CROSS_COMPILE="x86_64-w64-mingw32-" ./Configure \
+CROSS_COMPILE="${MINGW_PREFIX}" ./Configure \
mingw64 shared --prefix=$sslDir
_make depend
_make
@@ -116,7 +119,7 @@ fi
cd $curlSrcDir
./buildconf
./configure --prefix=$curlDir --with-ssl=$sslDir --with-zlib=$zlibDir \
- --host=x86_64-w64-mingw32
+ --host=${MINGW_BASE}
_make
_make install
@@ -127,7 +130,7 @@ if [[ ! -d $boostSrcDir ]]; then
fi
cd $boostSrcDir
-echo "using gcc : mingw32 : x86_64-w64-mingw32-g++-posix ;" > user-config.jam
+echo "using gcc : mingw32 : ${MINGW_CXX} ;" > user-config.jam
# Workaround for https://github.com/boostorg/thread/issues/156
# Older versions of mingw provided a different pthread lib.
@@ -138,8 +141,8 @@ sed -i 's/mthreads/pthreads/g' ./tools/build/src/tools/gcc.jam
sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.py
sed -i 's/pthreads/mthreads/g' ./tools/build/src/tools/gcc.jam
-export PTW32_INCLUDE=/usr/share/mingw-w64/include
-export PTW32_LIB=/usr/x86_64-w64-mingw32/lib
+export PTW32_INCLUDE=${PTW32Include}
+export PTW32_LIB=${PTW32Lib}
# Fix getting Windows page size
# TODO: send this upstream and maybe use a fork until it merges.
@@ -266,7 +269,7 @@ fi
mkdir -p $backtraceSrcDir/build
cd $backtraceSrcDir/build
../configure --prefix=$backtraceDir --exec-prefix=$backtraceDir \
- --host x86_64-w64-mingw32 --enable-host-shared
+ --host ${MINGW_BASE} --enable-host-shared
_make LDFLAGS="-no-undefined"
_make install
cp $backtraceDir/lib/libbacktrace.a $backtraceDir/lib/libbacktrace.dll.a
@@ -329,7 +332,7 @@ rexec@24rresvport@4
s_perror@8sethostname@8
EOF
-x86_64-w64-mingw32-dlltool -d $winLibDir/mswsock.def \
- -l $winLibDir/libmswsock.a
+$MINGW_DLLTOOL -d $winLibDir/mswsock.def \
+ -l $winLibDir/libmswsock.a
touch $depsToolsetDir/completed