blob: 1e5b783e5da671a674c854dafa1f75064b794c22 (
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
307
|
# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI="5"
PHP_EXT_OPTIONAL_USE="php"
PHP_EXT_NAME="librets"
PHP_EXT_SKIP_PHPIZE="yes"
USE_PHP="php5-3 php5-4 php5-5"
PYTHON_COMPAT=( python2_7 python3_{2,3} )
USE_RUBY="ruby19 ruby20"
RUBY_OPTIONAL="yes"
inherit autotools eutils java-pkg-opt-2 mono-env perl-module php-ext-source-r2 python-r1 ruby-ng toolchain-funcs
DESCRIPTION="A library that implements the RETS 1.8, 1.7, 1.5 and 1.0 standards"
HOMEPAGE="http://www.crt.realtors.org/projects/rets/librets/"
SRC_URI="http://www.crt.realtors.org/projects/rets/${PN}/files/${P}.tar.gz"
LICENSE="BSD-NAR"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="doc java mono perl php python ruby sql-compiler threads"
# Enabling thread safety for perl, php, python or ruby causes segmentation faults in cli scripts but not through apache
REQUIRED_USE="mono? ( sql-compiler )
perl? ( !threads )
php? ( !threads )
python? ( !threads )
ruby? ( !threads )"
SWIG_RDEPEND="dev-libs/libgcrypt
dev-libs/libgpg-error
dev-libs/libtasn1
net-dns/libidn
net-libs/gnutls"
RDEPEND=">=dev-libs/boost-1.46
dev-libs/expat
>=dev-util/boost-build-1.46
net-misc/curl
sql-compiler? ( dev-java/antlr:0[script] )
sys-libs/zlib
java? ( >=virtual/jdk-1.6.0 ${SWIG_RDEPEND} )
mono? ( dev-lang/mono ${SWIG_RDEPEND} )
php? ( ${SWIG_RDEPEND} )
python? ( ${SWIG_RDEPEND} ${PYTHON_DEPS} )
ruby? ( $(ruby_implementations_depend) ${SWIG_RDEPEND} )"
DEPEND="java? ( >=dev-lang/swig-1.3.40-r1 )
mono? ( >=dev-lang/swig-1.3.40-r1 )
php? ( dev-lang/php[-threads] >=dev-lang/swig-1.3.40-r1 )
python? ( >=dev-lang/swig-1.3.40-r1 )
ruby_targets_ruby19? ( >=dev-lang/swig-2.0.4-r1 )
ruby_targets_ruby20? ( >=dev-lang/swig-2.0.4-r1 )
${RDEPEND}"
# Reset to the default $S since ruby-ng overrides it
S="${WORKDIR}/${P}"
unset SWIG_RDEPEND
# Since php-ext-source-r2_src_install tries to install non-existant headers
# and a bad emake fails on EAPI 4, a copied subset must be used instead (bug 404307).
my_php-ext-source-r2_src_install() {
local slot
for slot in $(php_get_slots); do
php_init_slot_env ${slot}
# Let's put the default module away
insinto "${EXT_DIR}"
newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
done
php-ext-source-r2_createinifiles
}
my_php-move_swig_build_to_modules_dir() {
mkdir "${1}"/modules || die "Could not create directory for php slot"
mv build/swig/php5/* "${1}"/modules || die "Could not move php slot build"
}
my_php-replace_config_with_selected_config() {
php_init_slot_env ${1}
cd "${S}" || die "cannot change to source directory"
# Replace the reference to php-config with the current slotted one
sed -i -e "s|${2}|${PHPCONFIG}|g" project/build/php.mk || die "sed php-config change failed"
}
my_ruby-move_swig_build_to_impl_dir() {
mkdir -p "${1}"/${P} || die "Could not create directory for ruby implementation"
mv build/swig/ruby/* "${1}"/${P} || die "Could not move ruby implementation build"
}
my_python3-move_swig_build_to_impl_dir() {
# Only move if something there are files in the python3 directory
if [ "$(ls -A build/swig/python3)" ]; then
mkdir -p build/swig/"${1}" || die "Could not create directory for python3 implementation"
cp -R build/swig/python3/* build/swig/"${1}" || die "Could not move python3 implementation build"
rm -r build/swig/python3/build || die "Could not remove python3 build"
fi
}
pkg_setup() {
use java && java-pkg-opt-2_pkg_setup
use mono && mono-env_pkg_setup
use ruby && ruby-ng_pkg_setup
}
src_unpack() {
use php && php-ext-source-r2_src_unpack
default
}
src_prepare() {
epatch "${FILESDIR}"/${P}-fix-php-build-errors.patch \
"${FILESDIR}"/${P}-extconf.rb.patch \
"${FILESDIR}"/${P}-java.mk.patch
epatch_user
eautoreconf
if use python; then
# Change the path to librets-config-inplace for python slotted build support
sed -i -e "s|../../..|${S}|" project/swig/python/setup.py project/swig/python3/setup.py || die
# Remove the build-lib path for python slotted build support
sed -i -e "s| --build-lib=.||" project/build/python3.mk || die
fi
use php && php-ext-source-r2_src_prepare
}
src_configure() {
local myphpprefix
if use php; then
# Enable php extension when it finds the current selected slot
myphpprefix="${PHPPREFIX}/include"
fi
# The build system just finds "python", which could be any version of python if EPYTHON is unset.
use python && python_export_best EPYTHON
if use ruby; then
MYRUBYIMPLS=($(ruby_get_use_implementations))
MYRUBYFIRSTIMPL=${MYRUBYIMPLS[0]}
# Set RUBY value in config to the first ruby implementation to build
RUBY=$(ruby_implementation_command ${MYRUBYFIRSTIMPL})
MYRUBYIMPLS=(${MYRUBYIMPLS[@]:1})
fi
# Allow cross-compiling between operating systems since ar is not portable
tc-export AR
econf \
--enable-shared_dependencies \
--enable-depends \
--enable-default-search-path="/usr /opt ${myphpprefix}" \
--disable-examples \
--disable-debug \
$(usex doc "--enable-maintainer-documentation") \
$(usex java "" "--disable-java") \
$(usex mono "" "--disable-dotnet") \
$(usex perl "" "--disable-perl") \
$(usex php "" "--disable-php") \
$(usex python "" "--disable-python") \
$(usex threads "--enable-thread-safe") \
$(use_enable sql-compiler) \
$(use_with mono "snk-file" "${FILESDIR}"/${PN}.snk) \
$(usex ruby " RUBY=${RUBY}" "--disable-ruby")
}
src_compile() {
if use php; then
local slot myphpconfig="php-config"
# Shift off the first slot so it doesn't get built again
local myphpslots=($(php_get_slots)) myphpfirstslot="${myphpslots[@]:0:1}" myphpslots=(${myphpslots[@]:1})
my_php-replace_config_with_selected_config ${myphpfirstslot} ${myphpconfig}
myphpconfig="${PHPCONFIG}"
fi
emake
if use php; then
# Move the current slotted build of php to another dir so other slots can be built
my_php-move_swig_build_to_modules_dir "${WORKDIR}/${myphpfirstslot}"
# Build the remaining slots
for slot in ${myphpslots[@]}; do
my_php-replace_config_with_selected_config ${slot} ${myphpconfig}
myphpconfig="${PHPCONFIG}"
# Build the current slot
emake build/swig/php5/${PN}.so
my_php-move_swig_build_to_modules_dir "${PHP_EXT_S}"
done
fi
if use python; then
local selectedPython3=$(eselect python show --python3)
my_python3-move_swig_build_to_impl_dir ${selectedPython3}
building() {
# Skip python 2.7 and the selected python3 interpreter since it was already built when make ran the first time
if [ "${EPYTHON:6:1}" = "2" ] || [ "${EPYTHON}" = "${selectedPython3}" ]; then
return 0
fi
pushd "${S}"/build/swig/python3 || die
"${PYTHON}" setup.py build || die
popd
my_python3-move_swig_build_to_impl_dir ${EPYTHON}
}
python_foreach_impl building
fi
if use ruby; then
# Move the current implementation build of ruby to another dir so other implementations can be built
my_ruby-move_swig_build_to_impl_dir "${WORKDIR}/${MYRUBYFIRSTIMPL}"
unset MYFIRSTRUBYIMPL
unset RUBY
local impl
MYRUBYIMPL="\${RUBY}"
# Build the remaining implementations
for impl in ${MYRUBYIMPLS[@]}; do
cd "${S}" || die "cannot change to source directory"
# Replace the reference to ${RUBY} with the current implementation
sed -i -e "s|${MYRUBYIMPL}|$(ruby_implementation_command ${impl})|g" \
project/build/ruby.mk || die "sed ruby implementation change failed"
MYRUBYIMPL="$(ruby_implementation_command ${impl})"
# Build the current implementation
emake build/swig/ruby/${PN}_native.bundle
my_ruby-move_swig_build_to_impl_dir "${WORKDIR}/${impl}"
done
unset MYRUBYIMPL
unset MYRUBYIMPLS
unset impl
fi
}
each_ruby_install() {
exeinto "$(ruby_rbconfig_value archdir)"
doexe "${S}"/librets_native.so
doruby "${S}"/librets.rb
}
src_install() {
dolib.a build/${PN}/lib/${PN}.a
insinto /usr/include
doins -r project/${PN}/include/${PN}
dobin "${PN}-config"
if use php; then
my_php-ext-source-r2_src_install
insinto /usr/share/php
doins "${WORKDIR}"/php"${PHP_CURRENTSLOT}"/modules/${PN}.php
fi
if use perl; then
# Install manually since the package install has sandbox violations
insinto ${SITE_ARCH}
insopts "-m755"
doins -r "${S}"/build/swig/perl/blib/arch/auto
insopts "-m644"
doins "${S}"/build/swig/perl/${PN}.pm
fi
if use java; then
java-pkg_dojar "${S}"/build/swig/java/${PN}.jar
LIBOPTIONS="-m755" java-pkg_doso "${S}"/build/swig/java/${PN}.so
fi
use ruby && ruby-ng_src_install
if use mono; then
local dll="${S}"/build/swig/csharp/${PN}-dotnet.dll
gacutil -i "${dll}" \
-root "${ED}"/usr/$(get_libdir) \
-gacdir /usr/$(get_libdir) \
-package ${PN} \
|| die "installing ${dll} into the Global Assembly Cache failed"
fi
if use python; then
python_install() {
local pythonversion
# build files for python 3 reside in folders with slot versions
if [ "${EPYTHON:6:1}" = "3" ]; then
pythonversion=${EPYTHON:6}
fi
pushd "${S}"/build/swig/python${pythonversion} || die
"${PYTHON}" setup.py install --root="${D}" || die
popd
}
python_foreach_impl python_install
fi
}
pkg_preinst() {
:
}
pkg_postinst() {
:
}
pkg_prerm() {
:
}
pkg_postrm() {
:
}
|