%define build_compat32 %{?_with_compat32:1}%{!?_with_compat32:0}

Summary:        A library implementing the SSH2 protocol
Summary(ja):    SSH2 プロトコルを実装するためのライブラリ
Name:           libssh2
Version:        1.11.0
Release:        1%{?_dist_release}
Group:          system
Vendor:         Project Vine
Distribution:   Vine Linux

License:        BSD
URL:            https://www.libssh2.org/
Source0:        https://www.libssh2.org/download/%{name}-%{version}.tar.gz
# upstream patch for tests
Patch1:         572c57c9d8d4e89cfce19dde40125d55481256d1.patch

BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root
BuildRequires:  openssl-devel
BuildRequires:  zlib-devel   

%description
libssh2 is a library implementing the SSH2 protocol as defined by
Internet Drafts: SECSH-TRANS(22), SECSH-USERAUTH(25),
SECSH-CONNECTION(23), SECSH-ARCH(20), SECSH-FILEXFER(06)*,
SECSH-DHGEX(04), and SECSH-NUMBERS(10).


%package        devel
Summary:        Development files for %{name}
Summary(ja):    %{name} の開発ファイル
Group:          programming
Requires:       %{name} = %{version}-%{release}

%description    devel
The %{name}-devel package contains libraries and header files for
developing applications that use %{name}.


%package        docs 
Summary:        Documentation for %{name}
Summary(ja):    %{name} のドキュメント
Group:          documentation
Requires:       %{name} = %{version}-%{release}

%description    docs
The %{name}-docs package contains man pages and examples for
developing applications that use %{name}.


## to build compat32 for x86_64 architecture support
%package -n compat32-%{name}
Summary: A library implementing the SSH2 protocol
Summary(ja): SSH2 プロトコルを実装するためのライブラリ
Group: system,legacy

%description -n compat32-%{name}
libssh2 is a library implementing the SSH2 protocol as defined by
Internet Drafts: SECSH-TRANS(22), SECSH-USERAUTH(25),
SECSH-CONNECTION(23), SECSH-ARCH(20), SECSH-FILEXFER(06)*,
SECSH-DHGEX(04), and SECSH-NUMBERS(10).


%debug_package


%prep
%setup -q
%autopatch -p1

# Replace hard wired port number in the test suite to avoid collisions
# between 32-bit and 64-bit builds running on a single build-host
sed -i s/4711/47%{__isa_bits}/ tests/{test_ssh2.c,test_sshd.test}

# make sure things are UTF-8...
for i in ChangeLog NEWS ; do
    iconv --from=ISO-8859-1 --to=UTF-8 $i > new
    mv new $i
done

autoreconf -ivf


%build
%configure --disable-static --enable-shared

make %{?_smp_mflags}


%install
rm -rf %{buildroot}

make install DESTDIR=%{buildroot} INSTALL="install -p"
find %{buildroot} -name '*.la' -exec rm -f {} + 

# clean things up a bit for packaging
( cd example && make clean )
rm -rf example/simple/.deps 
find example/ -type f '(' -name '*.am' -o -name '*.in' ')' -exec rm -v {} +


%if 0
# docker is needed
%check
(cd tests && make check)
%endif


%clean
rm -rf %{buildroot}


%files
%defattr(-,root,root,-)
%license COPYING
%doc NEWS README* RELEASE-NOTES
%{_libdir}/*.so.*

%files docs
%defattr(-,root,root,-)
%license COPYING
%doc example/ docs/HACKING
%{_mandir}/man?/*

%files devel
%defattr(-,root,root,-)
%license COPYING
%{_includedir}/*
%{_libdir}/*.so
%{_libdir}/pkgconfig/libssh2.pc

%if %{build_compat32}
%files -n compat32-%{name}
%defattr(-,root,root,-)
%{_libdir}/*.so.*
%endif


%changelog
* Mon Jun 05 2023 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.11.0-1
- new upstream release.

* Tue Oct 05 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.10.0-2
- rebuilt with openssl-3.0.0.

* Thu Sep 09 2021 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.10.0-1
- new upstream release.
- dropped ldconfig scriptlets.

* Thu Oct 24 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.9.0-1
- new upstream release.

* Thu Mar 28 2019 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.8.2-1
- new upstream release.

* Sat Nov 03 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> 1.8.0-1
- new upstream release.
- built with openssl-1.1.1.

* Sat Mar 12 2016 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 1.7.0-2
- rebuilt with openssl 1.0.2g

* Fri Feb 26 2016 Satoshi IWAMOTO <satoshi.iwamoto@nifty.ne.jp> 1.7.0-1
- new upstream release with security fixes 

* Thu Nov 29 2012 Daisuke SUZUKI <daisuke@linux.or.jp> 1.4.2-1
- new upstream reelase
- add compat32 package

* Sat Jan 29 2011 Yoji TOYODA <bsyamato@sea.plala.or.jp> 1.2.7-1
- new upstream release
- fix %%files

* Tue Sep 15 2009 Daisuke SUZUKI <daisuke@linux.or.jp> 1.0-1
- initial build for Vine Linux

* Fri Aug 21 2009 Tomas Mraz <tmraz@redhat.com> - 1.0-4
- rebuilt with new openssl

* Sat Jul 25 2009 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 1.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_12_Mass_Rebuild

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

* Mon Feb 16 2009 Chris Weyl <cweyl@alumni.drew.edu> 1.0-1
- update to 1.0

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

* Mon Feb 18 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 0.18-7
- Autorebuild for GCC 4.3

* Wed Dec 05 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-6
- rebuild for new openssl...

* Tue Nov 27 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-5
- bump

* Tue Nov 27 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-4
- add INSTALL arg to make install vs env. var

* Mon Nov 26 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-3
- run tests; don't package test

* Sun Nov 18 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-2
- split docs into -docs (they seemed... large.)

* Tue Nov 13 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.18-1
- update to 0.18

* Sun Oct 14 2007 Chris Weyl <cweyl@alumni.drew.edu> 0.17-1
- update to 0.17
- many spec file changes

* Wed May 23 2007 Sindre Pedersen Bjørdal <foolish[AT]guezz.net> - 0.15-0.2.20070506
- Fix release tag
- Move manpages to -devel package
- Add Examples dir to -devel package

* Sun May 06 2007 Sindre Pedersen Bjørdal <foolish[AT]guezz.net> - 0.15-0.20070506.1
- Initial build
