]> git.proxmox.com Git - ceph.git/blame - ceph/do_cmake.sh
update ceph source to reef 18.1.2
[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
20effc67
TL
16PYBUILD="3"
17ARGS="-GNinja"
9f95a23c
TL
18if [ -r /etc/os-release ]; then
19 source /etc/os-release
20 case "$ID" in
21 fedora)
20effc67
TL
22 if [ "$VERSION_ID" -ge "35" ] ; then
23 PYBUILD="3.10"
adb31ebb 24 elif [ "$VERSION_ID" -ge "33" ] ; then
20effc67
TL
25 PYBUILD="3.9"
26 elif [ "$VERSION_ID" -ge "32" ] ; then
27 PYBUILD="3.8"
28 else
29 PYBUILD="3.7"
9f95a23c
TL
30 fi
31 ;;
32 rhel|centos)
33 MAJOR_VER=$(echo "$VERSION_ID" | sed -e 's/\..*$//')
20effc67
TL
34 if [ "$MAJOR_VER" -ge "9" ] ; then
35 PYBUILD="3.9"
36 elif [ "$MAJOR_VER" -ge "8" ] ; then
9f95a23c
TL
37 PYBUILD="3.6"
38 fi
39 ;;
40 opensuse*|suse|sles)
41 PYBUILD="3"
42 ARGS+=" -DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
43 ARGS+=" -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF"
44 ;;
1e59de90
TL
45 ubuntu)
46 MAJOR_VER=$(echo "$VERSION_ID" | sed -e 's/\..*$//')
47 if [ "$MAJOR_VER" -ge "22" ] ; then
48 PYBUILD="3.10"
49 fi
50 ;;
51
9f95a23c
TL
52 esac
53elif [ "$(uname)" == FreeBSD ] ; then
54 PYBUILD="3"
55 ARGS+=" -DWITH_RADOSGW_AMQP_ENDPOINT=OFF"
56 ARGS+=" -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF"
57else
58 echo Unknown release
59 exit 1
60fi
61
20effc67 62ARGS+=" -DWITH_PYTHON3=${PYBUILD}"
11fdf7f2
TL
63
64if type ccache > /dev/null 2>&1 ; then
31f18b77 65 echo "enabling ccache"
9f95a23c 66 ARGS+=" -DWITH_CCACHE=ON"
11fdf7f2 67fi
31f18b77 68
1e59de90
TL
69cxx_compiler="g++"
70c_compiler="gcc"
71# 20 is used for more future-proof
72for i in $(seq 20 -1 11); do
73 if type -t gcc-$i > /dev/null; then
74 cxx_compiler="g++-$i"
75 c_compiler="gcc-$i"
76 break
77 fi
78done
79ARGS+=" -DCMAKE_CXX_COMPILER=$cxx_compiler"
80ARGS+=" -DCMAKE_C_COMPILER=$c_compiler"
81
9f95a23c
TL
82mkdir $BUILD_DIR
83cd $BUILD_DIR
11fdf7f2
TL
84if type cmake3 > /dev/null 2>&1 ; then
85 CMAKE=cmake3
86else
87 CMAKE=cmake
88fi
9f95a23c
TL
89${CMAKE} $ARGS "$@" $CEPH_GIT_DIR || exit 1
90set +x
7c673cae
FG
91
92# minimal config to find plugins
93cat <<EOF > ceph.conf
9f95a23c 94[global]
7c673cae
FG
95plugin dir = lib
96erasure code dir = lib
97EOF
98
7c673cae 99echo done.
9f95a23c 100
f67539c2 101if [[ ! "$ARGS $@" =~ "-DCMAKE_BUILD_TYPE" ]]; then
9f95a23c 102 cat <<EOF
11fdf7f2
TL
103
104****
105WARNING: do_cmake.sh now creates debug builds by default. Performance
106may be severely affected. Please use -DCMAKE_BUILD_TYPE=RelWithDebInfo
107if a performance sensitive build is required.
108****
109EOF
9f95a23c
TL
110fi
111