]> git.proxmox.com Git - ceph.git/blame - ceph/mingw_conf.sh
update ceph source to reef 18.1.2
[ceph.git] / ceph / mingw_conf.sh
CommitLineData
f67539c2
TL
1# MINGW Settings:
2# Due to inconsistencies between distributions, mingw versions, binaries,
3# and directories must be determined (or defined) prior to building.
4
5# This script expects the following variables:
1e59de90
TL
6# * OS - currently ubuntu, rhel, or suse. In the future we may attempt to
7# detect the platform.
f67539c2
TL
8# * MINGW_CMAKE_FILE - if set, a cmake toolchain file will be created
9# * MINGW_POSIX_FLAGS - if set, Mingw Posix compatibility mode will be
10# enabled by defining the according flags.
11
12# -Common mingw settings-
13MINGW_PREFIX="x86_64-w64-mingw32-"
14MINGW_BASE="x86_64-w64-mingw32"
15MINGW_CPP="${MINGW_BASE}-c++"
16MINGW_DLLTOOL="${MINGW_BASE}-dlltool"
17MINGW_WINDRES="${MINGW_BASE}-windres"
18MINGW_STRIP="${MINGW_BASE}-strip"
19MINGW_OBJCOPY="${MINGW_BASE}-objcopy"
20# -Distribution specific mingw settings-
21case "$OS" in
22 ubuntu)
23 mingwPosix="-posix"
24 mingwLibDir="/usr/lib/gcc"
25 mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
26 mingwTargetLibDir="${mingwLibDir}/${MINGW_BASE}/${mingwVersion}"
27 mingwLibpthreadDir="/usr/${MINGW_BASE}/lib"
28 PTW32Include=/usr/share/mingw-w64/include
29 PTW32Lib=/usr/x86_64-w64-mingw32/lib
30 ;;
1e59de90
TL
31 rhel)
32 mingwPosix=""
33 mingwLibDir="/usr/lib64/gcc"
34 mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
35 mingwTargetLibDir="/usr/${MINGW_BASE}/sys-root/mingw/bin"
36 mingwLibpthreadDir="$mingwTargetLibDir"
37 PTW32Include=/usr/x86_64-w64-mingw32/sys-root/mingw/include
38 PTW32Lib=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
39 ;;
f67539c2
TL
40 suse)
41 mingwPosix=""
42 mingwLibDir="/usr/lib64/gcc"
43 mingwVersion="$(${MINGW_CPP}${mingwPosix} -dumpversion)"
44 mingwTargetLibDir="/usr/${MINGW_BASE}/sys-root/mingw/bin"
45 mingwLibpthreadDir="$mingwTargetLibDir"
46 PTW32Include=/usr/x86_64-w64-mingw32/sys-root/mingw/include
47 PTW32Lib=/usr/x86_64-w64-mingw32/sys-root/mingw/lib
48 ;;
49 *)
50 echo "$ID is unknown, automatic mingw configuration is not possible."
51 exit 1
52 ;;
53esac
54# -Common mingw settings, dependent upon distribution specific settings-
55MINGW_FIND_ROOT_LIB_PATH="${mingwLibDir}/\${TOOLCHAIN_PREFIX}/${mingwVersion}"
56MINGW_CC="${MINGW_BASE}-gcc${mingwPosix}"
57MINGW_CXX="${MINGW_BASE}-g++${mingwPosix}"
58# End MINGW configuration
59
60
61if [[ -n $MINGW_CMAKE_FILE ]]; then
62 cat > $MINGW_CMAKE_FILE <<EOL
63set(CMAKE_SYSTEM_NAME Windows)
64set(TOOLCHAIN_PREFIX ${MINGW_BASE})
65set(CMAKE_SYSTEM_PROCESSOR x86_64)
66
67# We'll need to use posix threads in order to use
68# C++11 features, such as std::thread.
69set(CMAKE_C_COMPILER \${TOOLCHAIN_PREFIX}-gcc${mingwPosix})
70set(CMAKE_CXX_COMPILER \${TOOLCHAIN_PREFIX}-g++${mingwPosix})
71set(CMAKE_RC_COMPILER \${TOOLCHAIN_PREFIX}-windres)
72
73set(CMAKE_FIND_ROOT_PATH /usr/\${TOOLCHAIN_PREFIX} ${MINGW_FIND_ROOT_LIB_PATH})
74set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
75# TODO: consider switching this to "ONLY". The issue with
76# that is that all our libs should then be under
77# CMAKE_FIND_ROOT_PATH and CMAKE_PREFIX_PATH would be ignored.
78set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
79set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
80EOL
81 if [[ -n $MINGW_POSIX_FLAGS ]]; then
82 cat >> $MINGW_CMAKE_FILE <<EOL
83# Some functions (e.g. localtime_r) will not be available unless we set
84# the following flag.
85add_definitions(-D_POSIX=1)
86add_definitions(-D_POSIX_C_SOURCE=1)
87add_definitions(-D_POSIX_=1)
88add_definitions(-D_POSIX_THREADS=1)
89EOL
90 fi
91fi