Fix a couple of loops.
[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 # For the curious:
8 # 0.9.5a soversion = 0
9 # 0.9.6  soversion = 1
10 # 0.9.6a soversion = 2
11 # 0.9.6c soversion = 3
12 # 0.9.7a soversion = 4
13 # 0.9.7ef soversion = 5
14 # 0.9.8ab soversion = 6
15 # 0.9.8g soversion = 7
16 # 0.9.8j + EAP-FAST soversion = 8
17 %define soversion 8
18
19 # Enable the tests.
20 # These only work some of the time, but fail randomly at other times
21 # (although I have had them complete a few times, so I don't think
22 # there is any actual problem with the binaries).
23 %define run_tests 0
24
25 # Number of threads to spawn when testing some threading fixes.
26 %define thread_test_threads %{?threads:%{threads}}%{!?threads:1}
27
28 Name:           mingw32-openssl
29 Version:        0.9.8j
30 Release:        2%{?dist}
31 Summary:        MinGW port of the OpenSSL toolkit
32
33 License:        OpenSSL
34 Group:          Development/Libraries
35 URL:            http://www.openssl.org/
36
37 # Use the hobble-openssl script to create the source file.
38 Source0:        openssl-%{version}-usa.tar.bz2
39
40 Source1:        hobble-openssl
41 Source2:        Makefile.certificate
42 Source6:        make-dummy-cert
43 Source8:        openssl-thread-test.c
44 Source9:        opensslconf-new.h
45 Source10:       opensslconf-new-warning.h
46
47 # Patches from Fedora native package.
48 # Build changes
49 Patch0:         openssl-0.9.8j-redhat.patch
50 Patch1:         openssl-0.9.8a-defaults.patch
51 Patch2:         openssl-0.9.8a-link-krb5.patch
52 Patch3:         openssl-0.9.8j-soversion.patch
53 Patch4:         openssl-0.9.8j-enginesdir.patch
54 Patch5:         openssl-0.9.8a-no-rpath.patch
55 Patch6:         openssl-0.9.8b-test-use-localhost.patch
56 Patch7:         openssl-0.9.8j-shlib-version.patch
57 # Bug fixes
58 Patch21:        openssl-0.9.8b-aliasing-bug.patch
59 Patch22:        openssl-0.9.8b-x509-name-cmp.patch
60 Patch23:        openssl-0.9.8g-default-paths.patch
61 Patch24:        openssl-0.9.8g-no-extssl.patch
62 # Functionality changes
63 Patch32:        openssl-0.9.8g-ia64.patch
64 Patch33:        openssl-0.9.8j-ca-dir.patch
65 Patch34:        openssl-0.9.6-x509.patch
66 Patch35:        openssl-0.9.8j-version-add-engines.patch
67 Patch38:        openssl-0.9.8a-reuse-cipher-change.patch
68 # Disabled this because it uses getaddrinfo which is lacking on Windows.
69 #Patch39:        openssl-0.9.8g-ipv6-apps.patch
70 Patch40:        openssl-0.9.8j-nocanister.patch
71 Patch41:        openssl-0.9.8j-use-fipscheck.patch
72 Patch42:        openssl-0.9.8j-fipscheck-hmac.patch
73 Patch43:        openssl-0.9.8j-evp-nonfips.patch
74 Patch44:        openssl-0.9.8j-kernel-fipsmode.patch
75 Patch45:        openssl-0.9.8j-env-nozlib.patch
76 Patch46:        openssl-0.9.8j-eap-fast.patch
77 Patch47:        openssl-0.9.8j-readme-warning.patch
78 Patch48:        openssl-0.9.8j-bad-mime.patch
79 Patch49:        openssl-0.9.8j-fips-no-pairwise.patch
80 # Backported fixes including security fixes
81
82 # MinGW-specific patches.
83 Patch100:       mingw32-openssl-0.9.8j-header-files.patch
84 Patch101:       mingw32-openssl-0.9.8j-configure.patch
85 Patch102:       mingw32-openssl-0.9.8j-shared.patch
86 Patch103:       mingw32-openssl-0.9.8g-global.patch
87 Patch104:       mingw32-openssl-0.9.8g-sfx.patch
88
89 BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
90
91 BuildArch:      noarch
92
93 BuildRequires:  mingw32-filesystem >= 40
94 BuildRequires:  mingw32-gcc
95 BuildRequires:  mingw32-binutils
96
97 BuildRequires:  mingw32-zlib
98 BuildRequires:  mingw32-pthreads
99
100 BuildRequires:  mktemp
101 #BuildRequires:  krb5-devel
102 BuildRequires:  perl
103 BuildRequires:  sed
104 BuildRequires:  /usr/bin/cmp
105 BuildRequires:  /usr/bin/rename
106
107 # XXX Not really sure about this one.  The build script uses
108 # /usr/bin/makedepend which comes from imake.
109 BuildRequires:  imake
110
111 %if %{run_tests}
112 # Required both to build, and to run the tests.
113 # XXX This needs to be fixed - cross-compilation should not
114 # require running executables.
115 BuildRequires:  wine
116
117 # Required to run the tests.
118 BuildRequires:  xorg-x11-server-Xvfb
119 %endif
120
121 #Requires:       ca-certificates >= 2008-5
122 Requires:       pkgconfig
123
124
125 %description
126 The OpenSSL toolkit provides support for secure communications between
127 machines. OpenSSL includes a certificate management tool and shared
128 libraries which provide various cryptographic algorithms and
129 protocols.
130
131 This package contains Windows (MinGW) libraries and development tools.
132
133
134 %prep
135 %setup -q -n openssl-%{version}
136
137 %{SOURCE1} > /dev/null
138 %patch0 -p1 -b .redhat
139 %patch1 -p1 -b .defaults
140 # Fix link line for libssl (bug #111154).
141 %patch2 -p1 -b .krb5
142 %patch3 -p1 -b .soversion
143 %patch4 -p1 -b .enginesdir
144 %patch5 -p1 -b .no-rpath
145 %patch6 -p1 -b .use-localhost
146 %patch7 -p1 -b .shlib-version
147
148 %patch21 -p1 -b .aliasing-bug
149 %patch22 -p1 -b .name-cmp
150 %patch23 -p1 -b .default-paths
151 %patch24 -p1 -b .no-extssl
152
153 %patch32 -p1 -b .ia64
154 #patch33 is applied after make test
155 %patch34 -p1 -b .x509
156 %patch35 -p1 -b .version-add-engines
157 %patch38 -p1 -b .cipher-change
158 #%patch39 -p1 -b .ipv6-apps
159 %patch40 -p1 -b .nocanister
160 %patch41 -p1 -b .use-fipscheck
161 %patch42 -p1 -b .fipscheck-hmac
162 %patch43 -p1 -b .evp-nonfips
163 %patch44 -p1 -b .fipsmode
164 %patch45 -p1 -b .env-nozlib
165 %patch46 -p1 -b .eap-fast
166 %patch47 -p1 -b .warning
167 %patch48 -p1 -b .bad-mime
168 %patch49 -p1 -b .no-pairwise
169
170 %patch100 -p1 -b .mingw-header-files
171 %patch101 -p1 -b .mingw-configure
172 %patch102 -p1 -b .mingw-shared
173 %patch103 -p1 -b .mingw-global
174 %patch104 -p1 -b .mingw-sfx
175
176 # Modify the various perl scripts to reference perl in the right location.
177 perl util/perlpath.pl `dirname %{__perl}`
178
179 # Generate a table with the compile settings for my perusal.
180 touch Makefile
181 make TABLE PERL=%{__perl}
182
183 %build
184 # NB: 'no-hw' is vital.  MinGW cannot build the hardware drivers
185 # and if you don't have this you'll get an obscure link error.
186 %{_mingw32_env}; \
187 sed -i -e "s/MINGW32_CC/%{_mingw32_cc}/" -e "s/MINGW32_CFLAGS/%{_mingw32_cflags}/" -e "s/MINGW32_RANLIB/%{_mingw32_ranlib}/" Configure; \
188 ./Configure \
189   --prefix=%{_mingw32_prefix} \
190   --openssldir=%{_mingw32_sysconfdir}/pki/tls \
191   zlib enable-camellia enable-seed enable-tlsext enable-rfc3779 \
192   no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa no-hw shared \
193   --enginesdir=%{_mingw32_libdir}/openssl/engines \
194   mingw
195 #  --with-krb5-flavor=MIT
196 #  -I%{_mingw32_prefix}/kerberos/include -L%{_mingw32_prefix}/kerberos/%{_lib}
197 %{_mingw32_make} depend
198 %{_mingw32_make} all build-shared
199
200 # Generate hashes for the included certs.
201 %{_mingw32_make} rehash build-shared
202
203 %if %{run_tests}
204 #----------------------------------------------------------------------
205 # Run some tests.  I don't know why this isn't in a %-check section
206 # but this is how it is in the native RPM.
207
208 # This is a bit of a hack, but the test scripts look for 'openssl'
209 # by name.
210 pushd apps
211 ln -s openssl.exe openssl
212 popd
213
214 # This is useful for diagnosing Wine problems.
215 WINEDEBUG=+loaddll
216 export WINEDEBUG
217
218 # Make sure we can find the installed DLLs.
219 WINEDLLPATH=%{_mingw32_bindir}
220 export WINEDLLPATH
221
222 # The tests run Wine and require an X server (but don't really use
223 # it).  Therefore we create a virtual framebuffer for the duration of
224 # the tests.
225 # XXX There is no good way to choose a random, unused display.
226 # XXX Setting depth to 24 bits avoids bug 458219.
227 unset DISPLAY
228 display=:21
229 Xvfb $display -screen 0 1024x768x24 -ac -noreset & xpid=$!
230 trap "kill -TERM $xpid ||:" EXIT
231 sleep 3
232 DISPLAY=$display
233 export DISPLAY
234
235 %{_mingw32_make} LDCMD=%{_mingw32_cc} -C test apps tests
236
237 # Disable this thread test, because we don't have pthread on Windows.
238 %{_mingw32_cc} -o openssl-thread-test \
239   -I./include \
240   %-{_mingw32_cflags} \
241   %-{SOURCE8} \
242   -L. \
243   -lssl -lcrypto \
244   -lpthread -lz -ldl
245
246 ## `krb5-config --cflags`
247 ## `krb5-config --libs`
248 #
249 ./openssl-thread-test --threads %{thread_test_threads}
250
251 #----------------------------------------------------------------------
252 %endif
253
254 # Patch33 must be patched after tests otherwise they will fail
255 patch -p1 -b -z .ca-dir < %{PATCH33}
256
257 # Add generation of HMAC checksum of the final stripped library
258 #%define __spec_install_post \
259 #    %{?__debug_package:%{__debug_install_post}} \
260 #    %{__arch_install_post} \
261 #    %{__os_install_post} \
262 #    fips/fips_standalone_sha1 $RPM_BUILD_ROOT/%{_lib}/libcrypto.so.%{version} >$RPM_BUILD_ROOT/%{_lib}/.libcrypto.so.%{version}.hmac \
263 #    ln -sf .libcrypto.so.%{version}.hmac $RPM_BUILD_ROOT/%{_lib}/.libcrypto.so.%{soversion}.hmac \
264 #%{nil}
265
266 if ! iconv -f UTF-8 -t ASCII//TRANSLIT CHANGES >/dev/null 2>&1 ; then
267   iconv -f ISO-8859-1 -t UTF-8 -o CHANGES.utf8 CHANGES && \
268     mv -f CHANGES.utf8 CHANGES
269 fi
270
271
272 %install
273 rm -rf $RPM_BUILD_ROOT
274 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}
275 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}/openssl
276 mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
277 mkdir -p $RPM_BUILD_ROOT%{_mingw32_includedir}
278 mkdir -p $RPM_BUILD_ROOT%{_mingw32_mandir}
279 make INSTALL_PREFIX=$RPM_BUILD_ROOT install build-shared
280
281 # Install the actual DLLs.
282 install libcrypto-%{soversion}.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
283 install libssl-%{soversion}.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
284
285 # Remove static libraries but DON'T remove *.dll.a files.
286 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.a
287 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.a
288
289 # I have no idea why it installs the manpages in /etc, but
290 # we remove them anyway.
291 rm -r $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/man
292
293 # Set permissions on lib*.dll.a so that strip works.
294 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.dll.a
295 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.dll.a
296
297 # Install a makefile for generating keys and self-signed certs, and a script
298 # for generating them on the fly.
299 mkdir -p $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/certs
300 install -m644 %{SOURCE2} $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/certs/Makefile
301 install -m755 %{SOURCE6} $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/certs/make-dummy-cert
302
303 # Pick a CA script.
304 pushd  $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/misc
305 mv CA.sh CA
306 popd
307
308 mkdir -m700 $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/CA
309 mkdir -m700 $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/CA/private
310
311 %clean
312 rm -rf $RPM_BUILD_ROOT
313
314
315 %files
316 %defattr(-,root,root)
317 %doc LICENSE
318 %{_mingw32_bindir}/openssl.exe
319 %{_mingw32_bindir}/c_rehash
320 %{_mingw32_bindir}/libcrypto-%{soversion}.dll
321 %{_mingw32_bindir}/libssl-%{soversion}.dll
322 #{_mingw32_bindir}/.libcrypto*.hmac
323 %{_mingw32_libdir}/libcrypto.dll.a
324 %{_mingw32_libdir}/libssl.dll.a
325 %{_mingw32_libdir}/engines
326 %{_mingw32_libdir}/pkgconfig/*.pc
327 %{_mingw32_includedir}/openssl
328 %config(noreplace) %{_mingw32_sysconfdir}/pki
329
330
331 %changelog
332 * Mon Feb  2 2009 Levente Farkas <lfarkas@lfarkas.org> - 0.9.8j-2
333 - Various build fixes.
334
335 * Wed Jan 28 2009 Levente Farkas <lfarkas@lfarkas.org> - 0.9.8j-1
336 - update to new upstream version.
337
338 * Mon Dec 29 2008 Levente Farkas <lfarkas@lfarkas.org> - 0.9.8g-2
339 - minor cleanup.
340
341 * Tue Sep 30 2008 Richard W.M. Jones <rjones@redhat.com> - 0.9.8g-1
342 - Initial RPM release.