]> Pileus Git - ~andy/sunrise/blob - dev-libs/librets/librets-1.5.3-r1.ebuild
app-misc/autokey-gtk: Add ~amd64 keyword, EAPI bump
[~andy/sunrise] / dev-libs / librets / librets-1.5.3-r1.ebuild
1 # Copyright 1999-2013 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: $
4
5 EAPI="5"
6
7 PHP_EXT_OPTIONAL_USE="php"
8 PHP_EXT_NAME="librets"
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
12 USE_PHP="php5-3"
13
14 PYTHON_COMPAT=( python2_{6,7} )
15
16 USE_RUBY="ree18 ruby18 ruby19"
17 RUBY_OPTIONAL="yes"
18
19 inherit autotools eutils java-pkg-opt-2 mono perl-module php-ext-source-r2 python-r1 ruby-ng toolchain-funcs versionator
20
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"
24
25 LICENSE="BSD-NAR"
26 SLOT="0"
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 )
31         php? ( !threads )
32         python? ( !threads )
33         ruby? ( !threads )"
34
35 SWIG_RDEPEND="dev-libs/libgcrypt
36         dev-libs/libgpg-error
37         dev-libs/libtasn1
38         net-dns/libidn
39         net-libs/gnutls"
40
41 RDEPEND=">=dev-libs/boost-1.46
42         dev-libs/expat
43         >=dev-util/boost-build-1.46
44         net-misc/curl
45         sql-compiler? ( dev-java/antlr:0[script] )
46         sys-libs/zlib
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} )"
52
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 )
61         ${RDEPEND}"
62
63 # Reset to the default $S since ruby-ng overrides it
64 S="${WORKDIR}/${P}"
65
66 unset SWIG_RDEPEND
67
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() {
71         local slot
72         for slot in $(php_get_slots); do
73                 php_init_slot_env ${slot}
74                 # Let's put the default module away
75                 insinto "${EXT_DIR}"
76                 newins "modules/${PHP_EXT_NAME}.so" "${PHP_EXT_NAME}.so"
77         done
78         php-ext-source-r2_createinifiles
79 }
80
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"
84 }
85
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"
91 }
92
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"
96 }
97
98 pkg_setup() {
99         use java && java-pkg-opt-2_pkg_setup
100         use perl && perl-module_pkg_setup
101         use ruby && ruby-ng_pkg_setup
102 }
103
104 src_unpack() {
105         use php && php-ext-source-r2_src_unpack
106         default
107 }
108
109 src_prepare() {
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
116         eautoreconf
117
118         # Change the path to librets-config-inplace for python slotted build support
119         if use python; then
120                 sed -i -e "s|../../..|${S}|" project/swig/python/setup.py || die
121         fi
122
123         use php && php-ext-source-r2_src_prepare
124 }
125
126 src_configure() {
127         local myphpprefix
128
129         if use php; then
130                 # Enable php extension when it finds the current selected slot
131                 myphpprefix="${PHPPREFIX}/include"
132         fi
133
134         # The build system just finds "python", which could be python3.2 if EPYTHON is unset.
135         use python && python_export_best EPYTHON
136
137         if use ruby; then
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})
143         fi
144
145         # Allow cross-compiling between operating systems since ar is not portable
146         tc-export AR
147         econf \
148                 --enable-shared_dependencies \
149                 --enable-depends \
150                 --enable-default-search-path="/usr /opt ${myphpprefix}" \
151                 --disable-examples \
152                 --disable-debug \
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")
163 }
164
165 src_compile() {
166         if use php; then
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}"
172         fi
173         emake
174         if use php; then
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}"
184                 done
185         fi
186
187         # Build the remaining python implementations
188         use python && python_foreach_impl emake
189
190         if use ruby; then
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
194                 unset RUBY
195                 local impl
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}"
207                 done
208                 unset MYRUBYIMPL
209                 unset MYRUBYIMPLS
210                 unset impl
211         fi
212 }
213
214 each_ruby_install() {
215         exeinto "$(ruby_rbconfig_value archdir)"
216         doexe "${S}"/librets_native.so
217         doruby "${S}"/librets.rb
218 }
219
220 src_install() {
221         dolib.a build/${PN}/lib/${PN}.a
222
223         insinto /usr/include
224         doins -r project/${PN}/include/${PN}
225
226         dobin "${PN}-config"
227
228         if use php; then
229                 my_php-ext-source-r2_src_install
230                 insinto /usr/share/php
231                 doins "${WORKDIR}"/php"${PHP_CURRENTSLOT}"/modules/${PN}.php
232         fi
233
234         if use perl; then
235                 # Install manually since the package install has sandbox violations
236                 insinto ${SITE_ARCH}
237                 insopts "-m755"
238                 doins -r "${S}"/build/swig/perl/blib/arch/auto
239                 insopts "-m644"
240                 doins "${S}"/build/swig/perl/${PN}.pm
241         fi
242
243         if use java; then
244                 java-pkg_dojar "${S}"/build/swig/java/${PN}.jar
245                 LIBOPTIONS="-m755" java-pkg_doso "${S}"/build/swig/java/${PN}.so
246         fi
247
248         use ruby && ruby-ng_src_install
249
250         if use mono; then
251                 egacinstall "${S}"/build/swig/csharp/${PN}-dotnet.dll
252         fi
253
254         if use python; then
255                 python_install() {
256                         pushd "${S}"/build/swig/python || die
257                         "${PYTHON}" setup.py install --root="${D}" || die
258                         popd
259                 }
260                 python_foreach_impl python_install
261         fi
262 }
263
264 pkg_preinst() {
265         use perl && perl-module_pkg_preinst
266 }
267
268 pkg_postinst() {
269         use perl && perl-module_pkg_postinst
270 }
271
272 pkg_prerm() {
273         use perl && perl-module_pkg_prerm
274 }
275
276 pkg_postrm() {
277         use perl && perl-module_pkg_postrm
278 }