blob: f57ef914e36a147b19eadcac71157e7b002cdf10 [file] [log] [blame]
Jakub Ružičkad57c8882023-02-17 17:21:17 +01001%if 0%{?rhel} == 8
2%undefine __cmake_in_source_build
3%endif
4
Jakub Ružičkac82b4212021-09-27 15:13:10 +02005Name: libyang
6Version: {{ version }}
7Release: {{ release }}%{?dist}
8Summary: YANG data modeling language library
9Url: https://github.com/CESNET/libyang
Jakub Ružičkaab105882022-04-20 14:22:28 +020010Source: %{url}/archive/v%{version}/%{name}-%{version}.tar.gz
Jakub Ružičkac82b4212021-09-27 15:13:10 +020011License: BSD
12
13BuildRequires: cmake
Jakub Ružičkaab105882022-04-20 14:22:28 +020014BuildRequires: doxygen
Jakub Ružičkac82b4212021-09-27 15:13:10 +020015BuildRequires: gcc
Jakub Ružičkaab105882022-04-20 14:22:28 +020016BuildRequires: cmake(cmocka) >= 1.0.1
Jakub Ružičkac82b4212021-09-27 15:13:10 +020017BuildRequires: make
18BuildRequires: pkgconfig(libpcre2-8) >= 10.21
19
20%package devel
21Summary: Development files for libyang
22Requires: %{name}%{?_isa} = %{version}-%{release}
23Requires: pcre2-devel
24
Jakub Ružičkaab105882022-04-20 14:22:28 +020025%package devel-doc
26Summary: Documentation of libyang API
27Requires: %{name}%{?_isa} = %{version}-%{release}
28
Jakub Ružičkac82b4212021-09-27 15:13:10 +020029%package tools
30Summary: YANG validator tools
31Requires: %{name}%{?_isa} = %{version}-%{release}
32# This was not properly split out before
33Conflicts: %{name} < 1.0.225-3
34
35%description devel
36Headers of libyang library.
37
Jakub Ružičkaab105882022-04-20 14:22:28 +020038%description devel-doc
39Documentation of libyang API.
40
Jakub Ružičkac82b4212021-09-27 15:13:10 +020041%description tools
42YANG validator tools.
43
44%description
45Libyang is YANG data modeling language parser and toolkit
46written (and providing API) in C.
47
48%prep
49%autosetup -p1
Martin Winterb6cdfd72023-06-16 03:20:52 +020050%if 0%{?rhel} && 0%{?rhel} < 8
51 mkdir build
52%endif
Jakub Ružičkac82b4212021-09-27 15:13:10 +020053
54%build
Martin Winterb6cdfd72023-06-16 03:20:52 +020055%if 0%{?rhel} && 0%{?rhel} < 8
56 cd build
57 cmake \
58 -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
59 -DCMAKE_BUILD_TYPE:String="Release" \
60 -DCMAKE_C_FLAGS="${RPM_OPT_FLAGS}" \
61 -DCMAKE_CXX_FLAGS="${RPM_OPT_FLAGS}" \
62 ..
63 make
64%else
65 %cmake -DCMAKE_BUILD_TYPE=RELWITHDEBINFO
66 %cmake_build
67 %if "x%{?suse_version}" == "x"
68 cd %{__cmake_builddir}
69 %endif
Jakub Ružičkaab105882022-04-20 14:22:28 +020070%endif
71make doc
72
73%check
Martin Winterb6cdfd72023-06-16 03:20:52 +020074%if ( 0%{?rhel} == 0 ) || 0%{?rhel} > 7
75 %if "x%{?suse_version}" == "x"
76 cd %{__cmake_builddir}
77 %endif
Jakub Ružičkaab105882022-04-20 14:22:28 +020078%endif
79ctest --output-on-failure -V %{?_smp_mflags}
Jakub Ružičkac82b4212021-09-27 15:13:10 +020080
Jakub Ružičkac82b4212021-09-27 15:13:10 +020081%install
Jakub Ružičkaab105882022-04-20 14:22:28 +020082mkdir -m0755 -p %{buildroot}/%{_docdir}/libyang
Martin Winterb6cdfd72023-06-16 03:20:52 +020083%if 0%{?rhel} && 0%{?rhel} < 8
84 cd build
85 make DESTDIR=%{buildroot} install
86%else
87 %cmake_install
88 cp -a doc/html %{buildroot}/%{_docdir}/libyang/html
89%endif
Jakub Ružičkac82b4212021-09-27 15:13:10 +020090
91%files
92%license LICENSE
93%{_libdir}/libyang.so.2
94%{_libdir}/libyang.so.2.*
Michal Vasko56c9d8d2022-06-09 16:06:43 +020095%{_datadir}/yang/modules/libyang/*.yang
Michal Vasko94947492022-06-08 07:52:10 +020096%dir %{_datadir}/yang/
Michal Vasko9436df32022-06-09 08:04:34 +020097%dir %{_datadir}/yang/modules/
98%dir %{_datadir}/yang/modules/libyang/
Jakub Ružičkac82b4212021-09-27 15:13:10 +020099
100%files tools
101%{_bindir}/yanglint
102%{_bindir}/yangre
103%{_datadir}/man/man1/yanglint.1.gz
Jakub Ružičkab6a86a42021-09-27 15:15:26 +0200104%{_datadir}/man/man1/yangre.1.gz
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200105
106%files devel
107%{_libdir}/libyang.so
108%{_libdir}/pkgconfig/libyang.pc
109%{_includedir}/libyang/*.h
110%dir %{_includedir}/libyang/
111
Jakub Ružičkaab105882022-04-20 14:22:28 +0200112%files devel-doc
113%{_docdir}/libyang
114
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200115%changelog
Jakub Ružičkaab105882022-04-20 14:22:28 +0200116* {{ now }} Jakub Ružička <jakub.ruzicka@nic.cz> - {{ version }}-{{ release }}
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200117- upstream package