#
-# Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+# Copyright (c) 2016-2020 Samsung Electronics Co., Ltd All Rights Reserved
#
# Contact: Krzysztof Jackiewicz <k.jackiewicz@samsung.com>
#
SET(CMAKE_C_FLAGS_DEBUG "-std=c11 -O0 -ggdb -Wp,-U_FORTIFY_SOURCE")
SET(CMAKE_C_FLAGS_RELEASE "-std=c11 -O2 -DNDEBUG")
+SET(CMAKE_C_FLAGS_COVERAGE "-std=c11 -O0 -ggdb --coverage -Wp,-U_FORTIFY_SOURCE")
ADD_DEFINITIONS("-fPIC") # Position Independent Code
ADD_DEFINITIONS("-Werror") # Make all warnings into errors
+%{!?build_type:%define build_type "RELEASE"}
+
Name: yaca
Version: 0.0.5
Release: 0
BuildRequires: python3 >= 3.4
BuildRequires: pkgconfig(capi-base-common)
BuildRequires: pkgconfig(openssl1.1)
-%if 0%{?gcov:1}
-BuildRequires: lcov
+%if %{build_type} == "COVERAGE"
+BuildRequires: lcov
%endif
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
%setup -q
%build
-%{!?build_type:%define build_type "RELEASE"}
-
-%if 0%{?gcov:1}
-export CFLAGS+=" -fprofile-arcs -ftest-coverage"
-export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
-export FFLAGS+=" -fprofile-arcs -ftest-coverage"
-export LDFLAGS+=" -lgcov"
-%endif
-
-%cmake . -DCMAKE_BUILD_TYPE=%{build_type} \
- -DBUILD_GCOV={?gcov:1}%{!?gcov:0}
+%cmake . -DCMAKE_BUILD_TYPE=%{build_type}
make -k %{?jobs:-j%jobs}
-%if 0%{?gcov:1}
+%if %{build_type} == "COVERAGE"
mkdir -p gcov-obj
find . \( -name '*.gcno' ! -name 'tc_*' \) -exec cp '{}' gcov-obj ';'
%endif
-
%install
%make_install
%py3_compile %{buildroot}/%{python3_sitearch}
-%if 0%{?gcov:1}
+%if "%{build_type}" == "COVERAGE"
mkdir -p %{buildroot}%{_datadir}/gcov/obj
install -m 0644 gcov-obj/* %{buildroot}%{_datadir}/gcov/obj
%endif
%{python3_sitearch}/%{name}
## gcov Package ############################################################
-%if 0%{?gcov:1}
+%if "%{build_type}" == "COVERAGE"
%package gcov
Summary: yaca gcov for measuring test coverage
Group: Secureity/Testing
%files gcov
%{_datadir}/gcov/obj/*
%endif
-
-