summaryrefslogtreecommitdiff
path: root/dev-libs/xerces-c/xerces-c-9999.ebuild
blob: b55d69fb6bcddece6729355779566ecfb7e39afb (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
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2

EAPI=8

inherit cmake flag-o-matic prefix

DESCRIPTION="Validating XML parser written in a portable subset of C++"
HOMEPAGE="https://xerces.apache.org/xerces-c/"

if [[ ${PV} == *9999 ]] ; then
	EGIT_REPO_URI="https://github.com/apache/xerces-c"
	EGIT_BRANCH="master"
	inherit git-r3
else
	SRC_URI="
		mirror://apache/xerces/c/3/sources/${P}.tar.xz
	"
	KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~loong ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86 ~x64-macos"
fi

LICENSE="Apache-2.0"
SLOT="0/$(ver_cut 1-2)"
IUSE="cpu_flags_x86_sse2 curl doc examples iconv icu static-libs test"

# needs 'gencat' on glibc or ICU on musl:
# https://bugs.gentoo.org/830270
REQUIRED_USE="elibc_musl? ( icu )"

RESTRICT="!test? ( test )"

RDEPEND="
	curl? ( net-misc/curl )
	icu? ( dev-libs/icu:0= )
	virtual/libiconv"
DEPEND="${RDEPEND}"
BDEPEND="
	doc? ( app-text/doxygen )
	test? ( dev-lang/perl )"

DOCS=( CREDITS KEYS NOTICE README )

PATCHES=(
	"${FILESDIR}"/${PN}-3.2.4-strict-aliasing.patch
)

pkg_setup() {
	export ICUROOT="${EPREFIX}/usr"

	if use iconv && use icu; then
		ewarn "This package can use iconv or icu for loading messages"
		ewarn "and transcoding, but not both. ICU takes precedence."
	fi
}

src_configure() {
	# bug #856100
	filter-lto
	append-flags -fno-strict-aliasing

	# 'cfurl' is only available on OSX and 'socket' isn't supposed to work.
	# But the docs aren't clear about it, so we would need some testing...
	local netaccessor
	if use curl; then
		netaccessor="curl"
	elif use elibc_Darwin; then
		netaccessor="cfurl"
	else
		netaccessor="socket"
	fi

	local msgloader
	if use icu; then
		msgloader="icu"
	elif use iconv; then
		msgloader="iconv"
	else
		msgloader="inmemory"
	fi

	local transcoder
	if use icu; then
		transcoder="icu"
	elif use elibc_Darwin; then
		transcoder="macosunicodeconverter"
	else
		transcoder="gnuiconv"
	fi

	local mycmakeargs=(
		-DCMAKE_INSTALL_DOCDIR="${EPREFIX}/usr/share/doc/${PF}"
		-Dnetwork-accessor="${netaccessor}"
		-Dmessage-loader="${msgloader}"
		-Dtranscoder="${transcoder}"
		# always select the "standard" Mutex Manager:
		# https://bugs.gentoo.org/972564
		-Dthreads:BOOL=ON
		-Dsse2:BOOL="$(usex cpu_flags_x86_sse2)"
	)

	cmake_src_configure
}

src_compile() {
	cmake_src_compile

	use doc && cmake_build doc-style createapidocs doc-xml
}

src_install() {
	cmake_src_install

	# package provides .pc files
	find "${D}" -name '*.la' -delete || die

	if use examples; then
		# clean out object files, executables, Makefiles
		# and the like before installing examples
		find samples/ \( -type f -executable -o -iname 'runConfigure' -o -iname '*.o' \
			-o -iname '.libs' -o -iname 'Makefile*' \) -exec rm -rf '{}' + || die
		docinto examples
		dodoc -r samples/.
		docompress -x /usr/share/doc/${PF}/examples
	fi

	# To make sure an appropriate NLS msg file is around when using
	# the iconv msgloader ICU has the messages compiled in.
	if use iconv && ! use icu; then
		doenvd "$(prefixify_ro "${FILESDIR}/50xerces-c")"
	fi
}