8f0fc687bd23b7f03e18d56bcbb2c86c684833b0
[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 # XXX Not really sure about this one.  The build script uses
82 # /usr/bin/makedepend which comes from imake.
83 BuildRequires:  imake
84
85 # Required both to build, and to run the tests.
86 BuildRequires:  wine
87
88 %if %{with_tests}
89 # Required to run the tests.
90 BuildRequires:  xorg-x11-server-Xvfb
91 %endif
92
93 #Requires:       ca-certificates >= 2008-5
94 Requires:       pkgconfig
95
96
97 %description
98 The OpenSSL toolkit provides support for secure communications between
99 machines. OpenSSL includes a certificate management tool and shared
100 libraries which provide various cryptographic algorithms and
101 protocols.
102
103 This package contains Windows (MinGW) libraries and development tools.
104
105
106 %prep
107 %setup -q -n openssl-%{version}
108
109 %{SOURCE1} > /dev/null
110 %patch0 -p1 -b .redhat
111 %patch1 -p1 -b .defaults
112 # Fix link line for libssl (bug #111154).
113 %patch2 -p1 -b .krb5
114 %patch3 -p1 -b .soversion
115 %patch4 -p1 -b .enginesdir
116 %patch5 -p1 -b .no-rpath
117 %patch6 -p1 -b .use-localhost
118 %patch7 -p1 -b .shlib-version
119
120 %patch21 -p1 -b .aliasing-bug
121 %patch22 -p1 -b .name-cmp
122 %patch23 -p1 -b .default-paths
123 %patch24 -p1 -b .no-extssl
124
125 %patch32 -p1 -b .ia64
126 #patch33 is applied after make test
127 %patch34 -p1 -b .x509
128 %patch35 -p1 -b .version-add-engines
129 %patch38 -p1 -b .cipher-change
130 #%patch39 -p1 -b .ipv6-apps
131 %patch50 -p1 -b .speed-bug
132 %patch51 -p1 -b .bn-mul-bug
133 %patch52 -p0 -b .srvname-crash
134 %patch53 -p0 -b .srv-kex-crash
135
136 %patch100 -p1 -b .mingw-header-files
137 %patch101 -p1 -b .mingw-configure
138 %patch102 -p1 -b .mingw-shared
139 %patch103 -p1 -b .mingw-global
140 %patch104 -p1 -b .mingw-sfx
141
142 # Modify the various perl scripts to reference perl in the right location.
143 perl util/perlpath.pl `dirname %{__perl}`
144
145 # Generate a table with the compile settings for my perusal.
146 touch Makefile
147 make TABLE PERL=%{__perl}
148
149
150 %build
151
152 cat > gcc <<EOS
153 #!/bin/sh -
154 %{_bindir}/i686-pc-mingw32-gcc -m32 "$@"
155 EOS
156 export PATH=.:$PATH
157
158 # NB: 'no-hw' is vital.  MinGW cannot build the hardware drivers
159 # and if you don't have this you'll get an obscure link error.
160 ./Configure \
161   --prefix=%{_mingw32_prefix} \
162   --openssldir=%{_mingw32_sysconfdir}/pki/tls \
163   zlib enable-camellia enable-seed enable-tlsext enable-rfc3779 \
164   no-idea no-mdc2 no-rc5 no-ec no-ecdh no-ecdsa no-hw shared \
165   --enginesdir=%{_mingw32_libdir}/openssl/engines \
166   mingw
167 #  --with-krb5-flavor=MIT
168 #  -I%{_mingw32_prefix}/kerberos/include -L%{_mingw32_prefix}/kerberos/%{_lib}
169 make depend
170 make all build-shared
171 make rehash build-shared
172
173 %if %{with_tests}
174 #----------------------------------------------------------------------
175 # Run some tests.  I don't know why this isn't in a %-check section
176 # but this is how it is in the native RPM.
177
178 # This is a bit of a hack, but the test scripts look for 'openssl'
179 # by name.
180 pushd apps
181 ln -s openssl.exe openssl
182 popd
183
184 # This is useful for diagnosing Wine problems.
185 WINEDEBUG=+loaddll
186 export WINEDEBUG
187
188 # Make sure we can find the installed DLLs.
189 WINEDLLPATH=%{_mingw32_bindir}
190 export WINEDLLPATH
191
192 # The tests run Wine and require an X server (but don't really use
193 # it).  Therefore we create a virtual framebuffer for the duration of
194 # the tests.
195 # XXX There is no good way to choose a random, unused display.
196 unset DISPLAY
197 display=:21
198 Xvfb $display -ac -noreset & xpid=$!
199 trap "kill -TERM $xpid ||:" EXIT
200 sleep 3
201 DISPLAY=$display
202 export DISPLAY
203
204 make LDCMD=%{_mingw32_cc} -C test apps tests
205
206 # Disable this thread test, because we don't have pthread on Windows.
207 #%-{_mingw32_cc} -o openssl-thread-test \
208 #  -I./include \
209 #  %-{_mingw32_cflags} \
210 #  %-{SOURCE8} \
211 #  -L. \
212 #  -lssl -lcrypto \
213 #  -lpthread -lz -ldl
214 #
215 ## `krb5-config --cflags`
216 ## `krb5-config --libs`
217 #
218 #./openssl-thread-test --threads %{thread_test_threads}
219
220 #----------------------------------------------------------------------
221 %endif
222
223 # Patch33 must be patched after tests otherwise they will fail
224 patch -p1 -b -z .ca-dir < %{PATCH33}
225
226 if ! iconv -f UTF-8 -t ASCII//TRANSLIT CHANGES >/dev/null 2>&1 ; then
227   iconv -f ISO-8859-1 -t UTF-8 -o CHANGES.utf8 CHANGES && \
228     mv -f CHANGES.utf8 CHANGES
229 fi
230
231
232 %install
233 rm -rf $RPM_BUILD_ROOT
234 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}
235 mkdir -p $RPM_BUILD_ROOT%{_mingw32_libdir}/openssl
236 mkdir -p $RPM_BUILD_ROOT%{_mingw32_bindir}
237 mkdir -p $RPM_BUILD_ROOT%{_mingw32_includedir}
238 mkdir -p $RPM_BUILD_ROOT%{_mingw32_mandir}
239 make INSTALL_PREFIX=$RPM_BUILD_ROOT install build-shared
240
241 # Install the actual DLLs.
242 install libcrypto-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
243 install libssl-7.dll $RPM_BUILD_ROOT%{_mingw32_bindir}
244
245 # Remove static libraries but DON'T remove *.dll.a files.
246 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.a
247 rm $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.a
248
249 # I have no idea why it installs the manpages in /etc, but
250 # we remove them anyway.
251 rm -r $RPM_BUILD_ROOT%{_mingw32_sysconfdir}/pki/tls/man
252
253 # Set permissions on lib*.dll.a so that strip works.
254 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libcrypto.dll.a
255 chmod 0755 $RPM_BUILD_ROOT%{_mingw32_libdir}/libssl.dll.a
256
257
258 %clean
259 rm -rf $RPM_BUILD_ROOT
260
261
262 %files
263 %defattr(-,root,root)
264 %{_mingw32_bindir}/openssl.exe
265 %{_mingw32_bindir}/c_rehash
266 %{_mingw32_bindir}/libcrypto-7.dll
267 %{_mingw32_bindir}/libssl-7.dll
268 %{_mingw32_libdir}/libcrypto.dll.a
269 %{_mingw32_libdir}/libssl.dll.a
270 %{_mingw32_libdir}/engines
271 %{_mingw32_libdir}/pkgconfig/*.pc
272 %{_mingw32_includedir}/openssl
273 %config(noreplace) %{_mingw32_sysconfdir}/pki
274
275
276 %changelog
277 * Tue Sep 30 2008 Richard W.M. Jones <rjones@redhat.com> - 0.9.8g-1
278 - Initial RPM release.