1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
7 PHP_EXT_OPTIONAL_USE="php"
9 PHP_EXT_SKIP_PHPIZE="yes"
10 # Will add php5-4 support as soon as someone fixes gentoo bug 404453 with swig 2.0.4
11 # or upstream fixes the build error with swig >= 2.0.8
14 PYTHON_COMPAT=( python2_{6,7} )
16 USE_RUBY="ree18 ruby18 ruby19"
19 inherit autotools eutils java-pkg-opt-2 mono perl-module php-ext-source-r2 python-r1 ruby-ng toolchain-funcs versionator
21 DESCRIPTION="A library that implements the RETS 1.8, 1.7, 1.5 and 1.0 standards"
22 HOMEPAGE="http://www.crt.realtors.org/projects/rets/librets/"
23 SRC_URI="http://www.crt.realtors.org/projects/rets/${PN}/files/${P}.tar.gz"
27 KEYWORDS="~amd64 ~x86"
28 IUSE="doc java mono perl php python ruby sql-compiler threads"
29 # Enabling threads for perl, php, python or ruby causes segmentation faults in cli scripts but not through apache
30 REQUIRED_USE="perl? ( !threads )
35 SWIG_RDEPEND="dev-libs/libgcrypt
41 RDEPEND=">=dev-libs/boost-1.46
43 >=dev-util/boost-build-1.46
45 sql-compiler? ( dev-java/antlr:0[script] )
47 java? ( >=virtual/jdk-1.6.0 ${SWIG_RDEPEND} )
48 mono? ( dev-lang/mono ${SWIG_RDEPEND} )
49 php? ( ${SWIG_RDEPEND} )
50 python? ( ${SWIG_RDEPEND} )
51 ruby? ( $(ruby_implementations_depend) ${SWIG_RDEPEND} )"
53 # An upstream bug prevents the php extension from building with swig >= 2.0.5
54 DEPEND="java? ( >=dev-lang/swig-1.3.40-r1 )
55 mono? ( >=dev-lang/swig-1.3.40-r1 )
56 php? ( <dev-lang/swig-2.0.5 >=dev-lang/swig-1.3.40-r1 )
57 python? ( >=dev-lang/swig-1.3.40-r1 )
58 ruby_targets_ruby18? ( >=dev-lang/swig-1.3.40-r1 )
59 ruby_targets_ruby18? ( >=dev-lang/swig-1.3.40-r1 )
60 ruby_targets_ruby19? ( >=dev-lang/swig-2.0.4-r1 )
63 # Reset to the default $S since ruby-ng overrides it
68 # Since php-ext-source-r2_src_install tries to install non-existant headers
69 # and a bad emake fails on EAPI 4, a copied subset must be used instead (bug 404307).
70 my_php-ext-source-r2_src_install() {
72 for slot in $(php_get_slots); do
73 php_init_slot_env ${slot}
74 # Let's put the default module away
76 newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
78 php-ext-source-r2_createinifiles
81 my_php-move_swig_build_to_modules_dir() {
82 mkdir "${1}"/modules || die "Could not create directory for php slot"
83 mv build/swig/php5/* "${1}"/modules || die "Could not move php slot build"
86 my_php-replace_config_with_selected_config() {
87 php_init_slot_env ${1}
88 cd "${S}" || die "cannot change to source directory"
89 # Replace the reference to php-config with the current slotted one
90 sed -i -e "s|${2}|${PHPCONFIG}|g" project/build/php.mk || die "sed php-config change failed"
93 my_ruby-move_swig_build_to_impl_dir() {
94 mkdir -p "${1}"/${P} || die "Could not create directory for ruby implementation"
95 mv build/swig/ruby/* "${1}"/${P} || die "Could not move ruby implementation build"
99 use java && java-pkg-opt-2_pkg_setup
100 use perl && perl-module_pkg_setup
101 use ruby && ruby-ng_pkg_setup
105 use php && php-ext-source-r2_src_unpack
110 # Patch to allow the ruby extension to compile when multiple versions of boost are installed
111 epatch "${FILESDIR}"/${P}-extconf.rb.patch
112 # Patch to fix compilation errors by removing the java examples target when building for java
113 epatch "${FILESDIR}"/${P}-java.mk.patch
114 # add missing LDFLAGS and change CFLAGS to CXXFLAGS
115 epatch "${FILESDIR}"/${P}-build.patch
118 # Change the path to librets-config-inplace for python slotted build support
120 sed -i -e "s|../../..|${S}|" project/swig/python/setup.py || die
123 use php && php-ext-source-r2_src_prepare
130 # Enable php extension when it finds the current selected slot
131 myphpprefix="${PHPPREFIX}/include"
134 # The build system just finds "python", which could be python3.2 if EPYTHON is unset.
135 use python && python_export_best EPYTHON
138 MYRUBYIMPLS=($(ruby_get_use_implementations))
139 MYRUBYFIRSTIMPL=${MYRUBYIMPLS[0]}
140 # Set RUBY value in config to the first ruby implementation to build
141 RUBY=$(ruby_implementation_command ${MYRUBYFIRSTIMPL})
142 MYRUBYIMPLS=(${MYRUBYIMPLS[@]:1})
145 # Allow cross-compiling between operating systems since ar is not portable
148 --enable-shared_dependencies \
150 --enable-default-search-path="/usr /opt ${myphpprefix}" \
153 $(usex doc "--enable-maintainer-documentation") \
154 $(usex java "" "--disable-java") \
155 $(usex mono "" "--disable-dotnet") \
156 $(usex perl "" "--disable-perl") \
157 $(usex php "" "--disable-php") \
158 $(usex python "" "--disable-python") \
159 $(usex threads "--enable-thread-safe") \
160 $(use_enable sql-compiler) \
161 $(use_with mono "snk-file" "${FILESDIR}"/${PN}.snk) \
162 $(usex ruby " RUBY=${RUBY}" "--disable-ruby")
167 local slot myphpconfig="php-config"
168 # Shift off the first slot so it doesn't get built again
169 local myphpslots=($(php_get_slots)) myphpfirstslot="${myphpslots[@]:0:1}" myphpslots=(${myphpslots[@]:1})
170 my_php-replace_config_with_selected_config ${myphpfirstslot} ${myphpconfig}
171 myphpconfig="${PHPCONFIG}"
175 # Move the current slotted build of php to another dir so other slots can be built
176 my_php-move_swig_build_to_modules_dir "${WORKDIR}/${myphpfirstslot}"
177 # Build the remaining slots
178 for slot in ${myphpslots[@]}; do
179 my_php-replace_config_with_selected_config ${slot} ${myphpconfig}
180 myphpconfig="${PHPCONFIG}"
181 # Build the current slot
182 emake build/swig/php5/${PN}.so
183 my_php-move_swig_build_to_modules_dir "${PHP_EXT_S}"
187 # Build the remaining python implementations
188 use python && python_foreach_impl emake
191 # Move the current implementation build of ruby to another dir so other implementations can be built
192 my_ruby-move_swig_build_to_impl_dir "${WORKDIR}/${MYRUBYFIRSTIMPL}"
193 unset MYFIRSTRUBYIMPL
196 MYRUBYIMPL="\${RUBY}"
197 # Build the remaining implementations
198 for impl in ${MYRUBYIMPLS[@]}; do
199 cd "${S}" || die "cannot change to source directory"
200 # Replace the reference to ${RUBY} with the current implementation
201 sed -i -e "s|${MYRUBYIMPL}|$(ruby_implementation_command ${impl})|g" \
202 project/build/ruby.mk || die "sed ruby implementation change failed"
203 MYRUBYIMPL="$(ruby_implementation_command ${impl})"
204 # Build the current implementation
205 emake build/swig/ruby/${PN}_native.bundle
206 my_ruby-move_swig_build_to_impl_dir "${WORKDIR}/${impl}"
214 each_ruby_install() {
215 exeinto "$(ruby_rbconfig_value archdir)"
216 doexe "${S}"/librets_native.so
217 doruby "${S}"/librets.rb
221 dolib.a build/${PN}/lib/${PN}.a
224 doins -r project/${PN}/include/${PN}
229 my_php-ext-source-r2_src_install
230 insinto /usr/share/php
231 doins "${WORKDIR}"/php"${PHP_CURRENTSLOT}"/modules/${PN}.php
235 # Install manually since the package install has sandbox violations
238 doins -r "${S}"/build/swig/perl/blib/arch/auto
240 doins "${S}"/build/swig/perl/${PN}.pm
244 java-pkg_dojar "${S}"/build/swig/java/${PN}.jar
245 LIBOPTIONS="-m755" java-pkg_doso "${S}"/build/swig/java/${PN}.so
248 use ruby && ruby-ng_src_install
251 egacinstall "${S}"/build/swig/csharp/${PN}-dotnet.dll
256 pushd "${S}"/build/swig/python || die
257 "${PYTHON}" setup.py install --root="${D}" || die
260 python_foreach_impl python_install
265 use perl && perl-module_pkg_preinst
269 use perl && perl-module_pkg_postinst
273 use perl && perl-module_pkg_prerm
277 use perl && perl-module_pkg_postrm