1 # Copyright 1999-2011 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 USE_PHP="php5-2 php5-3"
12 PYTHON_DEPEND="python? 2"
13 PYTHON_MODNAME="librets.py"
15 USE_RUBY="ree18 ruby18 ruby19"
18 inherit distutils eutils java-pkg-opt-2 mono multilib perl-module php-ext-source-r2 ruby-ng versionator
20 DESCRIPTION="A library that implements the RETS 1.7, RETS 1.5 and 1.0 standards"
21 HOMEPAGE="http://www.crt.realtors.org/projects/rets/librets/"
22 SRC_URI="http://www.crt.realtors.org/projects/rets/${PN}/files/${P}.tar.gz"
26 KEYWORDS="~amd64 ~x86"
27 IUSE="debug doc java mono perl php python ruby sql-compiler threads"
29 for i in java perl php python ruby; do
30 SWIG_DEPEND+=" ${i}? ( dev-lang/swig )"
31 SWIG_RDEPEND+=" ${i}? (
43 <dev-util/boost-build-1.46
44 java? ( >=virtual/jdk-1.6.0 )
45 mono? ( dev-lang/mono )
47 ruby? ( $(ruby_implementations_depend) )
48 sql-compiler? ( dev-java/antlr:0[script] )
52 DEPEND="${RDEPEND} ${SWIG_DEPEND}"
58 _php-move_swig_build_to_modules_dir() {
59 mkdir "${1}"/modules || die "Could not create directory for php slot"
60 mv build/swig/php5/* "${1}"/modules || die "Could not move php slot build"
63 _php-replace_config_with_selected_config() {
64 php_init_slot_env ${1}
65 cd "${S}" || die "cannot change to source directory"
66 # Replace the reference to php-config with the current slotted one
67 sed -i -e "s|${2}|${PHPCONFIG}|g" project/build/php.mk || die "sed php-config change failed"
70 _ruby-move_swig_build_to_impl_dir() {
71 mkdir -p "${1}"/${P} || die "Could not create directory for ruby implementation"
72 mv build/swig/ruby/* "${1}"/${P} || die "Could not move ruby implementation build"
76 use java && java-pkg-opt-2_pkg_setup
77 use perl && perl-module_pkg_setup
79 python_set_active_version 2
82 use ruby && ruby-ng_pkg_setup
86 use php && php-ext-source-r2_src_unpack
91 # Upstream patch to allow perl to be built in the compile stage
92 epatch "${FILESDIR}"/perl.mk.patch
93 # Patch to fix java errors and allow compilation
94 epatch "${FILESDIR}"/java.mk.patch
95 # Patch to stop python from building the extension again during install
96 epatch "${FILESDIR}"/python.mk.patch
97 # Upstream patch to allow dotnet binding to build
98 epatch "${FILESDIR}"/swig.m4.patch
99 # Patch to allow dotnet binding to build and set snk key file
100 epatch "${FILESDIR}"/dotnet.patch
102 use php && php-ext-source-r2_src_prepare
109 use java || myconf="--disable-java"
110 use mono || myconf="${myconf} --disable-dotnet"
111 use perl || myconf="${myconf} --disable-perl"
113 # Enable php extension when it finds the current selected slot
114 myphpprefix="${PHPPREFIX}/include"
116 myconf="${myconf} --disable-php"
118 use python || myconf="${myconf} --disable-python"
121 myconf="${myconf} --enable-maintainer-documentation"
125 if use perl || use php || use python || use ruby; then
126 ewarn "Enabling threads for perl, php, python or ruby causes segmentation faults."
127 ewarn "Disabling threads"
128 myconf="${myconf} --disable-thread-safe"
130 myconf="${myconf} --enable-thread-safe"
135 MYRUBYIMPLS=($(ruby_get_use_implementations))
136 MYRUBYFIRSTIMPL=${MYRUBYIMPLS[0]}
137 # Set RUBY value in config to the first ruby implementation to build
138 RUBY=$(ruby_implementation_command ${MYRUBYFIRSTIMPL})
139 MYRUBYIMPLS=(${MYRUBYIMPLS[@]:1})
140 myconf="${myconf} RUBY=${RUBY}"
142 myconf="${myconf} --disable-ruby"
146 --enable-shared_dependencies \
148 --enable-default-search-path="/usr /opt ${myphpprefix}" \
150 $(use_enable debug) \
151 $(use_enable sql-compiler) \
152 $(use_with mono "snk-file" "${FILESDIR}"/${PN}.snk) \
158 local slot myphpconfig="php-config"
159 # Shift off the first slot so it doesn't get built again
160 local myphpslots=($(php_get_slots)) myphpfirstslot="${myphpslots[@]:0:1}" myphpslots=(${myphpslots[@]:1})
161 _php-replace_config_with_selected_config ${myphpfirstslot} ${myphpconfig}
162 myphpconfig="${PHPCONFIG}"
164 local myboostpackage=$(best_version "<dev-libs/boost-1.46")
165 local myboostpackagever=${myboostpackage/*boost-/}
166 local myboostver=$(get_version_component_range 1-2 ${myboostpackagever})
167 local myboostslot=$(replace_version_separator 1 _ ${myboostver})
168 einfo "Using boost version ${myboostver}"
169 emake BOOST_CFLAGS="-I/usr/include/boost-${myboostslot}" BOOST_LIBS="-L/usr/$(get_libdir)/boost-${myboostslot}" || die "emake failed"
171 # Move the current slotted build of php to another dir so other slots can be built
172 _php-move_swig_build_to_modules_dir "${WORKDIR}/${myphpfirstslot}"
173 # Build the remaining slots
174 for slot in ${myphpslots[@]}; do
175 _php-replace_config_with_selected_config ${slot} ${myphpconfig}
176 myphpconfig="${PHPCONFIG}"
177 # Build the current slot
178 emake build/swig/php5/${PN}.so || die "Unable to make php${slot} extension"
179 _php-move_swig_build_to_modules_dir ${PHP_EXT_S}
183 # Move the current implementation build of ruby to another dir so other implementations can be built
184 _ruby-move_swig_build_to_impl_dir "${WORKDIR}/${MYRUBYFIRSTIMPL}"
185 unset MYFIRSTRUBYIMPL
188 MYRUBYIMPL="\${RUBY}"
189 # Build the remaining implementations
190 for impl in ${MYRUBYIMPLS[@]}; do
191 cd "${S}" || die "cannot change to source directory"
192 # Replace the reference to ${RUBY} with the current implementation
193 sed -i -e "s|${MYRUBYIMPL}|$(ruby_implementation_command ${impl})|g" \
194 project/build/ruby.mk || die "sed ruby implementation change failed"
195 MYRUBYIMPL="$(ruby_implementation_command ${impl})"
196 # Build the current implementation
197 emake build/swig/ruby/${PN}_native.bundle || die "Unable to make ${impl} extension"
198 _ruby-move_swig_build_to_impl_dir "${WORKDIR}/${impl}"
204 each_ruby_install() {
205 exeinto "$(ruby_rbconfig_value archdir)"
206 doexe "${S}"/librets_native.so || die
207 doruby "${S}"/librets.rb || die
211 dolib.a build/${PN}/lib/${PN}.a || die
214 doins -r project/${PN}/include/${PN} || die
216 dobin "${PN}-config" || die
219 php-ext-source-r2_src_install
220 insinto /usr/share/php
221 doins "${WORKDIR}"/php"${PHP_CURRENTSLOT}"/modules/${PN}.php || die
225 # Install manually since the package install has sandbox violations
228 doins -r "${S}"/build/swig/perl/blib/arch/auto || die
230 doins "${S}"/build/swig/perl/${PN}.pm || die
234 java-pkg_dojar "${S}"/build/swig/java/${PN}.jar || die
235 LIBOPTIONS="-m755" java-pkg_doso "${S}"/build/swig/java/${PN}.so || die
238 use ruby && ruby-ng_src_install
241 egacinstall "${S}"/build/swig/csharp/${PN}-dotnet.dll
245 cd "${S}"/build/swig/python || die
246 distutils_src_install
251 use perl && perl-module_pkg_preinst
255 use python && distutils_pkg_postinst
256 use perl && perl-module_pkg_postinst
260 use perl && perl-module_pkg_prerm
264 use python && distutils_pkg_postrm
265 use perl && perl-module_pkg_postrm