]> git.proxmox.com Git - ceph.git/blame - ceph/do_cmake.sh
import Ceph Pacific 16.2.4
[ceph.git] / ceph / do_cmake.sh
CommitLineData
81eedcae 1#!/usr/bin/env bash
9f95a23c
TL
2set -ex
3
f67539c2
TL
4if [ -d .git ]; then
5 git submodule update --init --recursive
6fi
9f95a23c
TL
7
8: ${BUILD_DIR:=build}
9: ${CEPH_GIT_DIR:=..}
10
11if [ -e $BUILD_DIR ]; then
12 echo "'$BUILD_DIR' dir already exists; either rm -rf '$BUILD_DIR' and re-run, or set BUILD_DIR env var to a different directory name"
7c673cae
FG
13 exit 1
14fi
31f18b77 15
11fdf7f2 16PYBUILD="2"
9f95a23c
TL
17if [ -r /etc/os-release ]; then
18 source /etc/os-release
19 case "$ID" in
20 fedora)
21 PYBUILD="3.7"
adb31ebb 22 if [ "$VERSION_ID" -eq "32" ] ; then
9f95a23c 23 PYBUILD="3.8"
adb31ebb
TL
24 elif [ "$VERSION_ID" -ge "33" ] ; then
25 PYBUILD="3.9"
9f95a23c
TL
26 fi
27 ;;
28 rhel|centos)
29 MAJOR_VER=$(echo "$VERSION_ID" | sed -e 's/\..*$//')
30 if [ "$MAJOR_VER" -ge "8" ] ; then
31 PYBUILD="3.6"
32 fi
33 ;;
34 opensuse*|suse|sles)
35 PYBUILD="3"
36 ARGS+=" -DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
37 ARGS+=" -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF"
38 ;;
39 esac
40elif [ "$(uname)" == FreeBSD ] ; then
41 PYBUILD="3"
42 ARGS+=" -DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
43 ARGS+=" -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF"
44else
45 echo Unknown release
46 exit 1
47fi
48
49if [[ "$PYBUILD" =~ ^3(\..*)?$ ]] ; then
50 ARGS+=" -DWITH_PYTHON3=${PYBUILD}"
11fdf7f2
TL
51fi
52
53if type ccache > /dev/null 2>&1 ; then
31f18b77 54 echo "enabling ccache"
9f95a23c 55 ARGS+=" -DWITH_CCACHE=ON"
11fdf7f2 56fi
31f18b77 57
f67539c2
TL
58if [[ ! "$ARGS $@" =~ "-DBOOST_J" ]] ; then
59 ncpu=$(getconf _NPROCESSORS_ONLN 2>&1)
60 [ -n "$ncpu" -a "$ncpu" -gt 1 ] && ARGS+=" -DBOOST_J=$(expr $ncpu / 2)"
61fi
62
9f95a23c
TL
63mkdir $BUILD_DIR
64cd $BUILD_DIR
11fdf7f2
TL
65if type cmake3 > /dev/null 2>&1 ; then
66 CMAKE=cmake3
67else
68 CMAKE=cmake
69fi
9f95a23c
TL
70${CMAKE} $ARGS "$@" $CEPH_GIT_DIR || exit 1
71set +x
7c673cae
FG
72
73# minimal config to find plugins
74cat <<EOF > ceph.conf
9f95a23c 75[global]
7c673cae
FG
76plugin dir = lib
77erasure code dir = lib
78EOF
79
7c673cae 80echo done.
9f95a23c 81
f67539c2 82if [[ ! "$ARGS $@" =~ "-DCMAKE_BUILD_TYPE" ]]; then
9f95a23c 83 cat <<EOF
11fdf7f2
TL
84
85****
86WARNING: do_cmake.sh now creates debug builds by default. Performance
87may be severely affected. Please use -DCMAKE_BUILD_TYPE=RelWithDebInfo
88if a performance sensitive build is required.
89****
90EOF
9f95a23c
TL
91fi
92