+#
+# Conditional build:
+%bcond_without apidocs # Doxygen documentation in HTML format
+
Summary: C library for portable packet creation and injection
Summary(pl.UTF-8): Biblioteka C do przenośnego tworzenia i wprowadzania pakietów
Summary(pt_BR.UTF-8): API para funções de rede de baixo nível
Name: libnet
-Version: 1.1.6
-Release: 2
+Version: 1.2
+Release: 1
Epoch: 1
License: BSD
Group: Libraries
-Source0: http://downloads.sourceforge.net/libnet-dev/%{name}-%{version}.tar.gz
-# Source0-md5: 710296fe424a49344e5fcc0d09e53317
-Patch0: %{name}-leaking-fd.patch
+#Source0Download: https://github.com/libnet/libnet/releases
+Source0: https://github.com/libnet/libnet/releases/download/v%{version}/%{name}-%{version}.tar.gz
+# Source0-md5: a36c669e0cdfda6a2aa3adfb1f6fe60a
+Patch0: %{name}-libdir.patch
Patch1: %{name}-proc.patch
-URL: http://sourceforge.net/projects/libnet-dev/
-BuildRequires: autoconf
-BuildRequires: automake
-BuildRequires: libtool
+URL: https://github.com/libnet/libnet
+BuildRequires: autoconf >= 2.69
+BuildRequires: automake >= 1:1.14
+%{?with_apidocs:BuildRequires: doxygen}
+BuildRequires: libtool >= 2:2.4.2
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
Arquivos de cabeçalho e bibliotecas usadas no desenvolvimento de
aplicativos estáticos que usam libnet.
+%package apidocs
+Summary: API documentation for libnet
+Summary(pl.UTF-8): Dokumentacja API biblioteki libnet
+Group: Documentation
+%if "%{_rpmversion}" >= "4.6"
+BuildArch: noarch
+%endif
+
+%description apidocs
+API documentation for libnet.
+
+%description apidocs -l pl.UTF-8
+Dokumentacja API biblioteki libnet.
+
%package examples
Summary: libnet - example programs
Summary(pl.UTF-8): libnet - programy przykładowe
Group: Development/Libraries
Requires: %{name}-devel = %{epoch}:%{version}-%{release}
+%if "%{_rpmversion}" >= "4.6"
+BuildArch: noarch
+%endif
%description examples
libnet - example programs.
%build
%{__libtoolize}
-%{__aclocal}
+%{__aclocal} -I m4
%{__autoconf}
+%{__autoheader}
%{__automake}
-%configure
+%configure \
+ %{!?with_apidocs:--disable-doxygen-html} \
+ --with-link-layer=linux
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT{%{_examplesdir}/%{name}-%{version},%{_mandir}/man3} \
- $RPM_BUILD_ROOT{/%{_lib},%{_bindir}}
+install -d $RPM_BUILD_ROOT{/%{_lib},%{_mandir}/man1,%{_examplesdir}/%{name}-%{version}}
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
-mv $RPM_BUILD_ROOT%{_libdir}/libnet.so.* $RPM_BUILD_ROOT/%{_lib}
+cp -p sample/*.[ch] $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
+
+%{__mv} $RPM_BUILD_ROOT%{_libdir}/libnet.so.* $RPM_BUILD_ROOT/%{_lib}
ln -sf /%{_lib}/$(cd $RPM_BUILD_ROOT/%{_lib} ; echo libnet.so.*.*.*) \
$RPM_BUILD_ROOT%{_libdir}/libnet.so
-install sample/*.[ch] $RPM_BUILD_ROOT%{_examplesdir}/%{name}-%{version}
-install doc/man/man3/libnet-functions.h.3 $RPM_BUILD_ROOT%{_mandir}/man3
-install libnet-config $RPM_BUILD_ROOT%{_bindir}
+# fix man section
+%{__mv} $RPM_BUILD_ROOT{%{_mandir}/man3/libnet-config.3,%{_mandir}/man1/libnet-config.1}
+
+# obsoleted by pkg-config
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/libnet.la
+
+%if %{with apidocs}
+# packaged as %doc
+%{__rm} -r $RPM_BUILD_ROOT%{_docdir}/libnet
+%endif
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc README doc/{CHANGELOG,MIGRATION,PACKET_BUILDING}
+%doc ChangeLog.md LICENSE README.md doc/{MIGRATION,RAWSOCKET}.md
%attr(755,root,root) /%{_lib}/libnet.so.*.*.*
-%attr(755,root,root) %ghost /%{_lib}/libnet.so.1
+%attr(755,root,root) %ghost /%{_lib}/libnet.so.9
%files devel
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/libnet-config
%attr(755,root,root) %{_libdir}/libnet.so
-%{_libdir}/libnet.la
%{_includedir}/libnet.h
%{_includedir}/libnet
-%{_mandir}/man3/libnet*.h.3*
+%{_pkgconfigdir}/libnet.pc
+%{_mandir}/man1/libnet-config.1*
+%{_mandir}/man3/libnet.3*
+%{_mandir}/man3/libnet-functions.3*
+%{_mandir}/man3/libnet-macros.3*
%files static
%defattr(644,root,root,755)
%{_libdir}/libnet.a
+%if %{with apidocs}
+%files apidocs
+%defattr(644,root,root,755)
+%doc doc/html/*.{css,html,js,png}
+%endif
+
%files examples
%defattr(644,root,root,755)
%{_examplesdir}/%{name}-%{version}