aboutsummaryrefslogtreecommitdiff
blob: ed77b97bc22998610d53315766eb1959b117cc7c (plain)
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
# Copyright 1999-2021 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=7

JAVA_PKG_OPT_USE="gui"
VIRTUALX_REQUIRED="manual"

inherit autotools bash-completion-r1 check-reqs eutils flag-o-matic \
	fortran-2 java-pkg-opt-2 pax-utils toolchain-funcs virtualx xdg-utils

DESCRIPTION="Scientific software package for numerical computations"
HOMEPAGE="https://www.scilab.org/"
SRC_URI="https://www.scilab.org/download/${PV}/${P}-src.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS=""

IUSE="debug doc emf fftw +gui +matio mpi nls openmp
	static-libs test tk +umfpack +xcos"
REQUIRED_USE="xcos? ( gui ) doc? ( gui )"

RESTRICT="test"

IUSE_L10N="fr zh zh ru ca de es pt ja it uk pl cs"
L10N_DOC="fr pt ja ru"

map_lang() {
	local lang=${1/_/-}
	case $1 in
		# Retain the following, which have a specific subtag
		de_*|en_*|pt_*|zh_*) ;;
		# Consider all other xx_XX as duplicates of the generic xx tag
		*_*) lang=${1%%_*} ;;
	esac
	echo ${lang}
}

prev_l=
for l in ${IUSE_L10N}; do
	l=$(map_lang ${l})
	[[ ${l} != "${prev_l}" ]] && IUSE+=" l10n_${l}"
	prev_l=${l}
done
unset l prev_l

CDEPEND="
	dev-libs/libpcre
	dev-libs/libxml2:2
	sci-libs/hdf5[mpi=]
	>=sci-libs/arpack-3
	sci-libs/lapack[deprecated(-)]
	sys-devel/gettext
	sys-libs/ncurses:0=
	sys-libs/readline:0=
	sys-process/time
	emf? (
		dev-java/freehep-graphicsio:0
		dev-java/freehep-graphicsio-emf:0
		dev-java/freehep-graphics2d:0
		dev-java/freehep-io:0
		dev-java/freehep-graphicsbase:0
	)
	fftw? ( sci-libs/fftw:3.0 )
	gui? (
		dev-java/avalon-framework:4.2
		>=dev-java/batik-1.9:1.9
		dev-java/commons-io:1
		dev-java/commons-logging:0
		>=dev-java/flexdock-1.2.4:0
		>=dev-java/fop-2.0:0
		~dev-java/gluegen-2.2.4:2.2
		dev-java/javahelp:0
		dev-java/jeuclid-core:0
		dev-java/jgoodies-looks:2.6
		>=dev-java/jlatexmath-1.0.3:1
		>=dev-java/jlatexmath-fop-1.0.3:1
		~dev-java/jogl-2.2.4:2.2
		>=dev-java/jrosetta-1.0.4:0
		>dev-java/lucene-5:=[modules(-)]
		<dev-java/lucene-7:=[modules(-)]
		dev-java/skinlf:0
		dev-java/xmlgraphics-commons:2
		virtual/opengl
		xcos? ( dev-java/jgraphx:0 )
		)
	matio? ( >=sci-libs/matio-1.5 )
	mpi? ( virtual/mpi[fortran] )
	tk? ( dev-lang/tk:0= )
	umfpack? ( sci-libs/umfpack )"

RDEPEND="${CDEPEND}
	gui? ( >=virtual/jre-1.8 )"

DEPEND="${CDEPEND}
	debug? ( dev-util/lcov )
	gui? (
		>=virtual/jdk-1.6
		doc? (
			app-text/docbook-xsl-stylesheets
			dev-java/xml-commons-external:1.4
			dev-java/saxon:9
		)
		xcos? (
			>=dev-lang/ocaml-4.06
			dev-ml/num
		)
	)
	test? (
		dev-java/junit:4
		dev-java/ant-junit4:0
		gui? ( ${VIRTUALX_DEPEND} ) )"
BDEPEND="virtual/pkgconfig"

DOCS=( "ACKNOWLEDGEMENTS" "README_Unix" "Readme_Visual.txt" )

PATCHES=(
	"${FILESDIR}/${PN}-5.5.2-followlinks.patch"
	"${FILESDIR}/${PN}-5.5.2-gluegen.patch"
	"${FILESDIR}/${PN}-5.5.2-ocaml-4.0.4.patch"
	"${FILESDIR}/${PN}-6.1.0-accessviolation.patch"
	"${FILESDIR}/${PN}-5.5.2-missinglib.patch"
	"${FILESDIR}/${PN}-6.1.0-freehep.patch"
	"${FILESDIR}/${PN}-6.1.0-libxml.patch"
)

pkg_pretend() {
	use doc && CHECKREQS_MEMORY="512M" check-reqs_pkg_pretend
}

pkg_setup() {
	if use openmp; then
		if [[ $(tc-getCC) == *gcc* ]] && ! tc-has-openmp; then
			ewarn "You are using a gcc without OpenMP capabilities"
			die "Need an OpenMP capable compiler"
		fi
		FORTRAN_NEED_OPENMP=1
	fi
	FORTRAN_STANDARD="77 90"
	fortran-2_pkg_setup
	#bug 8053
	unset F77
	java-pkg-opt-2_pkg_setup

	# fails to compile in src/fortran/optml2.f:172:50 without this
	test-flag-FC -fallow-argument-mismatch && append-fflags -fallow-argument-mismatch
	# failure in src/cpp/GetSparseVariable.cpp:106:22
	append-cxxflags -fpermissive

	ALL_L10N="en_US"
	ALL_L10N_DOC="en_US"
	for l in ${IUSE_L10N}; do
		use l10n_${l} && ALL_L10N="${ALL_L10N} ${l}"
	done
	for l in ${L10N_DOC}; do
		use l10n_${l} && ALL_L10N_DOC="${ALL_L10N_DOC} ${l}"
	done
	export ALL_L10N ALL_L10N_DOC
}

src_prepare() {
	default

	# increases java heap to 512M when building docs (sync with cheqreqs above)
	use doc && eapply "${FILESDIR}/${P}-java-heap.patch"

	# use the L10N variable that we set
	sed -i -e "/^ALL_LINGUAS=/d" -e "/^ALL_LINGUAS_DOC=/d" -i configure.ac ||die

	# make sure the DOCBOOK_ROOT variable is set
	sed -i -e "s/xsl-stylesheets-\*/xsl-stylesheets/g" bin/scilab* || die

	# fix QA for metainfo data installation path
	sed -i.bkp -e "s:/appdata:/metainfo:" desktop/Makefile.in || die

	# remove self closing <br /> (error our with javadoc8)
	# already upstream commit 2103082c
	find . -name '*.java' -exec sed -i "s|<br />|<BR>|" {} \; ||die

	#add specific gentoo java directories
	if use gui; then
		sed -i -e "s|/usr/lib/jogl2|/usr/lib/jogl-2.2|" \
			-e "s|/usr/lib64/jogl2|/usr/lib64/jogl-2.2|" configure.ac || die
		sed -i -e "s|/usr/lib/gluegen2|/usr/lib/gluegen-2.2|" \
			-e "s|/usr/lib64/gluegen2|/usr/lib64/gluegen-2.2|" \
			-e "s|AC_CHECK_LIB(\[gluegen2-rt|AC_CHECK_LIB([gluegen-rt|" \
			configure.ac || die

		sed -i -e "s/jogl2/jogl-2.2/" -e "s/gluegen2/gluegen-2.2/" \
			etc/librarypath.xml || die
	fi

	mkdir jar || die
	pushd jar >/dev/null
	if use gui; then
		java-pkg_jar-from jlatexmath-1,flexdock,skinlf
		java-pkg_jar-from jgoodies-looks-2.6,jrosetta
		java-pkg_jar-from avalon-framework-4.2,jeuclid-core
		java-pkg_jar-from xmlgraphics-commons-2,commons-io-1
		java-pkg_jar-from jogl-2.2 jogl-all.jar jogl2.jar
		java-pkg_jar-from gluegen-2.2 gluegen-rt.jar gluegen2-rt.jar
		java-pkg_jar-from fop fop.jar
		java-pkg_jar-from javahelp jhall.jar
		java-pkg_jar-from jlatexmath-fop-1
		use xcos &&	java-pkg_jar-from jgraphx
		if use doc; then
			java-pkg_jar-from --build-only batik-1.9 batik-all.jar
			java-pkg_jar-from --build-only saxon-9 saxon.jar saxon9he.jar
			java-pkg_jar-from --build-only xml-commons-external-1.4 xml-apis-ext.jar
		fi
	fi
	if use emf; then
		java-pkg_jar-from freehep-graphicsio-emf,freehep-graphics2d
		java-pkg_jar-from freehep-graphicsio,freehep-io,freehep-graphicsbase
	fi
	if use test; then
		java-pkg_jar-from junit-4 junit.jar junit4.jar
		java-pkg_jar-from ant-junit
	fi
	popd

	java-pkg-opt-2_src_prepare
	eautoconf
}

src_configure() {
	if use gui; then
		export JAVA_HOME="$(java-config -O)"
	else
		unset JAVAC
	fi

	export BLAS_LIBS="$($(tc-getPKG_CONFIG) --libs blas)"
	export LAPACK_LIBS="$($(tc-getPKG_CONFIG) --libs lapack)"
	export F77_LDFLAGS="${LDFLAGS}"

	econf \
		--enable-relocatable \
		--disable-rpath \
		--with-docbook="${EPREFIX}/usr/share/sgml/docbook/xsl-stylesheets" \
		--disable-static-system-lib \
		$(use_enable debug) \
		$(use_enable debug code-coverage) \
		$(use_enable debug debug-C) \
		$(use_enable debug debug-CXX) \
		$(use_enable debug debug-fortran) \
		$(use_enable debug debug-java) \
		$(use_enable debug debug-linker) \
		$(use_enable doc build-help) \
		$(use_enable nls) \
		$(use_enable nls build-localization) \
		$(use_enable static-libs static) \
		$(use_enable test compilation-tests) \
		$(use_with emf) \
		$(use_with fftw) \
		$(use_with gui) \
		$(use_with gui javasci) \
		$(use_with matio) \
		$(use_with openmp) \
		$(use_with tk) \
		$(use_with umfpack) \
		$(use_with xcos) \
		$(use_with xcos modelica) \
		$(use_with mpi)
}

src_compile() {
	addpredict /proc/mtrr
	default
	pax-mark m .libs/scilab-bin
	use doc && emake doc
}

src_test() {
	if use gui; then
		Xemake check
	else
		emake check
	fi
}

src_install() {
	default
	find "${ED}" -name '*.la' -delete || die
	rm -rf "${D}"/usr/share/scilab/modules/*/tests ||die
	newbashcomp "${FILESDIR}"/"${PN}".bash_completion "${PN}"
	bashcomp_alias ${PN} ${PN}-cli ${PN}-adv-cli
	echo "SEARCH_DIRS_MASK=${EPREFIX}/usr/$(get_libdir)/scilab" \
		> 50-"${PN}"
	insinto /etc/revdep-rebuild && doins "50-${PN}"
}

pkg_postinst() {
	xdg_mimeinfo_database_update
	xdg_desktop_database_update
	einfo "If you are using the NVIDIA binary drivers, and run into graphics"
	einfo "crashes, you may try to run scilab as follows:"
	einfo "EGL_DRIVER=egl_glx scilab"
	einfo "See upstream http://bugzilla.scilab.org/show_bug.cgi?id=12940"
}

pkg_postrm() {
	xdg_mimeinfo_database_update
	xdg_desktop_database_update
}