blob: bef15962bceccd913edba6768d2f6a572206c67d [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
Igor Ryzhovb0500752024-03-27 18:40:06 +020020%package modules
21Summary: YANG modules for libyang
22
Jakub Ružičkac82b4212021-09-27 15:13:10 +020023%package devel
24Summary: Development files for libyang
25Requires: %{name}%{?_isa} = %{version}-%{release}
26Requires: pcre2-devel
27
Jakub Ružičkaab105882022-04-20 14:22:28 +020028%package devel-doc
29Summary: Documentation of libyang API
30Requires: %{name}%{?_isa} = %{version}-%{release}
31
Jakub Ružičkac82b4212021-09-27 15:13:10 +020032%package tools
33Summary: YANG validator tools
34Requires: %{name}%{?_isa} = %{version}-%{release}
35# This was not properly split out before
36Conflicts: %{name} < 1.0.225-3
37
Igor Ryzhovb0500752024-03-27 18:40:06 +020038%description modules
39YANG modules for libyang.
40
Jakub Ružičkac82b4212021-09-27 15:13:10 +020041%description devel
42Headers of libyang library.
43
Jakub Ružičkaab105882022-04-20 14:22:28 +020044%description devel-doc
45Documentation of libyang API.
46
Jakub Ružičkac82b4212021-09-27 15:13:10 +020047%description tools
48YANG validator tools.
49
50%description
51Libyang is YANG data modeling language parser and toolkit
52written (and providing API) in C.
53
54%prep
55%autosetup -p1
Martin Winterb6cdfd72023-06-16 03:20:52 +020056%if 0%{?rhel} && 0%{?rhel} < 8
57 mkdir build
58%endif
Jakub Ružičkac82b4212021-09-27 15:13:10 +020059
60%build
Martin Winterb6cdfd72023-06-16 03:20:52 +020061%if 0%{?rhel} && 0%{?rhel} < 8
62 cd build
63 cmake \
64 -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \
65 -DCMAKE_BUILD_TYPE:String="Release" \
66 -DCMAKE_C_FLAGS="${RPM_OPT_FLAGS}" \
67 -DCMAKE_CXX_FLAGS="${RPM_OPT_FLAGS}" \
68 ..
69 make
70%else
71 %cmake -DCMAKE_BUILD_TYPE=RELWITHDEBINFO
72 %cmake_build
73 %if "x%{?suse_version}" == "x"
74 cd %{__cmake_builddir}
75 %endif
Jakub Ružičkaab105882022-04-20 14:22:28 +020076%endif
77make doc
78
79%check
Martin Winterb6cdfd72023-06-16 03:20:52 +020080%if ( 0%{?rhel} == 0 ) || 0%{?rhel} > 7
81 %if "x%{?suse_version}" == "x"
82 cd %{__cmake_builddir}
83 %endif
Jakub Ružičkaab105882022-04-20 14:22:28 +020084%endif
85ctest --output-on-failure -V %{?_smp_mflags}
Jakub Ružičkac82b4212021-09-27 15:13:10 +020086
Jakub Ružičkac82b4212021-09-27 15:13:10 +020087%install
Jakub Ružičkaab105882022-04-20 14:22:28 +020088mkdir -m0755 -p %{buildroot}/%{_docdir}/libyang
Martin Winterb6cdfd72023-06-16 03:20:52 +020089%if 0%{?rhel} && 0%{?rhel} < 8
90 cd build
91 make DESTDIR=%{buildroot} install
92%else
93 %cmake_install
94 cp -a doc/html %{buildroot}/%{_docdir}/libyang/html
95%endif
Jakub Ružičkac82b4212021-09-27 15:13:10 +020096
97%files
98%license LICENSE
Michal Vasko71d0ca92024-02-26 15:14:52 +010099%{_libdir}/libyang.so.3
100%{_libdir}/libyang.so.3.*
Igor Ryzhovb0500752024-03-27 18:40:06 +0200101
102%files modules
Michal Vasko56c9d8d2022-06-09 16:06:43 +0200103%{_datadir}/yang/modules/libyang/*.yang
Michal Vasko94947492022-06-08 07:52:10 +0200104%dir %{_datadir}/yang/
Michal Vasko9436df32022-06-09 08:04:34 +0200105%dir %{_datadir}/yang/modules/
106%dir %{_datadir}/yang/modules/libyang/
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200107
108%files tools
109%{_bindir}/yanglint
110%{_bindir}/yangre
111%{_datadir}/man/man1/yanglint.1.gz
Jakub Ružičkab6a86a42021-09-27 15:15:26 +0200112%{_datadir}/man/man1/yangre.1.gz
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200113
114%files devel
115%{_libdir}/libyang.so
116%{_libdir}/pkgconfig/libyang.pc
117%{_includedir}/libyang/*.h
118%dir %{_includedir}/libyang/
119
Jakub Ružičkaab105882022-04-20 14:22:28 +0200120%files devel-doc
121%{_docdir}/libyang
122
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200123%changelog
Jakub Ružičkaab105882022-04-20 14:22:28 +0200124* {{ now }} Jakub Ružička <jakub.ruzicka@nic.cz> - {{ version }}-{{ release }}
Jakub Ružičkac82b4212021-09-27 15:13:10 +0200125- upstream package