+#
+# Conditional build:
+%bcond_without static_libs # static library
+
Summary: A library that performs asynchronous DNS operations
-Summary(pl.UTF-8): Biblioteka do wykonywania asynchronicznych zapytań DNS
+Summary(pl.UTF-8): Biblioteka do wykonywania asynchronicznych zapytań DNS
Name: c-ares
-Version: 1.3.2
+Version: 1.22.0
Release: 1
License: MIT
Group: Libraries
-Source0: http://daniel.haxx.se/projects/c-ares/%{name}-%{version}.tar.gz
-# Source0-md5: 3f517655f22531889b2465219f4833fa
-URL: http://daniel.haxx.se/projects/c-ares/
+#Source0Download: https://c-ares.haxx.se/
+Source0: https://c-ares.haxx.se/download/%{name}-%{version}.tar.gz
+# Source0-md5: 0f9e7f16ddb6526e202e5e45b39253c7
+Patch0: %{name}-resolv.conf-reading-is-not-fatal.patch
+URL: https://c-ares.haxx.se/
+BuildRequires: autoconf >= 2.60
+BuildRequires: automake >= 1:1.9.6
+# for tests
+#BuildRequires: libstdc++-devel >= 6:4.7
+BuildRequires: libtool >= 2:2
+BuildRequires: rpmbuild(macros) >= 1.527
+BuildRequires: sed >= 4.0
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
%package devel
Summary: Development files for c-ares library
-Summary(pl.UTF-8): Pliki nagłówkowe dla biblioteki c-ares
+Summary(pl.UTF-8): Pliki nagłówkowe dla biblioteki c-ares
Group: Development/Libraries
Requires: %{name} = %{version}-%{release}
%package static
Summary: Static c-ares library
-Summary(pl.UTF-8): Statyczna biblioteka c-ares
+Summary(pl.UTF-8): Statyczna biblioteka c-ares
Group: Development/Libraries
Requires: %{name}-devel = %{version}-%{release}
%prep
%setup -q
+%patch0 -p1
+
+# we want our own debug flags, if any
+%{__sed} -i -e 's/flags_dbg_off=".*"/flags_dbg_off="%{rpmcflags}"/' m4/cares-compilers.m4
+%{__sed} -i -e 's/flags_opt_yes=".*"/flags_opt_yes="%{rpmcflags}"/' m4/cares-compilers.m4
%build
+%{__libtoolize}
+%{__aclocal} -I m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+cd test
+%{__libtoolize}
+%{__aclocal} -I ../m4
+%{__autoconf}
+%{__autoheader}
+%{__automake}
+cd ..
%configure \
+ --disable-silent-rules \
+ %{__enable_disable static_libs static} \
+ --disable-tests \
+ --enable-optimize="%{rpmcflags}" \
--enable-shared
%{__make}
%install
rm -rf $RPM_BUILD_ROOT
+
%{__make} install \
DESTDIR=$RPM_BUILD_ROOT
+# no external dependencies + obsoleted by pkg-config
+%{__rm} $RPM_BUILD_ROOT%{_libdir}/libcares.la
+
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(644,root,root,755)
-%doc README README.cares CHANGES NEWS
-%attr(755,root,root) %{_libdir}/*.so.*.*.*
+%doc AUTHORS CHANGES LICENSE.md NEWS README.cares README.md RELEASE-NOTES TODO
+%attr(755,root,root) %{_libdir}/libcares.so.*.*.*
+%attr(755,root,root) %ghost %{_libdir}/libcares.so.2
%files devel
%defattr(644,root,root,755)
-%attr(755,root,root) %{_libdir}/*.so
-%{_libdir}/*.la
-%{_includedir}/*
-%{_mandir}/man3/*
-
+%attr(755,root,root) %{_libdir}/libcares.so
+%{_includedir}/ares.h
+%{_includedir}/ares_build.h
+%{_includedir}/ares_dns.h
+%{_includedir}/ares_dns_record.h
+%{_includedir}/ares_nameser.h
+%{_includedir}/ares_rules.h
+%{_includedir}/ares_version.h
+%{_mandir}/man3/ares_*.3*
+%{_pkgconfigdir}/libcares.pc
+
+%if %{with static_libs}
%files static
%defattr(644,root,root,755)
-%{_libdir}/*.a
+%{_libdir}/libcares.a
+%endif