e5a1d8a2b745a22a88f6ecb9b40a31f1b1c52689
[fedora-mingw.git] / openssl / mingw32-openssl.spec
1 %define __strip %{_mingw32_strip}
2 %define __objdump %{_mingw32_objdump}
3 %define _use_internal_dependency_generator 0
4 %define __find_requires %{_mingw32_findrequires}
5 %define __find_provides %{_mingw32_findprovides}
6
7 # Enable the tests.
8 # These only work some of the time, but fail randomly at other times
9 # (although I have had them complete a few times, so I don't think
10 # there is any actual problem with the binaries).
11 %define with_tests 0
12
13 Name:           mingw32-openssl
14 Version:        0.9.8g
15 Release:        1%{?dist}
16 Summary:        MinGW port of the OpenSSL toolkit
17
18 License:        OpenSSL
19 Group:          Development/Libraries
20 URL:            http://www.openssl.org/
21
22 # Use the hobble-openssl script to create the source file.
23 Source0:        openssl-%{version}-usa.tar.bz2
24
25 Source1:        hobble-openssl
26 Source2:        Makefile.certificate
27 Source6:        make-dummy-cert
28 Source8:        openssl-thread-test.c
29 Source9:        opensslconf-new.h
30 Source10:       opensslconf-new-warning.h
31
32 # Patches from Fedora native package.
33 Patch0:         openssl-0.9.8g-redhat.patch
34 Patch1:         openssl-0.9.8a-defaults.patch
35 Patch2:         openssl-0.9.8a-link-krb5.patch
36 Patch3:         openssl-0.9.8g-soversion.patch
37 Patch4:         openssl-0.9.8a-enginesdir.patch
38 Patch5:         openssl-0.9.8a-no-rpath.patch
39 Patch6:         openssl-0.9.8b-test-use-localhost.patch
40 Patch7:         openssl-0.9.8g-shlib-version.patch
41 Patch21:        openssl-0.9.8b-aliasing-bug.patch
42 Patch22:        openssl-0.9.8b-x509-name-cmp.patch
43 Patch23:        openssl-0.9.8g-default-paths.patch
44 Patch24:        openssl-0.9.8g-no-extssl.patch
45 Patch32:        openssl-0.9.8g-ia64.patch
46 Patch33:        openssl-0.9.7f-ca-dir.patch
47 Patch34:        openssl-0.9.6-x509.patch
48 Patch35:        openssl-0.9.7-beta5-version-add-engines.patch
49 Patch38:        openssl-0.9.8a-reuse-cipher-change.patch
50 # Disabled this because it uses getaddrinfo which is lacking on Windows.
51 #Patch39:        openssl-0.9.8g-ipv6-apps.patch
52 Patch50:        openssl-0.9.8g-speed-bug.patch
53 Patch51:        openssl-0.9.8g-bn-mul-bug.patch
54 Patch52:        openssl-0.9.8g-cve-2008-0891.patch
55 Patch53:        openssl-0.9.8g-cve-2008-1671.patch
56
57 # MinGW-specific patches.
58 Patch100:       mingw32-openssl-0.9.8g-header-files.patch
59 Patch101:       mingw32-openssl-0.9.8g-configure.patch
60 Patch102:       mingw32-openssl-0.9.8g-shared.patch
61 Patch103:       mingw32-openssl-0.9.8g-global.patch
62 Patch104:       mingw32-openssl-0.9.8g-sfx.patch
63
64 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
65
66 BuildArch:      noarch
67
68 BuildRequires:  mingw32-filesystem >= 26
69 BuildRequires:  mingw32-gcc
70 BuildRequires:  mingw32-binutils
71
72 BuildRequires:  mingw32-zlib
73
74 BuildRequires:  mktemp
75 #BuildRequires:  krb5-devel
76 BuildRequires:  perl
77 BuildRequires:  sed
78 BuildRequires:  /usr/bin/cmp
79 BuildRequires:  /usr/bin/rename
80
81 # Required both to build, and to run the tests.
82 BuildRequires:  wine
83
84 %if %{with_tests}
85 # Required to run the tests.
86 BuildRequires:  xorg-x11-server-Xvfb
87 %endif
88
89 #Requires:       ca-certificates >= 2008-5
90 Requires:       pkgconfig
91
92
93 %description
94 The OpenSSL toolkit provides support for secure communications between
95 machines. OpenSSL includes a certificate management tool and shared
96 libraries which provide various cryptographic algorithms and
97 protocols.
98
99 This package contains Windows (MinGW) libraries and development tools.
100
101
102 %prep
103 %setup -q -n openssl-%{version}
104
105 %{SOURCE1} > /dev/null
106 %patch0 -p1 -b .redhat
107 %patch1 -p1 -b .defaults
108 # Fix link line for libssl (bug #111154).
109 %patch2 -p1 -b .krb5
110 %patch3 -p1 -b .soversion
111 %patch4 -p1 -b .enginesdir
112 %patch5 -p1 -b .no-rpath
113 %patch6 -p1 -b .use-localhost
114 %patch7 -p1 -b .shlib-version
115
116 %patch21 -p1 -b .aliasing-bug
117 %patch22 -p1 -b .name-cmp
118 %patch23 -p1 -b .default-paths
119 %patch24 -p1 -b .no-extssl
120
121 %patch32 -p1 -b .ia64
122 #patch33 is applied after make test
123 %patch34 -p1 -b .x509
124 %patch35 -p1 -b .version-add-engines
125 %patch38 -p1 -b .cipher-change
126 #%patch39 -p1 -b .ipv6-apps
127 %patch50 -p1 -b .speed-bug
128 %patch51 -p1 -b .bn-mul-bug
129 %patch52 -p0 -b .srvname-crash
130 %patch53 -p0 -b .srv-kex-crash
131
132 %patch100 -p1 -b .mingw-header-files
133 %patch101 -p1 -b .mingw-configure
134 %patch102 -p1 -b .mingw-shared
135 %patch103 -p1 -b .mingw-global
136 %patch104 -p1 -b .mingw-sfx
137
138 # Modify the various perl scripts to reference perl in the right location.
139 perl util/perlpath.pl `dirname %{__perl}`
140
141 # Generate a table with the compile settings for my perusal.
142 touch Makefile
143 make TABLE PERL=%{__perl}
144
145
146 %build
147
148 cat > gcc <<EOS
149 #!/bin/sh -
150 %{_bindir}/i686-pc-mingw32-gcc -m32 "$@"
151 EOS
152 export PATH=.:$PATH
153
154 # NB: 'no-hw' is vital.  MinGW cannot build the hardware drivers
155 # and if you don't have this you'll get an obscure link error.
156 ./Configure \
157   --prefix=%{_mingw32_prefix} \
158   --openssldir=%{_mingw32_sysconfdir}/pki/tls \
159   zlib enable-camellia enable-seed enable-tlsext enable-rfc3779 \
160   no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa no-hw shared \
161   --enginesdir=%{_mingw32_libdir}/openssl/engines \
162   mingw
163 #  --with-krb5-flavor=MIT
164 #  -I%{_mingw32_prefix}/kerberos/include -L%{_mingw32_prefix}/kerberos/%{_lib}
165 make depend
166 make all build-shared
167 make rehash build-shared
168
169 %if %{with_tests}
170 #----------------------------------------------------------------------
171 # Run some tests.  I don't know why this isn't in a %-check section
172 # but this is how it is in the native RPM.
173
174 # This is a bit of a hack, but the test scripts look for 'openssl'
175 # by name.
176 pushd apps
177 ln -s openssl.exe openssl
178 popd
179
180 # This is useful for diagnosing Wine problems.
181 WINEDEBUG=+loaddll
182 export WINEDEBUG
183
184 # Make sure we can find the installed DLLs.
185 WINEDLLPATH=%{_mingw32_bindir}
186 export WINEDLLPATH
187
188 # The tests run Wine and require an X server (but don't really use
189 # it).  Therefore we create a virtual framebuffer for the duration of
190 # the tests.
191 # XXX There is no good way to choose a random, unused display.
192 unset DISPLAY
193 display=:21
194 Xvfb $display -ac -noreset & xpid=$!
195 trap "kill -TERM $xpid ||:" EXIT
196 sleep 3
197 DISPLAY=$display
198 export DISPLAY
199
200 make LDCMD=%{_mingw32_cc} -C test apps tests
201
202 # Disable this thread test, because we don't have pthread on Windows.
203 #%-{_mingw32_cc} -o openssl-thread-test \
204 #  -I./include \
205 #  %-{_mingw32_cflags} \
206 #  %-{SOURCE8} \
207 #  -L. \
208 #  -lssl -lcrypto \
209 #  -lpthread -lz -ldl
210 #
211 ## `krb5-config --cflags`
212 ## `krb5-config --libs`
213 #
214 #./openssl-thread-test --threads %{thread_test_threads}
215
216 #----------------------------------------------------------------------
217 %endif
218
219 # Patch33 must be patched after tests otherwise they will fail
220 patch -p1 -b -z .ca-dir < %{PATCH33}
221
222 if ! iconv -f UTF-8 -t ASCII//TRANSLIT CHANGES >/dev/null 2>&1 ; then
223   iconv -f ISO-8859-1 -t UTF-8 -o CHANGES.utf8 CHANGES && \
224     mv -f CHANGES.utf8 CHANGES
225 fi
226
227
228 %install
229 rm -rf $RPM_BUILD_ROOT
230 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}
231 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}/openssl
232 mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
233 mkdir -p $RPM_BUILD_ROOT%{_mingw32_includedir}
234 mkdir -p $RPM_BUILD_ROOT%{_mingw32_mandir}
235 make INSTALL_PREFIX=$RPM_BUILD_ROOT install build-shared
236
237 # Install the actual DLLs.
238 install libcrypto-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
239 install libssl-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
240
241 # Remove static libraries but DON'T remove *.dll.a files.
242 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.a
243 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.a
244
245 # I have no idea why it installs the manpages in /etc, but
246 # we remove them anyway.
247 rm -r $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/man
248
249 # Set permissions on lib*.dll.a so that strip works.
250 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.dll.a
251 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.dll.a
252
253
254 %clean
255 rm -rf $RPM_BUILD_ROOT
256
257
258 %files
259 %defattr(-,root,root)
260 %{_mingw32_bindir}/openssl.exe
261 %{_mingw32_bindir}/c_rehash
262 %{_mingw32_bindir}/libcrypto-7.dll
263 %{_mingw32_bindir}/libssl-7.dll
264 %{_mingw32_libdir}/libcrypto.dll.a
265 %{_mingw32_libdir}/libssl.dll.a
266 %{_mingw32_libdir}/engines
267 %{_mingw32_libdir}/pkgconfig/*.pc
268 %{_mingw32_includedir}/openssl
269 %config(noreplace) %{_mingw32_sysconfdir}/pki
270
271
272 %changelog
273 * Tue Sep 30 2008 Richard W.M. Jones <rjones@redhat.com> - 0.9.8g-1
274 - Initial RPM release.