%global _legacy_common_support 1

%if 0%{!?mkrel:1}
%define mkrel(c) %{1}%{?dist}
%endif

Name:		socat
Epoch:		1
Version:	1.8.0.2
Release:	%mkrel 1
Summary:	Multipurpose relay
License:	GPLv2
Group:		Networking/Remote access
Url:		http://www.dest-unreach.org/socat/
Source0:	http://www.dest-unreach.org/socat/download/%{name}-%{version}.tar.gz
BuildRequires:	autoconf
BuildRequires:	automake
BuildRequires:	libtool
BuildRequires:	pkgconfig(openssl)
BuildRequires:	pkgconfig(ncurses)
BuildRequires:	(readline-devel or pkgconfig(readline))
%if 0%{?mageia} || "%{_vendor}" == "openmandriva" || "%{_vendor}" == "openEuler" || 0%{?suse_version}
BuildRequires:	(tcp_wrappers-devel or libwrap-devel or tcpd-devel)
%if "%{version}" >= "1.8.0.0" && "%{_vendor}" != "openEuler" && 0%{?suse_version} < 1560
BuildRequires:	yodl
%endif
%endif

%description
socat is a relay for bidirectional data transfer between two independent data
channels. Each of these data channels may be a file, pipe, device (serial line
etc. or a pseudo terminal), a socket (UNIX, IP4, IP6 - raw, UDP, TCP), an
SSL socket, proxy CONNECT connection, a file descriptor (stdin etc.), the GNU
line editor (readline), a program, or a combination of two of these.

%prep
%autosetup -p1

%build
%configure
%make_build

%install
%make_install


%if "%{version}" < "1.7.0.0"
%check
# Many of the default tests hang and some outright fail for reasons (mostly)
# unknown (some are probably due to our OpenSSL flags). Running these few tests
# now that seem pretty reliable is better than running none at all.
./test.sh fork dgram unix ipapp
%endif

%files
%doc README EXAMPLES FAQ CHANGES BUGREPORTS
%doc doc/dest-unreach.css doc/socat-genericsocket.html doc/socat.html doc/socat-multicast.html doc/socat-openssltunnel.html doc/socat-tun.html
%license COPYING
%{_bindir}/%{name}
%{_bindir}/filan
%{_bindir}/procan
%if "%{version}" >= "1.8.0.0"
%{_bindir}/socat-broker.sh
%{_bindir}/socat-chain.sh
%{_bindir}/socat-mux.sh
%{_bindir}/socat1
%endif
%{_mandir}/man1/*