]>
Commit | Line | Data |
---|---|---|
81eedcae | 1 | #!/usr/bin/env bash |
9f95a23c TL |
2 | set -ex |
3 | ||
f67539c2 TL |
4 | if [ -d .git ]; then |
5 | git submodule update --init --recursive | |
6 | fi | |
9f95a23c TL |
7 | |
8 | : ${BUILD_DIR:=build} | |
9 | : ${CEPH_GIT_DIR:=..} | |
10 | ||
11 | if [ -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 |
14 | fi | |
31f18b77 | 15 | |
11fdf7f2 | 16 | PYBUILD="2" |
9f95a23c TL |
17 | if [ -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 | |
40 | elif [ "$(uname)" == FreeBSD ] ; then | |
41 | PYBUILD="3" | |
42 | ARGS+=" -DWITH_RADOSGW_AMQP_ENDPOINT=OFF" | |
43 | ARGS+=" -DWITH_RADOSGW_KAFKA_ENDPOINT=OFF" | |
44 | else | |
45 | echo Unknown release | |
46 | exit 1 | |
47 | fi | |
48 | ||
49 | if [[ "$PYBUILD" =~ ^3(\..*)?$ ]] ; then | |
50 | ARGS+=" -DWITH_PYTHON3=${PYBUILD}" | |
11fdf7f2 TL |
51 | fi |
52 | ||
53 | if type ccache > /dev/null 2>&1 ; then | |
31f18b77 | 54 | echo "enabling ccache" |
9f95a23c | 55 | ARGS+=" -DWITH_CCACHE=ON" |
11fdf7f2 | 56 | fi |
31f18b77 | 57 | |
f67539c2 TL |
58 | if [[ ! "$ARGS $@" =~ "-DBOOST_J" ]] ; then |
59 | ncpu=$(getconf _NPROCESSORS_ONLN 2>&1) | |
60 | [ -n "$ncpu" -a "$ncpu" -gt 1 ] && ARGS+=" -DBOOST_J=$(expr $ncpu / 2)" | |
61 | fi | |
62 | ||
9f95a23c TL |
63 | mkdir $BUILD_DIR |
64 | cd $BUILD_DIR | |
11fdf7f2 TL |
65 | if type cmake3 > /dev/null 2>&1 ; then |
66 | CMAKE=cmake3 | |
67 | else | |
68 | CMAKE=cmake | |
69 | fi | |
9f95a23c TL |
70 | ${CMAKE} $ARGS "$@" $CEPH_GIT_DIR || exit 1 |
71 | set +x | |
7c673cae FG |
72 | |
73 | # minimal config to find plugins | |
74 | cat <<EOF > ceph.conf | |
9f95a23c | 75 | [global] |
7c673cae FG |
76 | plugin dir = lib |
77 | erasure code dir = lib | |
78 | EOF | |
79 | ||
7c673cae | 80 | echo done. |
9f95a23c | 81 | |
f67539c2 | 82 | if [[ ! "$ARGS $@" =~ "-DCMAKE_BUILD_TYPE" ]]; then |
9f95a23c | 83 | cat <<EOF |
11fdf7f2 TL |
84 | |
85 | **** | |
86 | WARNING: do_cmake.sh now creates debug builds by default. Performance | |
87 | may be severely affected. Please use -DCMAKE_BUILD_TYPE=RelWithDebInfo | |
88 | if a performance sensitive build is required. | |
89 | **** | |
90 | EOF | |
9f95a23c TL |
91 | fi |
92 |