Skip to content

Commit 469f94e

Browse files
authored
Merge pull request #10369 from Icinga/cflags
GHA: Linux: use the C(++) flags recommended by each respective distro
2 parents 63926c6 + f418d29 commit 469f94e

File tree

1 file changed

+24
-11
lines changed

1 file changed

+24
-11
lines changed

.github/workflows/linux.bash

+24-11
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ set -exo pipefail
44
export PATH="/usr/lib/ccache:/usr/lib64/ccache:$PATH"
55
export CCACHE_DIR=/icinga2/ccache
66
export CTEST_OUTPUT_ON_FAILURE=1
7-
CMAKE_OPTS=''
7+
CMAKE_OPTS=()
88

99
case "$DISTRO" in
1010
amazonlinux:2)
1111
amazon-linux-extras install -y epel
12-
yum install -y bison ccache cmake3 gcc-c++ flex ninja-build \
12+
yum install -y bison ccache cmake3 gcc-c++ flex ninja-build system-rpm-config \
1313
{libedit,mariadb,ncurses,openssl,postgresql,systemd}-devel
1414

1515
yum install -y bzip2 tar wget
@@ -24,28 +24,30 @@ case "$DISTRO" in
2424

2525
ln -vs /usr/bin/cmake3 /usr/local/bin/cmake
2626
ln -vs /usr/bin/ninja-build /usr/local/bin/ninja
27-
CMAKE_OPTS='-DBOOST_INCLUDEDIR=/boost_1_69_0 -DBOOST_LIBRARYDIR=/boost_1_69_0/stage/lib'
27+
CMAKE_OPTS+=(-DBOOST_{INCLUDEDIR=/boost_1_69_0,LIBRARYDIR=/boost_1_69_0/stage/lib})
2828
export LD_LIBRARY_PATH=/boost_1_69_0/stage/lib
2929
;;
3030

3131
amazonlinux:20*)
32-
dnf install -y bison cmake flex gcc-c++ ninja-build \
32+
dnf install -y amazon-rpm-config bison cmake flex gcc-c++ ninja-build \
3333
{boost,libedit,mariadb1\*,ncurses,openssl,postgresql,systemd}-devel
3434
;;
3535

3636
debian:*|ubuntu:*)
3737
apt-get update
38-
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-{recommends,suggests} -y bison \
39-
ccache cmake flex g++ lib{boost-all,edit,mariadb,ncurses,pq,ssl,systemd}-dev ninja-build tzdata
38+
DEBIAN_FRONTEND=noninteractive apt-get install --no-install-{recommends,suggests} -y \
39+
bison ccache cmake dpkg-dev flex g++ ninja-build tzdata \
40+
lib{boost-all,edit,mariadb,ncurses,pq,ssl,systemd}-dev
4041
;;
4142

4243
fedora:*)
43-
dnf install -y bison ccache cmake flex gcc-c++ ninja-build \
44+
dnf install -y bison ccache cmake flex gcc-c++ ninja-build redhat-rpm-config \
4445
{boost,libedit,mariadb,ncurses,openssl,postgresql,systemd}-devel
4546
;;
4647

4748
*suse*)
48-
zypper in -y bison ccache cmake flex gcc-c++ ninja {lib{edit,mariadb,openssl},ncurses,postgresql,systemd}-devel \
49+
zypper in -y bison ccache cmake flex gcc-c++ ninja rpm-config-SUSE \
50+
{lib{edit,mariadb,openssl},ncurses,postgresql,systemd}-devel \
4951
libboost_{context,coroutine,filesystem,iostreams,program_options,regex,system,test,thread}-devel
5052
;;
5153

@@ -61,22 +63,33 @@ case "$DISTRO" in
6163
;;
6264
esac
6365

64-
dnf install -y bison ccache cmake gcc-c++ flex ninja-build \
66+
dnf install -y bison ccache cmake gcc-c++ flex ninja-build redhat-rpm-config \
6567
{boost,libedit,mariadb,ncurses,openssl,postgresql,systemd}-devel
6668
;;
6769
esac
6870

71+
case "$DISTRO" in
72+
debian:*|ubuntu:*)
73+
CMAKE_OPTS+=(-DICINGA2_LTO_BUILD=ON)
74+
source <(dpkg-buildflags --export=sh)
75+
;;
76+
*)
77+
CMAKE_OPTS+=(-DCMAKE_{C,CXX}_FLAGS="$(rpm -E '%{optflags} %{?march_flag}')")
78+
export LDFLAGS="$(rpm -E '%{?build_ldflags}')"
79+
;;
80+
esac
81+
6982
mkdir /icinga2/build
7083
cd /icinga2/build
7184

7285
cmake \
7386
-GNinja \
74-
-DCMAKE_BUILD_TYPE=Release \
87+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
7588
-DICINGA2_UNITY_BUILD=ON \
7689
-DUSE_SYSTEMD=ON \
7790
-DICINGA2_USER=$(id -un) \
7891
-DICINGA2_GROUP=$(id -gn) \
79-
$CMAKE_OPTS ..
92+
"${CMAKE_OPTS[@]}" ..
8093

8194
ninja -v
8295

0 commit comments

Comments
 (0)