Remove duplicated codes
[platform/core/api/tethering.git] / packaging / capi-network-tethering.spec
1 Name:           capi-network-tethering
2 Summary:        Tethering Framework
3 Version:        1.2.1
4 Release:        1
5 Group:          System/Network
6 License:        Apache-2.0
7 Source0:        %{name}-%{version}.tar.gz
8 BuildRequires:  pkgconfig(dlog)
9 BuildRequires:  pkgconfig(dbus-1)
10 BuildRequires:  pkgconfig(capi-base-common)
11 BuildRequires:  pkgconfig(glib-2.0)
12 BuildRequires:  pkgconfig(gio-2.0)
13 BuildRequires:  pkgconfig(vconf)
14 BuildRequires:  pkgconfig(key-manager)
15 BuildRequires:  pkgconfig(capi-system-info)
16 BuildRequires:  pkgconfig(libtzplatform-config)
17 BuildRequires:  pkgconfig(gmock)
18 BuildRequires:  cmake
19 %if 0%{?gcov:1}
20 BuildRequires: gtest-devel
21 BuildRequires: lcov
22 BuildRequires: tar
23 %endif
24 Requires(post):         /sbin/ldconfig
25 Requires(postun):       /sbin/ldconfig
26
27 %description
28 Tethering framework library for CAPI
29
30 %package devel
31 Summary:        Development package for Tethering framework library
32 Group:          Development/Libraries
33 Requires:       %{name} = %{version}-%{release}
34 %description devel
35 Development package for Tethering framework library
36
37 %package tool
38 Summary:        Test application for Tethering
39 %description tool
40 Test application for Tethering
41
42 %if 0%{?gcov:1}
43 %package gcov
44 Summary:  Tethering Library(gcov)
45 Group:    Network/Testing
46 %description gcov
47 gcov objects for coverage test
48 %endif
49
50 %if 0%{?asan} != 1
51 %package unittests
52 Summary: %{name} unittests binary
53
54 %description unittests
55 unittests binary
56 %endif
57
58 %prep
59 %setup -q
60
61
62 %build
63 %if 0%{?gcov:1}
64 export CFLAGS+=" -fprofile-arcs -ftest-coverage"
65 export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
66 export FFLAGS+=" -fprofile-arcs -ftest-coverage"
67 %endif
68
69 %if "%{?tizen_profile_name}" == "tv"
70 export CFLAGS+=" -DTIZEN_TV_EXT"
71 export CXXFLAGS+=" -DTIZEN_TV_EXT"
72 %endif
73
74 %cmake -DLIB_INSTALL_DIR=%{_libdir} \
75        -DBUILD_UNITTEST=%{?asan:0}%{!?asan:1} \
76         .
77 make %{?_smp_mflags}
78
79 %install
80 rm -rf %{buildroot}
81 %make_install
82
83 %if 0%{?gcov:1}
84 builddir=$(basename $PWD)
85 gcno_obj_dir=%{buildroot}%{_datadir}/gcov/obj/%{name}/"$builddir"
86 mkdir -p "$gcno_obj_dir"
87 find . -name '*.gcno' ! -path '*/tools/*' -exec cp --parents '{}' "$gcno_obj_dir" ';'
88 %endif
89
90 %if 0%{?asan} != 1
91 cat << EOF > run-unittest.sh
92 #!/bin/sh
93 setup() {
94     echo "setup start"
95 }
96
97 test_main() {
98     echo "test_main start"
99     /usr/bin/tethering-gtest
100 }
101
102 teardown() {
103     echo "teardown start"
104 }
105
106 main() {
107     setup
108     test_main
109     teardown
110 }
111
112 main "\$*"
113 EOF
114
115 mkdir -p %{buildroot}%{_bindir}/tizen-unittests/%{name}
116 install -m 0755 run-unittest.sh %{buildroot}%{_bindir}/tizen-unittests/%{name}/
117 %endif
118
119 %check
120 %if 0%{?gcov:1}
121 tests/tethering-gtest
122 lcov -c --ignore-errors graph --no-external -b . -d . -o %{name}.info
123 genhtml %{name}.info -o out --legend --show-details
124 %endif
125
126 %post -p /sbin/ldconfig
127
128 %postun -p /sbin/ldconfig
129
130 %files
131 %manifest capi-network-tethering.manifest
132 %defattr(-,root,root,-)
133 %{_libdir}/*.so.*
134 %license LICENSE
135
136 %files devel
137 %defattr(-,root,root,-)
138 %{_includedir}/network/*.h
139 %{_libdir}/pkgconfig/*.pc
140 %{_libdir}/*.so
141 %license LICENSE
142
143 %files tool
144 %{_bindir}/tethering_test
145
146 %if 0%{?gcov:1}
147 %files gcov
148 %{_datadir}/gcov/obj/*
149 %endif
150
151 %if 0%{?asan} != 1
152 %files unittests
153 %{_bindir}/tethering-gtest
154 %{_bindir}/tizen-unittests/%{name}/run-unittest.sh
155 %endif