sys-process/glances: revbump 3.1.4.1, add missing doc dep
[gentoo.git] / sci-libs / pgplot / pgplot-5.2.2-r7.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=6
5
6 inherit eutils fortran-2 toolchain-funcs
7
8 MY_P="${PN}${PV//.}"
9
10 DESCRIPTION="FORTRAN/C device-independent scientific graphic library"
11 HOMEPAGE="http://www.astro.caltech.edu/~tjp/pgplot/"
12 SRC_URI="ftp://ftp.astro.caltech.edu/pub/pgplot/${MY_P}.tar.gz"
13
14 SLOT="0"
15 LICENSE="free-noncomm"
16 KEYWORDS="amd64 ~arm ~ia64 ~ppc x86 ~amd64-linux ~x86-linux"
17 IUSE="doc motif static-libs tk"
18
19 RDEPEND="
20         media-libs/libpng:=
21         x11-libs/libX11:=
22         x11-libs/libXt:=
23         motif? ( x11-libs/motif:= )
24         tk? ( dev-lang/tk:= )"
25 DEPEND="${RDEPEND}
26         doc? ( virtual/latex-base )"
27
28 S="${WORKDIR}/${PN}"
29
30 PATCHES=(
31         "${FILESDIR}"/${PN}-drivers.patch
32         "${FILESDIR}"/${PN}-makemake.patch
33         "${FILESDIR}"/${PN}-compile-setup.patch
34         "${FILESDIR}"/${PN}-headers.patch
35         "${FILESDIR}"/${PN}-libpng15.patch
36         "${FILESDIR}"/${PN}-tk86.patch
37 )
38
39 src_prepare() {
40         default
41         # gfortran < 4.3 does not compile gif, pp and wd drivers
42         if [[ $(tc-getFC) == *gfortran* ]] &&
43                 [[ $(gcc-major-version)$(gcc-minor-version) -lt 43 ]] ; then
44                 ewarn "Warning!"
45                 ewarn "gfortran < 4.3 selected: does not compile all drivers"
46                 ewarn "disabling gif, wd, and ppd drivers"
47                 ewarn "if you want more drivers, use gfortran >= 4.3"
48                 sed -e 's/GIDRIV/! GIDRIV/g' \
49                         -e 's/PPDRIV/! GIDRIV/g' \
50                         -e 's/WDDRIV/! GIDRIV/g' \
51                         -i drivers.list || die "sed drivers failed"
52         fi
53
54         # fix pointers for 64 bits
55         if use amd64 || use ia64; then
56                 sed -e 's/INTEGER PIXMAP/INTEGER*8 PIXMAP/g' \
57                         -i drivers/{gi,pp,wd}driv.f || die "sed 64bits failed"
58         fi
59
60         cp sys_linux/g77_gcc.conf local.conf
61
62         sed -e "s:FCOMPL=.*:FCOMPL=\"$(tc-getFC)\":g" \
63                 -e "s:CCOMPL=.*:CCOMPL=\"$(tc-getCC)\":g" \
64                 -i local.conf || die "sed flags failed"
65
66         if [[ "$(tc-getFC)" = if* ]]; then
67                 sed -e 's/-Wall//g' \
68                         -e 's/TK_LIBS="/TK_LIBS="-nofor-main /' \
69                         -i local.conf || die "sed drivers failed"
70         fi
71
72         sed -e "s:/usr/local/pgplot:${EPREFIX}/usr/$(get_libdir)/pgplot:g" \
73                 -e "s:/usr/local/bin:${EPREFIX}/usr/bin:g" \
74                 -i src/grgfil.f makehtml maketex || die "sed path failed"
75
76         use motif && sed -i -e '/XMDRIV/s/!//' drivers.list
77         use tk && sed -i -e '/TKDRIV/s/!//' drivers.list
78 }
79
80 src_configure() {
81         ./makemake . linux
82         # post makefile creation prefix hack
83         sed -i -e "s|/usr|${EPREFIX}/usr|g" makefile || die
84 }
85
86 src_compile() {
87         emake \
88                 CFLAGS="${CFLAGS} -fPIC" \
89                 FFLAGS="${FFLAGS} -fPIC" \
90                 shared cpg-shared pgxwin_server pgdisp pgplot.doc
91
92         use tk && emake CFLAGS="${CFLAGS} -fPIC" libtkpgplot.so
93         use motif && emake CFLAGS="${CFLAGS} -fPIC" libXmPgplot.so
94
95         emake -j1 clean
96         use static-libs && emake all cpg
97
98         if use doc; then
99                 export VARTEXFONTS="${T}/fonts"
100                 emake pgplot.html pgplot-routines.tex
101                 pdflatex pgplot-routines.tex
102                 pdflatex pgplot-routines.tex
103         fi
104
105         # this just cleans out not needed files
106         emake -j1 clean
107 }
108
109 src_test() {
110         # i can go to 16
111         local i j
112         for i in 1 2 3; do
113                 emake pgdemo${i}
114                 # j can also be LATEX CPS...
115                 for j in NULL PNG PS CPS LATEX; do
116                         local testexe=./test_${j}_${i}
117                         echo "LD_LIBRARY_PATH=. ./pgdemo${i} <<EOF" > ${testexe}
118                         echo "/${j}" >> ${testexe}
119                         echo "EOF" >> ${testexe}
120                         sh ${testexe} || die "test ${i} failed"
121                 done
122         done
123 }
124
125 src_install() {
126         insinto /usr/$(get_libdir)/pgplot
127         doins grfont.dat grexec.f *.inc rgb.txt
128         echo "PGPLOT_FONT=${EPREFIX}/usr/$(get_libdir)/pgplot/grfont.dat" >> 99pgplot
129         doenvd 99pgplot
130
131         dolib.so libpgplot.so*
132         dobin pgxwin_server pgdisp
133
134         # C binding
135         insinto /usr/include
136         doins cpgplot.h
137         dolib.so libcpgplot.so*
138
139         if use motif; then
140                 insinto /usr/include
141                 doins XmPgplot.h
142                 dolib.so libXmPgplot.so*
143         fi
144
145         if use tk; then
146                 insinto /usr/include
147                 doins tkpgplot.h
148                 dolib.so libtkpgplot.so*
149         fi
150
151         use static-libs && dolib.a lib*pgplot.a
152
153         # minimal doc
154         dodoc aaaread.me pgplot.doc
155         newdoc pgdispd/aaaread.me pgdispd.txt
156
157         if use doc; then
158                 dodoc cpg/cpgplot.doc applications/curvefit/curvefit.doc pgplot.html
159                 dodoc pgplot-routines.pdf pgplot-routines.tex
160                 insinto /usr/share/doc/${PF}/examples
161                 doins  examples/* cpg/cpgdemo.c
162                 insinto /usr/share/doc/${PF}/applications
163                 doins -r applications/*
164                 if use motif; then
165                         insinto /usr/share/doc/${PF}/pgm
166                         doins pgmf/* drivers/xmotif/pgmdemo.c
167                 fi
168                 if use tk; then
169                         insinto /usr/share/doc/${PF}/pgtk
170                         doins drivers/xtk/pgtkdemo.*
171                 fi
172         fi
173 }