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