%define __find_requires %{_mingw32_findrequires}
%define __find_provides %{_mingw32_findprovides}
+# Enable the tests.
+# These only work some of the time, but fail randomly at other times
+# (although I have had them complete a few times, so I don't think
+# there is any actual problem with the binaries).
+%define with_tests 0
+
Name: mingw32-openssl
Version: 0.9.8g
Release: 1%{?dist}
Patch101: mingw32-openssl-0.9.8g-configure.patch
Patch102: mingw32-openssl-0.9.8g-shared.patch
Patch103: mingw32-openssl-0.9.8g-global.patch
+Patch104: mingw32-openssl-0.9.8g-sfx.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: /usr/bin/cmp
BuildRequires: /usr/bin/rename
-# Required to run the tests.
+# XXX Not really sure about this one. The build script uses
+# /usr/bin/makedepend which comes from imake.
+BuildRequires: imake
+
+# Required both to build, and to run the tests.
+# XXX This needs to be fixed - cross-compilation should not
+# require running executables.
BuildRequires: wine
+
+%if %{with_tests}
+# Required to run the tests.
BuildRequires: xorg-x11-server-Xvfb
+%endif
#Requires: ca-certificates >= 2008-5
Requires: pkgconfig
%patch101 -p1 -b .mingw-configure
%patch102 -p1 -b .mingw-shared
%patch103 -p1 -b .mingw-global
+%patch104 -p1 -b .mingw-sfx
# Modify the various perl scripts to reference perl in the right location.
perl util/perlpath.pl `dirname %{__perl}`
# NB: 'no-hw' is vital. MinGW cannot build the hardware drivers
# and if you don't have this you'll get an obscure link error.
./Configure \
+ --prefix=%{_mingw32_prefix} \
--openssldir=%{_mingw32_sysconfdir}/pki/tls \
zlib enable-camellia enable-seed enable-tlsext enable-rfc3779 \
no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa no-hw shared \
make all build-shared
make rehash build-shared
+%if %{with_tests}
#----------------------------------------------------------------------
# Run some tests. I don't know why this isn't in a %-check section
# but this is how it is in the native RPM.
# it). Therefore we create a virtual framebuffer for the duration of
# the tests.
# XXX There is no good way to choose a random, unused display.
+# XXX Setting depth to 24 bits avoids bug 458219.
+unset DISPLAY
display=:21
-Xvfb $display & xpid=$!
+Xvfb $display -screen 0 1024x768x24 -ac -noreset & xpid=$!
trap "kill -TERM $xpid ||:" EXIT
sleep 3
DISPLAY=$display
make LDCMD=%{_mingw32_cc} -C test apps tests
# Disable this thread test, because we don't have pthread on Windows.
-#%{_mingw32_cc} -o openssl-thread-test \
+#%-{_mingw32_cc} -o openssl-thread-test \
# -I./include \
-# %{_mingw32_cflags} \
-# %{SOURCE8} \
+# %-{_mingw32_cflags} \
+# %-{SOURCE8} \
# -L. \
# -lssl -lcrypto \
# -lpthread -lz -ldl
#
#./openssl-thread-test --threads %{thread_test_threads}
+#----------------------------------------------------------------------
+%endif
+
# Patch33 must be patched after tests otherwise they will fail
patch -p1 -b -z .ca-dir < %{PATCH33}
%install
rm -rf $RPM_BUILD_ROOT
-exit 1
-make DESTDIR=$RPM_BUILD_ROOT install
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}/openssl
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_includedir}
+mkdir -p $RPM_BUILD_ROOT%{_mingw32_mandir}
+make INSTALL_PREFIX=$RPM_BUILD_ROOT install build-shared
+
+# Install the actual DLLs.
+install libcrypto-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
+install libssl-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
# Remove static libraries but DON'T remove *.dll.a files.
-rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libfoo.a
+rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.a
+rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.a
+
+# I have no idea why it installs the manpages in /etc, but
+# we remove them anyway.
+rm -r $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/man
+
+# Set permissions on lib*.dll.a so that strip works.
+chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.dll.a
+chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.dll.a
%clean
%files
%defattr(-,root,root)
-%{_mingw32_bindir}/foo.dll
-%{_mingw32_libdir}/foo.dll.a
-# etc.
+%{_mingw32_bindir}/openssl.exe
+%{_mingw32_bindir}/c_rehash
+%{_mingw32_bindir}/libcrypto-7.dll
+%{_mingw32_bindir}/libssl-7.dll
+%{_mingw32_libdir}/libcrypto.dll.a
+%{_mingw32_libdir}/libssl.dll.a
+%{_mingw32_libdir}/engines
+%{_mingw32_libdir}/pkgconfig/*.pc
+%{_mingw32_includedir}/openssl
+%config(noreplace) %{_mingw32_sysconfdir}/pki
%changelog
-* Wed Sep 24 2008 Your Name <you@example.com> - 1.2.3-1
+* Tue Sep 30 2008 Richard W.M. Jones <rjones@redhat.com> - 0.9.8g-1
- Initial RPM release.