93042b6f29b806f10e00eced1be6a2deb1bba72f
[gentoo.git] / sys-libs / db / db-3.2.9_p2-r1.ebuild
1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
3
4 EAPI=7
5
6 inherit db flag-o-matic multilib
7
8 #Number of official patches
9 #PATCHNO=`echo ${PV}|sed -e "s,\(.*_p\)\([0-9]*\),\2,"`
10 PATCHNO="${PV/*.*.*_p}"
11 if [[ ${PATCHNO} == "${PV}" ]] ; then
12         MY_PV="${PV}"
13         MY_P="${P}"
14         PATCHNO=0
15 else
16         MY_PV="${PV/_p${PATCHNO}}"
17         MY_P="${PN}-${MY_PV}"
18 fi
19
20 DESCRIPTION="Berkeley DB for transaction support in MySQL"
21 HOMEPAGE="http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html"
22 SRC_URI="http://download.oracle.com/berkeley-db/${MY_P}.tar.gz"
23 for (( i=1 ; i<=${PATCHNO} ; i++ )) ; do
24         export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
25 done
26
27 LICENSE="Sleepycat"
28 SLOT="3"
29 # This ebuild is to be the compatibility ebuild for when db4 is put
30 # in the tree.
31 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 m68k ~mips ppc ppc64 s390 sparc x86"
32 IUSE="doc"
33 RESTRICT="!test? ( test )"
34
35 DEPEND="${RDEPEND}
36         =sys-libs/db-1.85*"
37
38 S="${WORKDIR}/${MY_P}"
39
40 PATCHES=(
41         # Get db to link libdb* to correct dependencies ... for example if we use
42         # NPTL or NGPT, db detects usable mutexes, and should link against
43         # libpthread, but does not do so ...
44         # <azarah@gentoo.org> (23 Feb 2003)
45         "${FILESDIR}"/${MY_P}-fix-dep-link.patch
46
47         "${FILESDIR}"/${MY_P}-gcc43.patch
48 )
49
50 pkg_setup() {
51         # This doesn't build without exceptions
52         replace-flags -fno-exceptions -fexceptions
53 }
54
55 src_prepare() {
56         for (( i=1 ; i<=${PATCHNO} ; i++ ))
57         do
58                 eapply -p0 "${DISTDIR}"/patch."${MY_PV}"."${i}"
59         done
60
61         default
62
63         # We should get dump185 to link against system db1 ..
64         # <azarah@gentoo.org> (23 Feb 2003)
65         mv dist/Makefile.in{,.orig} || die
66         sed \
67                 -e 's:DB185INC=:DB185INC= -I/usr/include/db1:' \
68                 -e 's:DB185LIB=:DB185LIB= -ldb1:' \
69                 dist/Makefile.in.orig \
70                 > dist/Makefile.in || die
71
72         cd dist || die
73         # remove config.guess else we have problems with gcc-3.2
74         rm config.guess || die
75         sed -i "s,\(-D_GNU_SOURCE\),\1 ${CFLAGS}," configure || die
76 }
77
78 src_configure() {
79         local conf=(
80                 --host=${CHOST}
81                 --build=${CHOST}
82                 --enable-cxx
83                 --enable-compat185
84                 --enable-dump185
85         )
86
87         local conf_shared=(
88                 --disable-static
89                 --enable-shared
90
91                 # --enable-rpc DOES NOT BUILD
92                 # Robin H. Johnson <robbat2@gentoo.org> (18 Oct 2003)
93                 --enable-dynamic
94         )
95
96         local conf_static=(
97                 --disable-shared
98                 --enable-static
99         )
100
101         # TCL support is also broken
102         # Robin H. Johnson <robbat2@gentoo.org> (18 Oct 2003)
103         # conf_shared="${conf_shared}
104         #       `use_enable tcl tcl`
105         #       `use_with tcl tcl /usr/$(get_libdir)`"
106
107         # NOTE: we should not build both shared and static versions
108         #       of the libraries in the same build root!
109
110         einfo "Configuring ${P} (static)..."
111         mkdir build-static || die
112         pushd build-static &>/dev/null || die
113         strip="${EPREFIX}"/bin/true \
114         ECONF_SOURCE="${S}"/dist \
115         econf "${conf[@]}" "${conf_static[@]}"
116         popd &>/dev/null || die
117
118         einfo "Configuring ${P} (shared)..."
119         mkdir build-shared || die
120         pushd build-shared &>/dev/null || die
121         strip="${EPREFIX}"/bin/true \
122         ECONF_SOURCE="${S}"/dist \
123         econf "${conf[@]}" "${conf_shared[@]}"
124         popd &>/dev/null || die
125 }
126
127 src_compile() {
128         # Parallel make does not work
129         MAKEOPTS="${MAKEOPTS} -j1"
130
131         einfo "Building ${P} (static)..."
132         pushd "${S}"/build-static &>/dev/null || die
133         emake strip="${EPREFIX}"/bin/true
134         popd &>/dev/null || die
135
136         einfo "Building ${P} (shared)..."
137         pushd build-shared &>/dev/null || die
138         emake strip="${EPREFIX}"/bin/true
139         popd &>/dev/null || die
140 }
141
142 src_install() {
143         pushd build-shared &>/dev/null || die
144         # build system does not support DESTDIR
145         emake \
146                 libdb=libdb-3.2.a \
147                 libcxx=libcxx_3.2.a \
148                 DESTDIR="${D}" \
149                 prefix="${ED}"/usr \
150                 libdir="${ED}"/usr/$(get_libdir) \
151                 strip="${EPREFIX}"/bin/true \
152                 install
153         popd &>/dev/null || die
154
155         pushd build-static &>/dev/null || die
156         newlib.a libdb.a libdb-3.2.a
157         newlib.a libdb_cxx.a libdb_cxx-3.2.a
158         popd &>/dev/null || die
159
160         db_src_install_headerslot || die "db_src_install_headerslot failed!"
161
162         # this is now done in the db eclass, function db_fix_so and db_src_install_usrlibcleanup
163         #cd "${D}"/usr/lib
164         #ln -s libdb-3.2.so libdb.so.3
165
166         # For some reason, db.so's are *not* readable by group or others,
167         # resulting in no one but root being able to use them!!!
168         # This fixes it -- DR 15 Jun 2001
169         pushd "${ED}"/usr/$(get_libdir) &>/dev/null || die
170         chmod go+rx *.so
171         # The .la's aren't readable either
172         chmod go+r *.la
173         popd &>/dev/null || die
174
175         dodoc README
176
177         db_src_install_doc || die "db_src_install_doc failed!"
178
179         db_src_install_usrbinslot || die "db_src_install_usrbinslot failed!"
180
181         db_src_install_usrlibcleanup || die "db_src_install_usrlibcleanup failed!"
182 }
183
184 pkg_postinst() {
185         db_fix_so
186 }
187
188 pkg_postrm() {
189         db_fix_so
190 }
191
192 src_test() {
193         if use test; then
194                 eerror "We'd love to be able to test, but the testsuite is broken in the 3.2.9 series"
195         fi
196 }