]> Pileus Git - ~andy/sunrise/blob - dev-libs/librets/librets-1.5.2-r2.ebuild
dev-libs/librets: Fixed problem with boost dependency so that it builds with the...
[~andy/sunrise] / dev-libs / librets / librets-1.5.2-r2.ebuild
1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="3"
6
7 PHP_EXT_OPTIONAL_USE="php"
8 PHP_EXT_NAME="librets"
9 PHP_EXT_SKIP_PHPIZE="yes"
10 USE_PHP="php5-2 php5-3"
11
12 PYTHON_DEPEND="python? 2"
13 PYTHON_MODNAME="librets.py"
14
15 USE_RUBY="ree18 ruby18 ruby19"
16 RUBY_OPTIONAL="yes"
17
18 inherit distutils eutils java-pkg-opt-2 mono multilib perl-module php-ext-source-r2 ruby-ng versionator
19
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"
23
24 LICENSE="BSD-NAR"
25 SLOT="0"
26 KEYWORDS="~amd64 ~x86"
27 IUSE="debug doc java mono perl php python ruby sql-compiler threads"
28
29 for i in java perl php python ruby; do
30         SWIG_DEPEND+=" ${i}? ( dev-lang/swig )"
31         SWIG_RDEPEND+=" ${i}? (
32                 dev-libs/libgcrypt
33                 dev-libs/libgpg-error
34                 dev-libs/libtasn1
35                 net-dns/libidn
36                 net-libs/gnutls
37         )"
38 done
39
40 RDEPEND="
41         <dev-libs/boost-1.46
42         dev-libs/expat
43         <dev-util/boost-build-1.46
44         java? ( >=virtual/jdk-1.6.0 )
45         mono? ( dev-lang/mono )
46         net-misc/curl
47         ruby? ( $(ruby_implementations_depend) )
48         sql-compiler? ( dev-java/antlr:0[script] )
49         sys-libs/zlib
50         ${SWIG_RDEPEND}"
51
52 DEPEND="${RDEPEND} ${SWIG_DEPEND}"
53
54 unset SWIG_DEPEND
55 unset SWIG_RDEPEND
56 unset i
57
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"
61 }
62
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"
68 }
69
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"
73 }
74
75 pkg_setup() {
76         use java && java-pkg-opt-2_pkg_setup
77         use perl && perl-module_pkg_setup
78         if use python; then
79                 python_set_active_version 2
80                 python_pkg_setup
81         fi
82         use ruby && ruby-ng_pkg_setup
83 }
84
85 src_unpack() {
86         use php && php-ext-source-r2_src_unpack
87         default
88 }
89
90 src_prepare() {
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
101         eautoreconf
102         use php && php-ext-source-r2_src_prepare
103 }
104
105 src_configure() {
106         local myconf
107         local myphpprefix
108
109         use java || myconf="--disable-java"
110         use mono || myconf="${myconf} --disable-dotnet"
111         use perl || myconf="${myconf} --disable-perl"
112         if use php; then
113                 # Enable php extension when it finds the current selected slot
114                 myphpprefix="${PHPPREFIX}/include"
115         else
116                 myconf="${myconf} --disable-php"
117         fi
118         use python || myconf="${myconf} --disable-python"
119
120         if use doc; then
121                 myconf="${myconf} --enable-maintainer-documentation"
122         fi
123
124         if use threads; then
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"
129                 else
130                         myconf="${myconf} --enable-thread-safe"
131                 fi
132         fi
133
134         if use ruby; then
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}"
141         else
142                 myconf="${myconf} --disable-ruby"
143         fi
144
145         econf \
146                 --enable-shared_dependencies \
147                 --enable-depends \
148                 --enable-default-search-path="/usr /opt ${myphpprefix}" \
149                 --disable-examples \
150                 $(use_enable debug) \
151                 $(use_enable sql-compiler) \
152                 $(use_with mono "snk-file" "${FILESDIR}"/${PN}.snk) \
153                 ${myconf}
154 }
155
156 src_compile() {
157         if use php; then
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}"
163         fi
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"
170         if use php; then
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}
180                 done
181         fi
182         if use ruby; then
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
186                 unset RUBY
187                 local impl
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}"
199                 done
200                 unset MYRUBYIMPLS
201         fi
202 }
203
204 each_ruby_install() {
205         exeinto "$(ruby_rbconfig_value archdir)"
206         doexe "${S}"/librets_native.so || die
207         doruby "${S}"/librets.rb || die
208 }
209
210 src_install() {
211         dolib.a build/${PN}/lib/${PN}.a || die
212
213         insinto /usr/include
214         doins -r project/${PN}/include/${PN} || die
215
216         dobin "${PN}-config" || die
217
218         if use php; then
219                 php-ext-source-r2_src_install
220                 insinto /usr/share/php
221                 doins "${WORKDIR}"/php"${PHP_CURRENTSLOT}"/modules/${PN}.php || die
222         fi
223
224         if use perl; then
225                 # Install manually since the package install has sandbox violations
226                 insinto ${SITE_ARCH}
227                 insopts "-m755"
228                 doins -r "${S}"/build/swig/perl/blib/arch/auto || die
229                 insopts "-m644"
230                 doins "${S}"/build/swig/perl/${PN}.pm || die
231         fi
232
233         if use java; then
234                 java-pkg_dojar "${S}"/build/swig/java/${PN}.jar || die
235                 LIBOPTIONS="-m755" java-pkg_doso "${S}"/build/swig/java/${PN}.so  || die
236         fi
237
238         use ruby && ruby-ng_src_install
239
240         if use mono; then
241                 egacinstall "${S}"/build/swig/csharp/${PN}-dotnet.dll
242         fi
243
244         if use python; then
245                 cd "${S}"/build/swig/python || die
246                 distutils_src_install
247         fi
248 }
249
250 pkg_preinst() {
251         use perl && perl-module_pkg_preinst
252 }
253
254 pkg_postinst() {
255         use python && distutils_pkg_postinst
256         use perl && perl-module_pkg_postinst
257 }
258
259 pkg_prerm() {
260         use perl && perl-module_pkg_prerm
261 }
262
263 pkg_postrm() {
264         use python && distutils_pkg_postrm
265         use perl && perl-module_pkg_postrm
266 }