fix build error
[platform/upstream/openblas.git] / packaging / openblas.spec
1 Name:           openblas
2 Version:        0.3.7
3 Release:        1
4 Summary:        An optimized BLAS library based on GotoBLAS2
5 License:        BSD-3-Clause and MIT and Apache-2.0
6 Group:          Productivity/Scientific/Math
7 Url:            http://www.openblas.net
8 Source0:        %{name}-%{version}.tar.gz
9 Source1001:     %{name}.manifest
10 BuildRequires:  gcc-fortran
11 BuildRequires:  update-alternatives
12 BuildRequires:  sed
13 Requires(post): update-alternatives
14 Requires(preun): update-alternatives
15
16 %description
17 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
18
19 %package     -n lib%{name}_serial0
20 Summary:        An optimized BLAS library based on GotoBLAS2, serial version
21 Group:          System/Libraries
22 Requires(post): update-alternatives
23 Requires(preun): update-alternatives
24 Obsoletes:      lib%{name}0 < %{version}
25 Provides:       lib%{name}0 = %{version}
26
27 %description -n lib%{name}_serial0
28 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
29
30 %package     -n lib%{name}_serial-devel
31 Summary:        Development libraries for OpenBLAS, serial version
32 Group:          Development/Libraries/C and C++
33 Requires:       %{name}-devel-headers = %{version}
34 Requires:       lib%{name}_serial0 = %{version}
35
36 %description -n lib%{name}_serial-devel
37 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
38
39 This package contains the development libraries for serial OpenBLAS version.
40
41 %package     -n lib%{name}_openmp0
42 Summary:        An optimized BLAS library based on GotoBLAS2, OpenMP version
43 Group:          System/Libraries
44 Requires(post): update-alternatives
45 Requires(preun): update-alternatives
46 Obsoletes:      lib%{name}0
47 Obsoletes:      lib%{name}o0
48
49 %description -n lib%{name}_openmp0
50 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
51
52 This package contains the library compiled with OpenMP support.
53
54 %package     -n lib%{name}_openmp-devel
55 Summary:        Development libraries for OpenBLAS, OpenMP version
56 Group:          Development/Libraries/C and C++
57 Requires:       %{name}-devel-headers = %{version}
58 Requires:       lib%{name}_openmp0 = %{version}
59
60 %description -n lib%{name}_openmp-devel
61 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
62
63 This package contains the development libraries for OpenMP OpenBLAS version.
64
65 %package     -n lib%{name}_pthreads0
66 Summary:        An optimized BLAS library based on GotoBLAS2, pthreads version
67 Group:          System/Libraries
68 Requires(post): update-alternatives
69 Requires(preun): update-alternatives
70 Obsoletes:      lib%{name}0
71 Obsoletes:      lib%{name}p0
72
73 %description -n lib%{name}_pthreads0
74 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
75
76 This package contains the library compiled with threading support.
77
78 %package     -n lib%{name}_pthreads-devel
79 Summary:        Development headers and libraries for OpenBLAS, pthreads version
80 Group:          Development/Libraries/C and C++
81 Requires:       %{name}-devel-headers = %{version}
82 Requires:       lib%{name}_pthreads0 = %{version}
83
84 %description -n lib%{name}_pthreads-devel
85 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
86
87 This package contains the development libraries for pthreads OpenBLAS version.
88
89 %package        devel
90 Summary:        Development headers and libraries for OpenBLAS
91 Group:          Development/Libraries/C and C++
92 Requires:       %{name}-devel-headers = %{version}
93 %ifarch %ix86 x86_64
94 Requires:       lib%{name}_pthreads-devel = %{version}
95 %else
96 Requires:       lib%{name}_openmp-devel = %{version}
97 %endif
98
99 %description    devel
100 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
101
102 This package contains the development libraries and headers for OpenBLAS.
103
104 %package        devel-headers
105 Summary:        Development headers for OpenBLAS
106 Group:          Development/Libraries/C and C++
107 Conflicts:      %{name}-devel < %{version}
108
109 %description    devel-headers
110 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
111
112 This package contains headers for OpenBLAS.
113
114 %package        devel-static
115 Summary:        Static version of OpenBLAS
116 Group:          Development/Libraries/C and C++
117 Requires:       %{name}-devel = %{version}
118
119 %description    devel-static
120 OpenBLAS is an optimized BLAS library based on GotoBLAS2 1.13 BSD version.
121
122 This package contains the static libraries.
123
124 %prep
125 %setup -q
126 cp %{SOURCE1001} .
127
128 %ifarch %arm aarch64
129 # Disable utest if armv7l; Tizen-qemu-armv7l does not support syscall 319
130 sed -i "s|ctest utest|ctest|" Makefile
131 sed -i "s|tests shared|shared|" Makefile
132 %endif
133
134 cd ..
135 # Prepare build for serial, pthreads and OpenMP versions
136 cp -ar %{name}-%{version} openmp
137 cp -ar %{name}-%{version} pthreads
138 cp -ar %{name}-%{version} serial
139 #mv %{name}-%{version} serial
140
141 # cp %{SOURCE1} .
142
143 %build
144 %if 0%{?asan}
145 export EXTRALIB+="-lasan"
146 %endif
147
148 export LDFLAGS+="-Wl,-z,noexecstack"
149
150 # Only x86/x86-64 CPUs support DYNAMIC_ARCH
151 %ifarch %ix86 x86_64
152 %define openblas_target DYNAMIC_ARCH=1 TARGET=NEHALEM
153 %endif
154 %ifarch armv7l
155 %define openblas_target TARGET=ARMV7 ARM_SOFTFP_ABI=1
156 %endif
157 %ifarch armv7hl
158 %define openblas_target TARGET=ARMV7
159 %endif
160 %ifarch aarch64
161 %define openblas_target TARGET=ARMV8
162 %endif
163
164 cd ..
165 # Make serial, threaded and OpenMP versions
166 make -C serial %{?_smp_mflags} %{?openblas_target} USE_THREAD=0 USE_OPENMP=0 LIBNAMESUFFIX=serial \
167         FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=64 V=1
168 make -C openmp %{?_smp_mflags} %{?openblas_target} USE_THREAD=1 USE_OPENMP=1 LIBNAMESUFFIX=openmp \
169         FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=64 V=1
170 make -C pthreads %{?_smp_mflags} %{?openblas_target} USE_THREAD=1 USE_OPENMP=0 LIBNAMESUFFIX=pthreads \
171         FC=gfortran CC=gcc COMMON_OPT="%{optflags}" NUM_THREADS=64 V=1
172
173 %install
174 cd ..
175 # Install serial library and headers
176 make -C serial USE_THREAD=0 LIBNAMESUFFIX=serial \
177         OPENBLAS_LIBRARY_DIR=%{buildroot}%{_libdir} \
178         OPENBLAS_INCLUDE_DIR=%{buildroot}%{_includedir}/%{name} \
179         OPENBLAS_CMAKE_DIR=%{buildroot}%{_libdir}/cmake/%{name} \
180         PREFIX=%{buildroot}%{_prefix} install
181
182 # Put libraries in correct location
183 rm -rf %{buildroot}%{_libdir}/lib%{name}*
184
185 # Install the serial library
186 install -D -p -m 755 serial/lib%{name}_serial.so %{buildroot}%{_libdir}/lib%{name}_serial.so.0
187 install -D -p -m 644 serial/lib%{name}_serial.a %{buildroot}%{_libdir}/lib%{name}_serial.a
188
189 # Install the OpenMP library
190 install -D -p -m 755 openmp/lib%{name}_openmp.so %{buildroot}%{_libdir}/lib%{name}_openmp.so.0
191 install -D -p -m 644 openmp/lib%{name}_openmp.a %{buildroot}%{_libdir}/lib%{name}_openmp.a
192
193 # Install the threaded library
194 install -D -p -m 755 pthreads/lib%{name}_pthreads.so %{buildroot}%{_libdir}/lib%{name}_pthreads.so.0
195 install -D -p -m 644 pthreads/lib%{name}_pthreads.a %{buildroot}%{_libdir}/lib%{name}_pthreads.a
196
197 # Fix source permissions (also applies to LAPACK)
198 find -name \*.f -exec chmod 644 {} +
199
200 # Remove pkgconfig file, it can't be configured for different library suffixes we use and, as such, is useless
201 #rm -fr %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
202 sed -i  "s|%{buildroot}||g" %{buildroot}%{_libdir}/pkgconfig/%{name}.pc
203
204 # Dummy target for update-alternatives
205 install -d %{buildroot}/%{_sysconfdir}/alternatives
206 ln -s lib%{name}.so.0 %{buildroot}/%{_libdir}/lib%{name}.so.0
207 ln -s lib%{name}.so.0 %{buildroot}/%{_sysconfdir}/alternatives/lib%{name}.so.0
208 ln -s lib%{name}.so.0 %{buildroot}/%{_libdir}/libblas.so.3
209 ln -s lib%{name}.so.0 %{buildroot}/%{_libdir}/libcblas.so.3
210 ln -s lib%{name}.so.0 %{buildroot}/%{_libdir}/liblapack.so.3
211 ln -s lib%{name}.so.0 %{buildroot}/%{_sysconfdir}/alternatives/libblas.so.3
212 ln -s lib%{name}.so.0 %{buildroot}/%{_sysconfdir}/alternatives/libcblas.so.3
213 ln -s lib%{name}.so.0 %{buildroot}/%{_sysconfdir}/alternatives/liblapack.so.3
214
215 # Fix symlinks
216 pushd %{buildroot}%{_libdir}
217 ln -sf lib%{name}.so.0 lib%{name}.so
218 # Serial libraries
219 ln -sf lib%{name}_serial.so.0 lib%{name}_serial.so
220 # OpenMP libraries
221 ln -sf lib%{name}_openmp.so.0 lib%{name}_openmp.so
222 # Threaded libraries
223 ln -sf lib%{name}_pthreads.so.0 lib%{name}_pthreads.so
224
225 rm -rf %{buildroot}%{_libdir}/cmake
226
227 # Fix cmake config file
228 # sed -i 's|%{buildroot}||g' %{buildroot}%{_libdir}/cmake/%{name}/*.cmake
229
230 # Delete info about OBS host cpu
231 %ifarch %ix86 x86_64
232 sed -i '/#define OPENBLAS_NEEDBUNDERSCORE/,/#define OPENBLAS_VERSION/{//!d}' %{buildroot}%{_includedir}/%{name}/openblas_config.h
233 %endif
234
235 %post -n lib%{name}_serial0
236 %{_sbindir}/update-alternatives --install \
237    %{_libdir}/libblas.so.3 libblas.so.3 %{_libdir}/lib%{name}_serial.so.0  20
238 %{_sbindir}/update-alternatives --install \
239    %{_libdir}/libcblas.so.3 libcblas.so.3 %{_libdir}/lib%{name}_serial.so.0  20
240 %{_sbindir}/update-alternatives --install \
241    %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/lib%{name}_serial.so.0  20
242 %{_sbindir}/update-alternatives --install \
243    %{_libdir}/lib%{name}.so.0 lib%{name}.so.0 %{_libdir}/lib%{name}_serial.so.0  20
244 /sbin/ldconfig
245
246 %preun -n lib%{name}_serial0
247 if [ "$1" = 0 ] ; then
248    %{_sbindir}/update-alternatives --remove libblas.so.3 %{_libdir}/lib%{name}_serial.so.0
249    %{_sbindir}/update-alternatives --remove libcblas.so.3 %{_libdir}/lib%{name}_serial.so.0
250    %{_sbindir}/update-alternatives --remove liblapack.so.3 %{_libdir}/lib%{name}_serial.so.0
251    %{_sbindir}/update-alternatives --remove lib%{name}.so.0 %{_libdir}/lib%{name}_serial.so.0
252 fi
253
254 %postun -n lib%{name}_serial0 -p /sbin/ldconfig
255
256 %posttrans -n lib%{name}_serial0
257 if [ "$1" = 0 ] ; then
258   if ! [ -f %{_libdir}/lib%{name}.so.0 ] ; then
259       %{_sbindir}/update-alternatives --auto lib%{name}.so.0
260   fi
261 fi
262
263 %post -n lib%{name}_openmp0
264 %{_sbindir}/update-alternatives --install \
265    %{_libdir}/libblas.so.3 libblas.so.3 %{_libdir}/lib%{name}_openmp.so.0  20
266 %{_sbindir}/update-alternatives --install \
267    %{_libdir}/libcblas.so.3 libcblas.so.3 %{_libdir}/lib%{name}_openmp.so.0  20
268 %{_sbindir}/update-alternatives --install \
269    %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/lib%{name}_openmp.so.0  20
270 %{_sbindir}/update-alternatives --install \
271 %ifarch %ix86 x86_64
272    %{_libdir}/lib%{name}.so.0 lib%{name}.so.0 %{_libdir}/lib%{name}_openmp.so.0  20
273 %else
274    %{_libdir}/lib%{name}.so.0 lib%{name}.so.0 %{_libdir}/lib%{name}_openmp.so.0  50
275 %endif
276 /sbin/ldconfig
277
278 %preun -n lib%{name}_openmp0
279 if [ "$1" = 0 ] ; then
280    %{_sbindir}/update-alternatives --remove libblas.so.3 %{_libdir}/lib%{name}_openmp.so.0
281    %{_sbindir}/update-alternatives --remove libcblas.so.3 %{_libdir}/lib%{name}_openmp.so.0
282    %{_sbindir}/update-alternatives --remove liblapack.so.3 %{_libdir}/lib%{name}_openmp.so.0
283    %{_sbindir}/update-alternatives --remove lib%{name}.so.0 %{_libdir}/lib%{name}_openmp.so.0
284 fi
285
286 %postun -n lib%{name}_openmp0 -p /sbin/ldconfig
287
288 %posttrans -n lib%{name}_openmp0
289 if [ "$1" = 0 ] ; then
290   if ! [ -f %{_libdir}/lib%{name}.so.0 ] ; then
291       %{_sbindir}/update-alternatives --auto lib%{name}.so.0
292   fi
293 fi
294
295 %post -n lib%{name}_pthreads0
296 %{_sbindir}/update-alternatives --install \
297    %{_libdir}/libblas.so.3 libblas.so.3 %{_libdir}/lib%{name}_pthreads.so.0  20
298 %{_sbindir}/update-alternatives --install \
299    %{_libdir}/libcblas.so.3 libcblas.so.3 %{_libdir}/lib%{name}_pthreads.so.0  20
300 %{_sbindir}/update-alternatives --install \
301    %{_libdir}/liblapack.so.3 liblapack.so.3 %{_libdir}/lib%{name}_pthreads.so.0  20
302 %{_sbindir}/update-alternatives --install \
303 %ifarch %ix86 x86_64
304    %{_libdir}/lib%{name}.so.0 lib%{name}.so.0 %{_libdir}/lib%{name}_pthreads.so.0  50
305 %else
306    %{_libdir}/lib%{name}.so.0 lib%{name}.so.0 %{_libdir}/lib%{name}_pthreads.so.0  20
307 %endif
308 /sbin/ldconfig
309
310 %preun -n lib%{name}_pthreads0
311 if [ "$1" = 0 ] ; then
312    %{_sbindir}/update-alternatives --remove libblas.so.3 %{_libdir}/lib%{name}_pthreads.so.0
313    %{_sbindir}/update-alternatives --remove libcblas.so.3 %{_libdir}/lib%{name}_pthreads.so.0
314    %{_sbindir}/update-alternatives --remove liblapack.so.3 %{_libdir}/lib%{name}_pthreads.so.0
315    %{_sbindir}/update-alternatives --remove lib%{name}.so.0 %{_libdir}/lib%{name}_pthreads.so.0
316 fi
317
318 %postun -n lib%{name}_pthreads0 -p /sbin/ldconfig
319
320 %posttrans -n lib%{name}_pthreads0
321 if [ "$1" = 0 ] ; then
322   if ! [ -f %{_libdir}/lib%{name}.so.0 ] ; then
323       %{_sbindir}/update-alternatives --auto lib%{name}.so.0
324   fi
325 fi
326
327 %files -n lib%{name}_serial0
328 %manifest %{name}.manifest
329 %defattr(-,root,root,-)
330 %{_libdir}/lib%{name}_serial.so.0
331 %ghost %{_libdir}/lib%{name}.so.0
332 %ghost %{_libdir}/libblas.so.3
333 %ghost %{_libdir}/libcblas.so.3
334 %ghost %{_libdir}/liblapack.so.3
335 %ghost %{_sysconfdir}/alternatives/lib%{name}.so.0
336 %ghost %{_sysconfdir}/alternatives/libblas.so.3
337 %ghost %{_sysconfdir}/alternatives/libcblas.so.3
338 %ghost %{_sysconfdir}/alternatives/liblapack.so.3
339
340 %files -n lib%{name}_serial-devel
341 %defattr(-,root,root,-)
342 %{_libdir}/lib%{name}_serial.so
343
344 %files -n lib%{name}_openmp0
345 %manifest %{name}.manifest
346 %defattr(-,root,root,-)
347 %{_libdir}/lib%{name}_openmp.so.0
348 %ghost %{_libdir}/lib%{name}.so.0
349 %ghost %{_libdir}/libblas.so.3
350 %ghost %{_libdir}/libcblas.so.3
351 %ghost %{_libdir}/liblapack.so.3
352 %ghost %{_sysconfdir}/alternatives/lib%{name}.so.0
353 %ghost %{_sysconfdir}/alternatives/libblas.so.3
354 %ghost %{_sysconfdir}/alternatives/libcblas.so.3
355 %ghost %{_sysconfdir}/alternatives/liblapack.so.3
356
357 %files -n lib%{name}_openmp-devel
358 %defattr(-,root,root,-)
359 %{_libdir}/lib%{name}_openmp.so
360
361 %files -n lib%{name}_pthreads0
362 %manifest %{name}.manifest
363 %defattr(-,root,root,-)
364 %{_libdir}/lib%{name}_pthreads.so.0
365 %ghost %{_libdir}/lib%{name}.so.0
366 %ghost %{_libdir}/libblas.so.3
367 %ghost %{_libdir}/libcblas.so.3
368 %ghost %{_libdir}/liblapack.so.3
369 %ghost %{_sysconfdir}/alternatives/lib%{name}.so.0
370 %ghost %{_sysconfdir}/alternatives/libblas.so.3
371 %ghost %{_sysconfdir}/alternatives/libcblas.so.3
372 %ghost %{_sysconfdir}/alternatives/liblapack.so.3
373
374 %files -n lib%{name}_pthreads-devel
375 %defattr(-,root,root,-)
376 %{_libdir}/lib%{name}_pthreads.so
377
378 %files devel
379 %defattr(-,root,root,-)
380 %doc Changelog.txt GotoBLAS* LICENSE README.md
381 %{_libdir}/documentation.list
382 %{_libdir}/lib%{name}.so
383 %{_libdir}/pkgconfig/*
384
385 %files devel-headers
386 %defattr(-,root,root,-)
387 %{_includedir}/%{name}/
388
389 %files devel-static
390 %defattr(-,root,root,-)
391 %{_libdir}/lib%{name}_serial.a
392 %{_libdir}/lib%{name}_openmp.a
393 %{_libdir}/lib%{name}_pthreads.a
394
395 %changelog
396