summaryrefslogtreecommitdiff
blob: efba8079f9e0f65e1a6d6c6d13dc7a70ce68829f (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
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit bash-completion-r1 cmake-utils

DESCRIPTION="Powerful map generator"
HOMEPAGE="https://gmt.soest.hawaii.edu/"
SRC_URI="mirror://gmt/${P}-src.tar.xz"

LICENSE="GPL-3+ gmttria? ( Artistic )"
SLOT="5"
KEYWORDS="~amd64 ~x86"
IUSE="+dcw doc examples +fftw +gdal gmttria +gshhg htmldoc lapack openmp pcre pcre2 threads tutorial"

RDEPEND="
	!sci-biology/probcons
	app-text/ghostscript-gpl
	dcw? ( sci-geosciences/dcw-gmt )
	fftw? ( sci-libs/fftw:3.0/3 )
	gdal? ( sci-libs/gdal )
	gshhg? ( sci-geosciences/gshhg-gmt )
	>=sci-libs/netcdf-4.1[hdf5]
	lapack? ( virtual/lapack )
	pcre? ( dev-libs/libpcre )
	pcre2? ( dev-libs/libpcre2 )
	net-misc/curl
	sys-libs/zlib"

DEPEND="${RDEPEND}"

REQUIRED_USE="?? ( pcre pcre2 )"

src_prepare() {
	cmake-utils_src_prepare
	# Rename man pages to avoid a name conflict with gmt4
	pushd man_release || die
	local m c suffix newc
	for m in *.gz; do
		c=${m%%.*}
		suffix=${m#*.}
		newc=gmt_${c}
		# This man pages does'nt conflict
		case "${c}" in
		"gmt" | "gmt.conf" | "postscriptlight")
			continue ;;
		"gmt_shell_functions")
			newc=gmt5_shell_functions ;;
		"gmtcolors")
			newc=gmt5colors ;;
		esac
		mv "${c}.${suffix}" "${newc}.${suffix}" || die
	done
	popd || die
}

src_configure() {
	local mycmakeargs=(
		-DLICENSE_RESTRICTED="$(usex gmttria no yes)"
		-DGMT_OPENMP="$(usex openmp)"
		-DGMT_USE_THREADS="$(usex threads)"
		-DGMT_INSTALL_TRADITIONAL_FOLDERNAMES=OFF # Install bash completions properly
		-DGMT_INSTALL_MODULE_LINKS=OFF # Don't install symlinks on gmt binary, they are conflicted with gmt4
		-DBASH_COMPLETION_DIR="$(get_bashcompdir)"
		-DGMT_DATADIR="share/${P}"
		-DGMT_DOCDIR="share/doc/${PF}"
		-DGMT_MANDIR="share/man"
	)
	use fftw || mycmakeargs+=( -DGMT_EXCLUDE_FFTW3=yes )
	use gdal || mycmakeargs+=( -DGMT_EXCLUDE_GDAL=yes )
	use lapack || mycmakeargs+=( -DGMT_EXCLUDE_LAPACK=yes )
	use pcre || mycmakeargs+=( -DGMT_EXCLUDE_PCRE=yes )
	use pcre2 || mycmakeargs+=( -DGMT_EXCLUDE_PCRE2=yes )
	cmake-utils_src_configure
}

src_install() {
	cmake-utils_src_install
	# Remove various documentation
	if ! use doc; then
		rm -rf "${ED}/usr/share/doc/${PF}/pdf" || die
	fi

	if use examples; then
		docompress -x /usr/share/doc/${PF}/examples
	else
		rm -rf "${ED}/usr/share/doc/${PF}/examples" || die
	fi

	if ! use htmldoc; then
		rm -rf "${ED}/usr/share/doc/${PF}/html" || die
	fi

	if use tutorial; then
		docompress -x /usr/share/doc/${PF}/tutorial
	else
		rm -rf "${ED}/usr/share/doc/${PF}/tutorial" || die
	fi

	# Decompress manuals
	find "${ED}/usr/share/man" -name "*.gz" -exec gunzip {} + || die
	# Rename some files to avoid a name conflict with gmt4
	mv "${ED}/usr/bin/gmt_shell_functions.sh" "${ED}/usr/bin/gmt5_shell_functions.sh" || die
	mv "${ED}/usr/bin/isogmt" "${ED}/usr/bin/isogmt5" || die
	rm "${ED}/usr/bin/gmtswitch" || die
	# Rename bash completion file
	mv "${D}$(get_bashcompdir)/gmt_completion.bash" "${D}$(get_bashcompdir)/gmt" || die
}