%{?!with_python3:     %global with_python3     0}
%{?!enable_gost:      %global enable_gost      0}
%{?!enable_dane:      %global enable_dane      1}

%if %{enable_gost}
%define	subdir_conf_opt --disable-rpath --disable-static
%else
%define	subdir_conf_opt --disable-rpath --disable-static --disable-gost
%endif


Summary: Lowlevel DNS(SEC) library with API
Summary(ja): 低レベルな DNS(SEC) ライブラリと API
Name: ldns
Version: 1.8.1
Release: 1%{?_dist_release}
Group: system
Distribution: Vine Linux
Vendor: Project Vine
Packager: iwaim

License: BSD
URL: http://www.nlnetlabs.nl/%{name}/
Source: https://www.nlnetlabs.nl/downloads/ldns/%{name}-%{version}.tar.gz

BuildRequires: libtool, autoconf, automake, gcc-c++, doxygen,
BuildRequires: perl, libpcap-devel
%if %{enable_gost}
BuildRequires: openssl-devel >= 1.0.0
%else
BuildRequires: openssl-devel
%endif
%if %{with_python3}
BuildRequires: python3-rpm-macros
BuildRequires: python3-devel, swig
%endif
Obsoletes: ldns-python < 1.7.1-2

Requires: ca-certificates


%description
ldns is a library with the aim to simplify DNS programing in C. All
lowlevel DNS/DNSSEC operations are supported. We also define a higher
level API which allows a programmer to (for instance) create or sign
packets.


%package devel
Summary: Development package that includes the ldns header files
Group: programming
Requires: %{name} = %{version}-%{release}

%description devel
The devel package contains the ldns library and the include files


%if %{with_python3}
%package -n python3-ldns
Summary: Python3 extensions for ldns
Group: programming
Requires: %{name} = %{version}-%{release}

%description -n python3-ldns
Python3 extensions for ldns
%endif


%debug_package


%prep
%{?extra_version:%global pkgname %{name}-%{version}%{extra_version}}%{!?extra_version:%global pkgname %{name}-%{version}}

%autosetup -cn %{pkgname} -N
pushd %{pkgname}

# fixup .pc file
sed -i "s/@includedir@/@includedir@\/ldns/" packaging/libldns.pc.in

autoreconf -ivf
popd


%build
CFLAGS="%{optflags} -fPIC -fno-strict-aliasing"
CXXFLAGS="%{optflags} -fPIC -fno-strict-aliasing"
LDFLAGS="$RPM_LD_FLAGS -Wl,-z,now -pie"
export CFLAGS CXXFLAGS LDFLAGS

pushd %{pkgname}
%configure --disable-rpath --disable-static \
 --enable-ecdsa \
 --enable-ed25519 --enable-ed448 \
 --with-ca-file=/etc/pki/tls/certs/ca-bundle.trust.crt \
 --with-ca-path=/etc/pki/tls/certs/ \
 --with-trust-anchor=%{_sharedstatedir}/unbound/root.key \
 --with-examples \
 --with-drill \
%if !%{enable_gost}
 --disable-gost \
%endif
%if %{with_python3}
 --with-pyldns PYTHON=%{__python3}\
%endif

make %{?_smp_mflags} 
make %{?_smp_mflags} drill
make %{?_smp_mflags} examples
make %{?_smp_mflags} doc
popd


%install
rm -rf %{buildroot}

pushd %{pkgname}
mkdir -p %{buildroot}%{_libdir}/pkgconfig

make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install 
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-drill
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-examples
make DESTDIR=%{buildroot} INSTALL="%{__install} -p" install-doc

%if %{with_python3}
# remove execute perms from python files
chmod a-x %{buildroot}%{python3_sitearch}/*py
%endif

# don't package building script in doc
rm doc/doxyparse.pl
#remove doc stubs
rm -rf doc/.svn
#remove double set of man pages
rm -rf doc/man

# remove .la files
rm -rf %{buildroot}%{_libdir}/*.la %{buildroot}%{python3_sitearch}/*.la
popd


%clean
rm -rf %{buildroot}


%files 
%license %{pkgname}/LICENSE 
%doc %{pkgname}/README 
%{_libdir}/libldns*so.*
%{_bindir}/drill
%{_bindir}/ldnsd
#%{_bindir}/ldns-*
%{_bindir}/ldns-chaos
%{_bindir}/ldns-compare-zones
%{_bindir}/ldns-[d-z]*
%{_mandir}/*/*

%files devel
%doc %{pkgname}/doc %{pkgname}/Changelog %{pkgname}/README
%{_libdir}/libldns*so
%{_bindir}/ldns-config
%{_libdir}/pkgconfig/*.pc
%dir %{_includedir}/ldns
%{_includedir}/ldns/*.h

%if %{with_python3}
%files python3-ldns
%defattr(-,root,root)
%{python_sitearch}/*
%endif


%changelog
* Fri Dec 03 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.8.1-1
- new upstream release.

* Fri Nov 26 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.8.0-1
- new upstream release.
- dropped Patch1.
- dropped Patch2-4: fixed in upstream.

* Sat Oct 16 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.7.1-2
- rebuilt with openssl-3.0.0.
- imported Patch1-4 from rawhide.
- dropped ldconfig scriptlets.
- dropped python support.

* Sat Aug 24 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.7.1-1
- updated to 1.7.1.

* Sun Nov 04 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.7.0-2
- rebuilt with openssl-1.1.1.

* Mon Jan 30 2017 IWAI, Masaharu <iwaim.sub@gmail.com> 1.7.0-1
- update to 1.7.0
- add enable_dane option

* Tue Mar 15 2016 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.6.17-2
- rebuilt with openssl-1.0.2g.

* Mon Mar  9 2015 IWAI, Masaharu <iwaim.sub@gmail.com> 1.6.17-1
- update to 1.6.17
- drop 'fix compiler warnings and one uninitialized value' patch (Patch1000)
 - upstream merged

* Tue Dec 31 2013 IWAI, Masaharu <iwaim.sub@gmail.com> 1.6.16-2
- add 'fix compiler warnings and one uninitialized value' patch (Patch1000)
 - from Fedora ldns-1.6.16-6.fc20

* Wed Dec  5 2012 IWAI, Masaharu <iwai@alib.jp> 1.6.16-1
- new upstream release

* Sun May 27 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 1.6.13-1
- new upstream release 
- move python files to sitearch from sitelib

* Wed Feb 29 2012 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.6.10-2
- rebuild with python-2.7.2

* Sat Sep  3 2011 IWAI, Masaharu <iwai@alib.jp> 1.6.10-1
- new upstream release

* Wed Mar 30 2011 IWAI, Masaharu <iwai@alib.jp> 1.6.9-1
- new upstream release

* Wed Feb 23 2011 IWAI, Masaharu <iwai@alib.jp> 1.6.8-1
- new upstream release

* Sun Nov 14 2010 IWAI, Masaharu <iwai@alib.jp> 1.6.7-1
- new upstream release
- add enable_gost flag: default disable
- defined subdir_conf_opt rpm macro

* Thu Sep  2 2010 IWAI, Masaharu <iwai@alib.jp> 1.6.6-1
- new upstream release

* Fri Jul 23 2010 IWAI, Masaharu <iwai@alib.jp> 1.6.5-1
- new upstream release
- drop unnecessary installfix patch (Patch1): upstream merged
- drop unnecessary rpathfix patch (Patch2): upstream merged

* Thu Jun  3 2010 IWAI, Masaharu <iwai@alib.jp> 1.6.4-2vl6
- rebuild with libpcap 1.1.1 on VineSeed

* Wed May  5 2010 IWAI, Masaharu <iwai@alib.jp> 1.6.4-1
- initial build for Vine Linux: based Fedora 1.6.4-2.fc13

* Fri Jan 22 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-2
- Fix missing _ldns.so causing ldns-python to not work
- Patch for installing ldns-python files
- Patch for rpath in ldns-python
- Don't install .a file for ldns-python

* Wed Jan 20 2010 Paul Wouters <paul@xelerance.com> - 1.6.4-1
- Upgraded to 1.6.4. 
- Added ldns-python sub package

* Fri Dec 04 2009 Paul Wouters <paul@xelerance.com> - 1.6.3-1
- Upgraded to 1.6.3, which has minor bugfixes

* Fri Nov 13 2009 Paul Wouters <paul@xelerance.com> - 1.6.2-1
- Upgraded to 1.6.2. This fixes various bugs.
  (upstream released mostly to default with sha2 for the imminent
   signed root, but we already enabled that in our builds)

* Tue Aug 25 2009 Tomas Mraz <tmraz@redhat.com> - 1.6.1-3
- rebuilt with new openssl

* Sun Aug 16 2009 Paul Wouters <paul@xelerance.com> - 1.6.1-2
- Added openssl dependancy back in, since we get more functionality
 when using openssl. Especially in 'drill'.

* Sun Aug 16 2009 Paul Wouters <paul@xelerance.com> - 1.6.1-1
- Updated to 1.6.1

* Fri Jul 24 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.6.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

* Mon Jul 13 2009 Paul Wouters <paul@xelerance.com> - 1.6.0-4
- Fixed the ssl patch so it can now compile --without-ssl

* Sat Jul 11 2009 Paul Wouters <paul@xelerance.com> - 1.6.0-3
- Added patch to compile with --without-ssl
- Removed openssl dependancies
- Recompiled with --without-ssl

* Sat Jul 11 2009 Paul Wouters <paul@xelerance.com> - 1.6.0-2
- Updated to 1.6.0
- (did not yet compile with --without-ssl due to compile failures)

* Fri Jul 10 2009 Paul Wouters <paul@xelerance.com> - 1.6.0-1
- Updated to 1.6.0
- Compile without openssl

* Thu Apr 16 2009 Paul Wouters <paul@xelerance.com> - 1.5.1-4
- Memory management bug when generating a sha256 key, see:
  https://bugzilla.redhat.com/show_bug.cgi?id=493953

* Wed Feb 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_11_Mass_Rebuild

* Tue Feb 10 2009 Paul Wouters <paul@xelerance.com> - 1.5.1-1
- Updated to new version, 1.5.0 had a bug preventing
  zone signing.

* Mon Feb  9 2009 Paul Wouters <paul@xelerance.com> - 1.5.0-1
- Updated to new version

* Thu Feb 05 2009 Adam Tkac <atkac redhat com> - 1.4.0-3
- fixed configure flags

* Sat Jan 17 2009 Tomas Mraz <tmraz@redhat.com> - 1.4.0-2
- rebuild with new openssl

* Fri Nov  7 2008 Paul Wouters <paul@xelerance.com> - 1.4.0-1
- Updated to 1.4.0

* Wed May 28 2008 Paul Wouters <paul@xelerance.com> - 1.3.0-3
- enable SHA2 functionality

* Wed May 28 2008 Paul Wouters <paul@xelerance.com> - 1.3.0-2
- re-tag (don't do builds while renaming local repo dirs)

* Wed May 28 2008 Paul Wouters <paul@xelerance.com> - 1.3.0-1
- Updated to latest release

* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 1.2.2-3
- Autorebuild for GCC 4.3

* Wed Dec  5 2007 Paul Wouters <paul@xelerance.com> - 1.2.2-2
- Rebuild for new libcrypto

* Thu Nov 29 2007 Paul Wouters <paul@xelerance.com> - 1.2.2-1
- Upgraded to 1.2.2. Removed no longer needed race workaround

* Tue Nov 13 2007 Paul Wouters <paul@xelerance.com> - 1.2.1-4
- Try to fix racing ln -s statements in parallel builds

* Fri Nov  9 2007 Paul Wouters <paul@xelerance.com> - 1.2.1-3
- Added patch for ldns-read-zone that does not put @. in RRDATA

* Fri Oct 19 2007 Paul Wouters <paul@xelerance.com> - 1.2.1-2
- Use install -p to work around multilib conflicts for .h files

* Wed Oct 10 2007 Paul Wouters <paul@xelerance.com> - 1.2.1-1
- Updated to 1.2.1
- Removed patches that got moved into upstream

* Wed Aug  8 2007 Paul Wouters <paul@xelerance.com> 1.2.0-11
- Patch for ldns-key2ds to write to stdout
- Again remove extra set of man pages from doc
- own /usr/include/ldns (bug 233858)

* Wed Aug  8 2007 Paul Wouters <paul@xelerance.com> 1.2.0-10
- Added sha256 DS record patch to ldns-key2ds
- Minor tweaks for proper doc/man page installation.
- Workaround for parallel builds

* Mon Aug  6 2007 Paul Wouters <paul@xelerance.com> 1.2.0-2
- Own the /usr/include/ldns directory (bug #233858)
- Removed obsoleted patch
- Remove files form previous libtool run accidentally packages by upstream

* Mon Sep 11 2006 Paul Wouters <paul@xelerance.com> 1.0.1-4
- Commented out 1.1.0 make targets, put make 1.0.1 targets.

* Mon Sep 11 2006 Paul Wouters <paul@xelerance.com> 1.0.1-3
- Fixed changelog typo in date
- Rebuild requested for PT_GNU_HASH support from gcc
- Did not upgrade to 1.1.0 due to compile issues on x86_64

* Fri Jan  6 2006 Paul Wouters <paul@xelerance.com> 1.0.1-1
- Upgraded to 1.0.1. Removed temporary clean hack from spec file.

* Sun Dec 18 2005 Paul Wouters <paul@xelerance.com> 1.0.0-8
- Cannot use make clean because there are no Makefiles. Use hardcoded rm.

* Sun Dec 18 2005 Paul Wouters <paul@xelerance.com> 1.0.0-7
- Patched 'make clean' target to get rid of object files shipped with 1.0.0

* Tue Dec 13 2005 Paul Wouters <paul@xelerance.com> 1.0.0-6
- added a make clean for 2.3.3 since .o files were left behind upstream,
  causing failure on ppc platform

* Sun Dec 11 2005 Tom "spot" Callaway <tcallawa@redhat.com> 1.0.0-5
- minor cleanups

* Wed Oct  5 2005 Paul Wouters <paul@xelerance.com> 0.70_1205
- reworked for svn version

* Sun Sep 25 2005 Paul Wouters <paul@xelerance.com> - 0.70
- Initial version
