Пакет petsc-real: Specfile

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
%def_without mpi4py
%def_without petsc4py
%def_without netcdf
%def_without tops

%define mpiimpl openmpi
%define mpidir %_libexecdir/%mpiimpl
%define pastix_sover 0
%define spooles_sover 2

%define oname petsc
%define scalar_type real
%define ldir %_libexecdir/%oname-%scalar_type
%if "%scalar_type" == "real"
%define alttype complex
%else
%define alttype real
%endif

%define somver 3
%define sover %somver.0.0

%define topsomver 0
%define topsover %topsomver.0.0

Name: %oname-%scalar_type
Version: 3.0.0_p8
Release: alt2.M51.1
Summary: Portable, Extensible Toolkit for Scientific Computation (%scalar_type scalars)
License: BSD
Group: Sciences/Mathematics
Url: http://www.mcs.anl.gov/petsc/
Packager: Eugeny A. Rostovtsev (REAL) <real at altlinux.org>

Source: ftp://ftp.mcs.anl.gov/pub/petsc/release-snapshots/petsc-3.0.0-p8.tar.gz
Source1: ftp://ftp.mcs.anl.gov/pub/petsc/externalpackages/Generator.tar.gz
Source3: gen_makefile
Source4: makefile.tmpl

Requires: lib%name-devel = %version-%release
Requires: python-module-%oname-config >= %version-%release
Requires: %oname-common >= %version-%release
Requires: pdtoolkit tau mpe2
# skip 'requires' generation, because import directory calculated at runtime
%add_python_req_skip script

BuildRequires(pre): rpm-build-python
BuildPreReq: chrpath %mpiimpl-devel gcc-fortran libgfortran-devel
BuildPreReq: libstdc++-devel libatlas-devel libsz2-devel libarpack-devel
BuildPreReq: liblapack-devel gcc-c++ libscalapack-devel libX11-devel
BuildPreReq: libXt-devel libsowing-devel boost-devel python-module-fiat
BuildPreReq: libparmetis-devel libblacs-devel libspooles-devel
BuildPreReq: libtetgen-devel zlib-devel libblocksolve95-devel
BuildPreReq: libtriangle-devel libsuperlu_dist-devel libsuitesparse-devel
BuildPreReq: libsuperlu-devel liby12m-devel libf2cblaslapack-devel
BuildPreReq: libfblaslapack-devel cproto libchaco-devel c2html
BuildPreReq: libtau-devel libmtl4-devel libmpe2-devel boost-python-devel
BuildPreReq: libplapack-devel python-devel /proc
%if %scalar_type == real
%if_with petsc4py
BuildPreReq: python-module-petsc4py-%scalar_type
%endif
%ifarch %ix86
BuildPreReq: libscotch-devel libmumps-devel libpastix-devel
%endif
BuildPreReq: libamesos-devel libepetraext-devel libteuchos-devel
BuildPreReq: libifpack-devel libaztecoo-devel libepetra-devel
BuildPreReq: libml-devel libzoltan-devel
BuildPreReq: libml-devel ffc libhypre-devel libspai-devel libparms-devel
BuildPreReq: libblopex-devel libhdf5-mpi-devel python-module-numpy
BuildPreReq: libexpat-devel
%if_with mpi4py
BuildPreReq: python-module-mpi4py
%endif
%if_with netcdf
BuildPreReq: libnetcdf-mpi-devel
%endif
BuildPreReq: libsundials-devel libzoltan-devel
BuildPreReq: libsprng1-devel
%endif
%if %scalar_type == complex
BuildPreReq: libfftw3-mpi-devel
%endif
%if_with tops
BuildPreReq: babel ccaffeine cca-spec-classic cca-spec-babel cca-spec-neo
%endif

%description
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

For generating initial makefiles for Your programs use script named
`gen_makefile'. If You want create log file when running Your programs for event
vizualisations, use `-log_mpe [logfile]' as a parameter for Your executables.

%package -n lib%name
Summary: Shared libraries of PETSc (%scalar_type scalars)
Group: System/Libraries
Conflicts: lib%name-devel < %version-%release
Obsoletes: lib%name-devel < %version-%release
Conflicts: libslepc-%scalar_type-devel < 3.0.0_p4-alt2
Obsoletes: libslepc-%scalar_type-devel < 3.0.0_p4-alt2
Requires: libspooles
%ifarch %ix86
%if %scalar_type == real
Requires: libpastix
%endif
%endif

%description -n lib%name
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains shared libraries of PETSc (with %scalar_type scalar types).

%package -n lib%name-devel
Summary: Development files of PETSc (%scalar_type scalars)
Group: Development/Other
Requires: lib%name = %version-%release
Requires: %oname-common >= %version-%release
Requires: %mpiimpl-devel gcc-fortran libgfortran-devel
Requires: libstdc++-devel libatlas-devel libsz2-devel libarpack-devel
Requires: liblapack-devel gcc-c++ libscalapack-devel libX11-devel
Requires: libXt-devel libsowing-devel boost-devel python-module-fiat
Requires: libparmetis-devel libblacs-devel libspooles-devel
Requires: libtetgen-devel zlib-devel libblocksolve95-devel
Requires: libtriangle-devel libsuperlu_dist-devel libsuitesparse-devel
Requires: libsuperlu-devel liby12m-devel libf2cblaslapack-devel
Requires: libfblaslapack-devel cproto libchaco-devel
Requires: libtau-devel libmtl4-devel libmpe2-devel boost-python-devel
Requires: libplapack-devel python-devel
%if %scalar_type == real
%if_with petsc4py
Requires: python-module-petsc4py-%scalar_type
%endif
%ifarch %ix86
Requires: libscotch-devel libmumps-devel libpastix-devel
%endif
Requires: libamesos-devel libepetraext-devel libteuchos-devel
Requires: libifpack-devel libaztecoo-devel libepetra-devel
Requires: libml-devel libzoltan-devel
Requires: libml-devel ffc libhypre-devel libspai-devel libparms-devel
Requires: libblopex-devel libhdf5-mpi-devel python-module-numpy
Requires: libexpat-devel
%if_with mpi4py
Requires: python-module-mpi4py
%endif
%if_with netcdf
Requires: libnetcdf-mpi-devel
%endif
Requires: libsundials-devel libzoltan-devel
Requires: libsprng1-devel
%endif
%if %scalar_type == complex
Requires: libfftw3-mpi-devel
%endif
%if_with tops
Requires: babel ccaffeine cca-spec-classic cca-spec-babel cca-spec-neo
%endif


%description -n lib%name-devel
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains development files of PETSc (with %scalar_type
scalar types).

%package -n lib%name-devel-static
Summary: Static development files of PETSc (%scalar_type scalars)
Group: Development/Other
Requires: lib%name-devel = %version-%release
Requires: libparmetis-devel libsuitesparse-devel
Requires: libspooles-devel libsuperlu_dist-devel libsuperlu-devel
Requires: libchaco-devel libblocksolve95-devel
Requires: libf2cblaslapack-devel libfblaslapack-devel
Requires: libmtl4-devel libparms-devel libpdtoolkit-devel
Requires: libmpe2-devel libscalasca-devel libplapack-devel
%if %scalar_type == real
%ifarch %ix86
Requires: libscotch-devel libmumps-devel libpastix-devel
%endif
Requires: libzoltan-devel libspai-devel libblopex-devel
Requires: libhypre-devel
Requires: libscalapack-devel libml-devel
Requires: libsprng1-devel
%endif
%if %scalar_type == complex
Requires: libfftw3-mpi-devel
%endif

%description -n lib%name-devel-static
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains static development files of PETSc (with %scalar_type
scalar types).

%package -n python-module-%oname-config
Summary: Configuration system of PETSc (%scalar_type scalars)
Group: Development/Other
Requires: %oname-common = %version-%release
%py_provides petsc_config

%description -n python-module-%oname-config
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains configuration system of PETSc (with %scalar_type scalar
types).

%package -n %oname-docs
Summary: Documentation for PETSc
Group: Development/Documentation
BuildArch: noarch

%description -n %oname-docs
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains development documentation for PETSc.

%package -n %oname-examples
Summary: Examples of PETSc
Group: Development/Tools
Requires: %oname-common = %version-%release
Requires: python-module-%oname-config = %version-%release
# skip 'requires' generation, because import directory calculated at runtime
%add_python_req_skip RDict script

%description -n %oname-examples
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains examples of PETSc. If You want build some example, execute
command `gen_makefile NAME'.

%package -n %oname-common
Summary: Common files of PETSc (both for real and complex scalars)
Group: Development/Tools
Conflicts: libxforms-demos
%add_python_req_skip RDict script

%description -n %oname-common
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains common files of PETSc.

%package tops
Summary: TOPS components of PETSc (for %scalar_type scalars)
Group: Development/Tools
Requires: %name = %version-%release
Requires: %oname-tops = %version-%release
Requires: lib%name-tops = %version-%release

%description tops
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package provides Towards Optimal Petscale Simulations (TOPS) components
of PETSc.

%package -n lib%name-tops
Summary: Shared libraries of TOPS components of PETSc (for %scalar_type scalars)
Group: System/Libraries
Requires: lib%name = %version-%release

%description -n lib%name-tops
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains shared libraries of Towards Optimal Petscale Simulations
(TOPS) components of PETSc.

%package -n %oname-tops
Summary: Common files of TOPS components of PETSc (for %scalar_type scalars)
Group: Development/Tools

%description -n %oname-tops
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains common files of Towards Optimal Petscale Simulations
(TOPS) components of PETSc.

%package sources
Summary: Prepared sources of PETSc (for %scalar_type scalars)
Group: Development/Tools

%description sources
Portable, Extensible Toolkit for Scientific Computation (PETSc) is a suite of
data structures and routines for the scalable (parallel) solution of scientific
applications modeled by partial differential equations. It employs the MPI
standard for parallelism.

This package contains prepared sources of PETSc.

%prep
%setup
tar -xzf %SOURCE1
rm -f Generator/.hgignore
rm -fR Generator/.hg
sed -i -e 's/^\(import\ lex\)/from fract4d \1/' Generator/exprlex.py
sed -i -e 's/^\(import\ yacc\)/from fract4d \1/' Generator/exprparse.py
sed -i 's|2\.5|%__python_version|g' tutorials/python/ex1.c
sed -i 's|/usr/lib/|%_libdir/|g' tutorials/python/ex1.c

%install
install -d %buildroot%ldir/lib
%if %scalar_type == complex
cat <<EOF >dummy.c
void MatCreate_MPIRowbs()
{
	return;
}
EOF
gcc %optflags_shared -c dummy.c
ar r %buildroot%ldir/lib/libpetscdummy.a dummy.o
ranlib %buildroot%ldir/lib/libpetscdummy.a
DUMMY="-Wl,--no-as-needed -L%buildroot%ldir/lib -lpetscdummy"
%endif

mpi-selector --set %mpiimpl
source %_sysconfdir/profile.d/mpi-selector.sh
source %mpidir/bin/mpivars.sh

ln -s %_libexecdir/spooles/lib/libspooles.so .
ln -s %_libexecdir/spooles/lib/libspoolesMPI.so .
%if %scalar_type == real
%ifarch %ix86
ln -s %_libexecdir/pastix/lib/libpastix.so .
%endif
%endif

export PETSC_DIR=$PWD
export PETSC_ARCH=linux-gnu
OPTFLAGS="%optflags %optflags_shared -DPETSC_HAVE_MPE -I$PETSC_DIR/include/sieve"
%if_with netcdf
OPTFLAGS="$OPTFLAGS -DPETSC_HAVE_NETCDF -DPETSC_HAVE_PNETCDF"
%endif
BLASLAPACK="[libf2clapack.a,libflapack.a,libf2cblas.a,libfblas.a,libxerbla.a"
BLASLAPACK="$BLASLAPACK,liblapack.so,liblapack_atlas.so,libf77blas.so,libblas.so"
BLASLAPACK="$BLASLAPACK,libcblas.so,libatlas.so]"
MUMPS="[libcmumps.so,libdmumps.so,libsmumps.so,libzmumps.so,libmumps_common.so"
MUMPS="$MUMPS,libpord.so,libesmumps.so,libscotch.so,libscotcherr.so]"
ML="[libml.so,libamesos.so,libepetraext.so,libifpack.so,libaztecoo.so"
ML="$ML,libepetra.so,libteuchos.so,liby12m.so]"
SUNDIALS="[libsundials_cvode.so,libsundials_nvecserial.so"
SUNDIALS="$SUNDIALS,libsundials_nvecparallel.so]"
%if_with tops
CCAS="-lcca_0_8_6_b_1.4.0-cxx -lsidlstub_cxx"
%endif

./configure \
	--prefix=%prefix \
	--with-shared \
	--with-scalar-type=%scalar_type \
	--with-alternatives=1 \
	--with-is-color-value-type=char \
	--with-fortran-interfaces=1 \
	--with-debugging=no \
	--search-dirs=/bin:%_bindir:%mpidir/bin \
	--with-host-cpu=%_arch \
	--with-clanguage=C++ \
	--with-timer=mpi \
	--with-mpi-dir=%mpidir \
	--with-mpi-shared=1 \
	--with-xt=1 \
	--with-sowing=1 \
	--with-sowing-dir=%prefix \
	--with-boost=1 \
	--with-boost-dir=%prefix \
	--with-c2html=1 \
	--with-c2html-dir=%prefix \
	--with-fiat=1 \
	--with-fiat-dir=%prefix \
	--with-parmetis=1 \
	--with-parmetis-include=%_includedir/parmetis \
	--with-parmetis-lib=[libparmetis.so,libmetis.so] \
	--with-blacs=1 \
	--with-blacs-include=%_includedir \
	--with-blacs-lib=[libblacs.so] \
	--with-scalapack=1 \
	--with-scalapack-include=%_includedir \
	--with-scalapack-lib=[libscalapack.so,libblacs.so,libarpack_LINUX.so] \
	--with-triangle=1 \
	--with-triangle-include=%_includedir/triangle \
	--with-triangle-lib=libtriangle.so \
	--with-superlu_dist=1 \
	--with-superlu_dist-include=%_includedir/superlu_dist \
	--with-superlu_dist-lib=libsuperlu_dist_2.3.so \
	--with-umfpack=1 \
	--with-umfpack-include=%_includedir/suitesparse \
	--with-umfpack-lib=[libumfpack.so,libamd.so] \
	--with-tetgen=1 \
	--with-tetgen-dir=%prefix \
	--with-spooles=1 \
	--with-spooles-include=%_libexecdir/spooles/include \
	--with-spooles-lib=[libspoolesMPI.so,libspooles.so] \
	--with-blas-lapack-lib=$BLASLAPACK \
	--with-chaco=1 \
	--with-chaco-dir=%prefix \
	--with-generator=$PWD/Generator \
	--with-cproto=1 \
	--with-cproto-dir=%prefix \
	--with-blocksolve95=1 \
	--with-blocksolve95-dir=%prefix \
	--with-blocksolve95-bopt=O \
	--with-blocksolve95-arch=linux \
	--with-plapack=1 \
	--with-plapack-include=%_includedir/plapack \
	--with-plapack-lib=[libPLAPACK.so] \
	--with-mpe=1 \
	--with-mpe-include=%_includedir \
	--with-mpe-lib=[liblmpe.so,libmpe.so] \
%if %scalar_type == real
	--with-parms=1 \
	--with-parms-dir=%prefix \
	--with-ml=1 \
	--with-ml-include=%_includedir \
	--with-ml-lib=$ML \
	--with-ffc=1 \
	--with-ffc-dir=%prefix \
	--with-hypre=1 \
	--with-hypre-include=%_includedir/hypre \
	--with-hypre-lib=[libHYPRE.so,libgomp.so] \
	--with-expat=1 \
	--with-expat-dir=%prefix \
	--with-sundials=1 \
	--with-sundials-include=%_includedir/sundials-double \
	--with-sundials-lib=$SUNDIALS \
	--with-hdf5=1 \
	--with-hdf5-dir=%prefix \
	--with-zoltan=1 \
	--with-zoltan-dir=%prefix \
	--with-blopex=1 \
	--with-blopex-include=%_includedir/libblopex \
	--with-blopex-lib=libBLOPEX.so \
	--with-spai=1 \
	--with-spai-include=%_includedir/spai \
	--with-spai-lib=libspai.so \
	--with-numpy=1 \
	--with-numpy-dir=%prefix \
	--with-sprng=1 \
	--with-sprng-include=%_includedir/sprng1 \
	--with-sprng-lib=[libcmrg.so,liblcg64.so,liblcg.so,liblfg.so,libmlfg.so] \
%if_with mpi4py
	--with-mpi4py=1 \
	--with-mpi4py-dir=%prefix \
%endif
%if_with petsc4py
	--with-petsc4py=1 \
	--with-petsc4py-dir=%prefix \
%endif
%if_with netcdf
	--with-netcdf=1 \
	--with-netcdf-dir=%prefix \
%endif
%endif
%if %scalar_type == complex
	--with-fftw=1 \
	--with-fftw-include=%_includedir/fftw3-mpi \
	--with-fftw-lib=[libfftw3_mpi.a,libfftw3.a] \
%endif
%ifarch %ix86
%if %scalar_type == real
	--with-mumps=1 \
	--with-mumps-include=%_includedir \
	--with-mumps-lib=$MUMPS \
	--with-scotch=1 \
	--with-scotch-dir=%prefix \
	--with-pastix=1 \
	--with-pastix-include=%_includedir \
	--with-pastix-lib=[libpastix.so,libmetis.so,libptscotch.so,librt.so] \
%endif
%endif
%if_with tops
	--with-babel=1 \
	--with-babel-dir=%prefix \
	--with-ccafe=1 \
	--with-ccafe-dir=%prefix \
%endif
	--CC=mpicc --CXX=mpicxx --FC=mpif90 \
	--COPTFLAGS="$OPTFLAGS" \
	--CXXOPTFLAGS="$OPTFLAGS" \
	--FOPTFLAGS="$OPTFLAGS" \
	--LIBS="-L$PWD -L%_libexecdir/spooles/lib -llmpe -lmpe $CCAS $DUMMY"

%make all

%make_install PETSC_DIR=$PWD PETSC_ARCH=linux-gnu \
	INSTALL_DIR=%buildroot%prefix \
	install

install -d %buildroot%_sysconfdir
install -d %buildroot%ldir/examples
install -d %buildroot%_docdir/%oname/include/adic
install -d %buildroot%_docdir/%oname/include/finclude
install -d %buildroot%_docdir/%oname/include/mpiuni
install -d %buildroot%_docdir/%oname/include/private
install -d %buildroot%_docdir/%oname/include/sieve
install -d %buildroot%_datadir/%name
install -d %buildroot%_datadir/%oname
install -d %buildroot%python_sitelibdir/%{oname}_config
install -d %buildroot%ldir/lib
install -d %buildroot%ldir/include
install -d %buildroot%ldir/python

mv %buildroot%_libexecdir/*.so* %buildroot%_libexecdir/*.a \
	%buildroot%ldir/lib/
mv %buildroot%_includedir/* %buildroot%ldir/include/

mv Generator %buildroot%python_sitelibdir/%{oname}_config/
rm -fR config/examples
mv config/* %buildroot%python_sitelibdir/%{oname}_config/
touch %buildroot%python_sitelibdir/%{oname}_config/__init__.py

pushd %buildroot%_bindir
rm -fR matlab win32fe
rm -f mpiexec.gmalloc mpiexec.llrun mpiexec.poe mpiexec.prun
mv %buildroot%_bindir/hostnames.chiba %buildroot%_sysconfdir/
chmod +x parseargs.py
popd

pushd %buildroot%ldir/include
mv *.html %buildroot%_docdir/%oname/include/
for i in adic finclude mpiuni private sieve; do
	mv $i/*.html %buildroot%_docdir/%oname/include/$i/
done
cp $PETSC_DIR/src/dm/mesh/sieve/Filter.hh sieve/
sed -i "s|$PETSC_DIR/Generator|%python_sitelibdir/%{oname}_config/Generator|g" \
	$(find -type f)
sed -i "s|$PETSC_DIR/linux-gnu/lib|%ldir/lib|g" $(find -type f)
sed -i "s|$PETSC_DIR/include|%ldir/include|g" $(find -type f)
sed -i "s|$PETSC_DIR|%_datadir/%name|g" $(find -type f)
mv makefile makefile.%oname
popd

pushd %buildroot/%prefix/conf
rm -f uninstall.py *.log
sed -i "s|$PETSC_DIR/Generator|%python_sitelibdir/%{oname}_config/Generator|g" *
sed -i "s|$PETSC_DIR/config|%python_sitelibdir/%{oname}_config|g" *
sed -i "s|$PETSC_DIR/conf|%_datadir/%name/conf|g" *
sed -i "s|$PETSC_DIR/include|%ldir/include|g" *
sed -i "s|%buildroot||g" *
sed -i "s|$PETSC_DIR|%prefix|g" *
sed -i 's|/usr/config|%python_sitelibdir/%{oname}_config|g' *
sed -i 's|/usr/conf|%_datadir/%name/conf|g' *
sed -i 's|linux\-gnu/||g' RDict.db
sed -i "s|/usr/include|%ldir/include|" variables
sed -i "83s|^\(PETSC_LIB_DIR_COMPLEX\).*|\1 = %ldir/lib|g" variables
sed -i "11s|^\(PETSC_LIB_DIR\).*|\1 = %ldir/lib|g" variables
sed -i "s|/usr/include/petscconf.h|%ldir/include/petscconf.h|g" rules
popd

mv %buildroot%prefix/conf %buildroot%_datadir/%name/
ln -s %_datadir/%name/conf %buildroot%ldir
ln -s %ldir/lib %buildroot%_datadir/%name
ln -s %ldir/include %buildroot%_datadir/%name

mkdir doc
cp docs/copyright.html doc/
mv *.html docs tutorials %buildroot%_docdir/%oname/
%if %scalar_type == real
pushd src
rm -fR contrib/semiLagrange
for i in $(find ./ -name examples); do
	install -d %buildroot%ldir/examples/$i
	cp -fR $i/* %buildroot%ldir/examples/$i/
done
popd
%endif

install -p -m755 %SOURCE3 %buildroot%_bindir
install -p -m644 %SOURCE4 %buildroot%_datadir/%oname

cat <<EOF >%buildroot%_bindir/%name.sh
source %mpidir/bin/mpivars.sh
export PETSC_DIR=%ldir
export PETSC_LDIR=%ldir
export PETSC_LIB_DIR=%ldir/lib
export PETSC_SCALAR_TYPE=%scalar_type
export PETSC_CONFIG_DIR=%ldir/python/%{oname}_config
export TAU_MAKEFILE=$(rpm -ql libtau-common|grep Makefile)
export SLEPC_DIR=%ldir
PYPATH="\`echo \$PYTHONPATH|sed 's|:%_libexecdir/%oname-%alttype/python||'\`"
PYPATH="\`echo \$PYPATH|sed 's|:%python_sitelibdir/%oname-%alttype/python||'\`"
export PYTHONPATH="\$PYPATH:%ldir/python"
EOF
chmod +x %buildroot%_bindir/%name.sh

install -d %buildroot%_pkgconfigdir
cat <<EOF >%buildroot%_pkgconfigdir/%name.pc
prefix=%prefix
exec_prefix=%prefix
libdir=%ldir/lib
includedir=%ldir/include
pyexecdir=%ldir/python

Name: %name
Description: Portable, Extensible Toolkit for Scientific Computation (%scalar_type scalars)
Version: %version
Libs: -L%ldir/lib -lpetscts -lpetscsnes -lpetscksp -lpetscdm -lpetscmat -lpetscvec -lpetsc -Wl,-R%mpidir/lib:%ldir/lib
Cflags: -I%mpidir/include -I%ldir/include
EOF

ln -s %name.sh %buildroot%_bindir/slepc-%scalar_type.sh
ln -s %python_sitelibdir/petsc_config %buildroot%ldir/python

# TOPS

%if_with tops
#mv %buildroot%_libexecdir/tops/*/*.a \
#	%buildroot%_libexecdir/tops/*/*.so.%topsover \
#	%buildroot%ldir/lib/

install -d %buildroot%_datadir/%oname/tops
rm -fR src/tops/server
pushd src/tops/utils
install -p -m755 genSCLCCA* generateClientMakefile.sh \
	%buildroot%_bindir
rm -f genSCLCCA* generateClientMakefile.sh
popd
cp -fR src/tops %buildroot%_datadir/%oname/tops/
%endif

# fix RPATH

pushd %buildroot%ldir/lib
ADDRPATH="%_libexecdir/spooles/lib"
%ifarch %ix86
%if %scalar_type == real
ADDRPATH="$ADDRPATH:%_libexecdir/pastix/lib"
%endif
%endif

for i in petsc petsccontrib petscksp petscdm \
	petscmat petscsnes petscts petscvec tops topsc
do
	if [ -f lib$i.so.%sover ]; then
		chrpath -r \
			%ldir/lib:%mpidir/lib:$ADDRPATH \
			lib$i.so.%sover
		ln -s lib$i.so.%sover lib$i.so.%somver
		ln -s lib$i.so.%somver lib$i.so
	fi
done
#if_with tops
#for i in topsclient-c topsclient-cxx
#do
#	if [ -f lib$i.so.%topsover ]; then
#		chrpath -r %ldir/lib:%mpidir/lib lib$i.so.%topsover
#		ln -s lib$i.so.%topsover lib$i.so.%topsomver
#		ln -s lib$i.so.%topsomver lib$i.so
#	fi
#done
#endif
popd

rm -f $(find ./ -name '*.o') \
	$(find ./ -name '*.a') \
	$(find ./ -name '*.so*') \
	$(find ./ -name '*.html'|egrep -v copyright)
install -d %buildroot%ldir/sources
cp -fR src include %buildroot%ldir/sources/

%files
%doc doc/copyright.html

%files -n lib%name
%dir %ldir
%dir %ldir/lib
%dir %ldir/python
%ldir/lib/*.so.*
%_bindir/%name.sh
%_bindir/slepc-%scalar_type.sh

%files -n lib%name-devel
%ldir/include
%ldir/lib/*.so
%if %scalar_type == complex
%ldir/lib/libpetscdummy.a
%endif
%_datadir/%name
%ldir/conf
%_pkgconfigdir/*

%files -n lib%name-devel-static
%ldir/lib/*.a
%if %scalar_type == complex
%exclude %ldir/lib/libpetscdummy.a
%endif

%if_with tops
%files tops

%files -n lib%name-tops
%ldir/libtops*.so.*
%endif

%if %scalar_type == real
%files -n %oname-common
%_sysconfdir/hostnames.chiba
%_bindir/*
%exclude %_bindir/%name.sh
%exclude %_bindir/slepc-%scalar_type.sh
%_datadir/%oname
%if_with tops
%exclude %_bindir/TOPS*
%exclude %_datadir/%oname/tops
%dir %_libexecdir/cca
%_libexecdir/cca/*
%endif

%if_with tops
%files -n %oname-tops
%_bindir/TOPS*
%_bindir/genSCLCCA*
%_bindir/generateClientMakefile.sh
%_datadir/%oname/tops
%endif

%files -n %oname-docs
%_docdir/%oname

%files -n python-module-%oname-config
%python_sitelibdir/*
%ldir/python/petsc_config

%files -n %oname-examples
%dir %ldir
%ldir/examples
%exclude %ldir/examples/tops
%endif

%files sources
%ldir/sources

%changelog
* Wed Dec 16 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p8-alt2.M51.1
- Port for branch 5.1

* Sun Sep 20 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p8-alt2
- Added necessary requirements for devel package

* Thu Sep 10 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p8-alt1
- Version 3.0.0_p8

* Tue Sep 08 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt6
- Rebuilt with shared libraries of all requirements
- Enabled build with SPRNG

* Tue Aug 18 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt5
- Rebuild with shared libraries of ScaLAPACK and ML
- Build with petsc4py
- Added package with prepared sources

* Thu Jul 23 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt4
- Rebuild with python 2.6

* Sun Jul 19 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt3.3
- Link with libpetscdummy (for complex scalars)

* Sat Jul 18 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt3.2
- Corrected %_bindir/%name.sh for PYTHONPATH

* Sat Jul 18 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt3.1
- Drop requirement on lib%name-%scalar_type for config module

* Sat Jul 18 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt3
- Integrated startup commands for all client packages in %_bindir/%name.sh
- Moved %_bindir/%name.sh into lib%name package

* Fri Jul 17 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt2
- Redefined PETSC_DIR: /usr/share/petsc-%scalar_type -> /usr/lib/petsc-%scalar_type
- Added necessary libraries requirements for devel package
- Created pkg-config file
- Moved examples into /usr/lib/petsc-%scalar_type

* Tue Jul 14 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p7-alt1
- Version 3.0.0_p7

* Sun Jul 12 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p6-alt2
- Fixed include directory in $PETSC_DIR/conf files
- Added links to development files into $PETSC_DIR

* Wed Jun 24 2009 Eugeny A. Rostovtsev (REAL) <real at altlinux.org> 3.0.0_p6-alt1
- Initial build for Sisyphus