1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
5 inherit autotools db flag-o-matic java-pkg-opt-2 multilib multilib-minimal toolchain-funcs
7 #Number of official patches
8 #PATCHNO=`echo ${PV}|sed -e "s,\(.*_p\)\([0-9]*\),\2,"`
9 PATCHNO="${PV/*.*.*_p}"
10 if [[ ${PATCHNO} == "${PV}" ]] ; then
15 MY_PV="${PV/_p${PATCHNO}}"
19 RESTRICT="!test? ( test )"
21 S_BASE="${WORKDIR}/${MY_P}"
22 S="${S_BASE}/build_unix"
23 DESCRIPTION="Oracle Berkeley DB"
24 HOMEPAGE="http://www.oracle.com/technetwork/database/database-technologies/berkeleydb/overview/index.html"
25 SRC_URI="http://download.oracle.com/berkeley-db/${MY_P}.tar.gz"
26 for (( i=1 ; i<=${PATCHNO} ; i++ )) ; do
27 export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
32 KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~ppc ~ppc64 ~riscv ~s390 ~sparc ~x86"
33 IUSE="doc java cxx tcl test"
35 REQUIRED_USE="test? ( tcl )"
37 # the entire testsuite needs the TCL functionality
38 DEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
39 test? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
40 java? ( >=virtual/jdk-1.5 )
41 >=sys-devel/binutils-2.16.1"
42 RDEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0=[${MULTILIB_USEDEP}] )
43 java? ( >=virtual/jre-1.5 )"
45 MULTILIB_WRAPPED_HEADERS=(
46 /usr/include/db${SLOT}/db.h
51 "${FILESDIR}"/${PN}-4.8.24-java-manifest-location.patch
53 # use the includes from the prefix
54 "${FILESDIR}"/${PN}-4.6-jni-check-prefix-first.patch
55 "${FILESDIR}"/${PN}-4.2-listen-to-java-options.patch
57 # sqlite configure call has an extra leading ..
58 # upstreamed:5.2.36, missing in 5.3.x
59 "${FILESDIR}"/${PN}-5.2.28-sqlite-configure-path.patch
61 # The upstream testsuite copies .lib and the binaries for each parallel test
62 # core, ~300MB each. This patch uses links instead, saves a lot of space.
63 "${FILESDIR}"/${PN}-6.0.20-test-link.patch
65 # Needed when compiling with clang
66 "${FILESDIR}"/${PN}-5.1.29-rename-atomic-compare-exchange.patch
71 for (( i=1 ; i<=${PATCHNO} ; i++ ))
73 eapply -p0 "${DISTDIR}"/patch."${MY_PV}"."${i}"
78 # Upstream release script grabs the dates when the script was run, so lets
79 # end-run them to keep the date the same.
80 export REAL_DB_RELEASE_DATE="$(awk \
81 '/^DB_VERSION_STRING=/{ gsub(".*\\(|\\).*","",$0); print $0; }' \
82 "${S_BASE}"/dist/configure)"
84 -e "/^DB_RELEASE_DATE=/s~=.*~='${REAL_DB_RELEASE_DATE}'~g" \
85 -i dist/RELEASE || die
87 # Include the SLOT for Java JAR files
88 # This supersedes the unused jarlocation patches.
90 -e '/jarfile=.*\.jar$/s,(.jar$),-$(LIBVERSION)\1,g' \
91 -i dist/Makefile.in || die
94 rm aclocal/libtool.m4 || die
96 -e '/AC_PROG_LIBTOOL$/aLT_OUTPUT' \
97 -i configure.ac || die
99 -e '/^AC_PATH_TOOL/s/ sh, none/ bash, none/' \
100 -i aclocal/programs.m4 || die
102 AT_M4DIR="aclocal aclocal_java" eautoreconf
104 # Upstream sucks - they do autoconf and THEN replace the version variables.
108 DB_VERSION_{FAMILY,LETTER,RELEASE,MAJOR,MINOR} \
109 DB_VERSION_{PATCH,FULL,UNIQUE_NAME,STRING,FULL_STRING} \
113 sed -e "s/${ev}/${!v}/g" -i configure || die
116 # This is a false positive skip in the tests as the test-reviewer code
117 # looks for 'Skipping\s'
119 -e '/db_repsite/s,Skipping:,Skipping,g' \
120 -i "${S_BASE}"/test/tcl/reputils.tcl || die
123 multilib_src_configure() {
125 # sql_compat will cause a collision with sqlite3
127 # Don't --enable-sql* because we don't want to use bundled sqlite.
128 # See Gentoo bug #605688
134 --disable-sql_codegen
136 $([[ ${ABI} == amd64 ]] && echo --with-mutex=x86/gcc-assembly)
138 $(use_enable cxx stl)
139 $(multilib_native_use_enable java)
143 tc-ld-disable-gold #470634
145 # compilation with -O0 fails on amd64, see bug #171231
146 if [[ ${ABI} == amd64 ]]; then
147 local CFLAGS="${CFLAGS}" CXXFLAGS="${CXXFLAGS}"
148 replace-flags -O0 -O2
149 is-flagq -O[s123] || append-flags -O2
152 # Add linker versions to the symbols. Easier to do, and safer than header file
154 if use userland_GNU ; then
155 append-ldflags -Wl,--default-symver
158 if multilib_is_native_abi && use java ; then
160 --with-java-prefix="${JAVA_HOME}"
161 --with-javac-flags="$(java-pkg_javac-args)"
165 # Bug #270851: test needs TCL support
166 if use tcl || use test ; then
169 --with-tcl="${EPREFIX}/usr/$(get_libdir)"
172 myconf+=(--disable-tcl )
175 ECONF_SOURCE="${S_BASE}"/dist \
179 # The embedded assembly on ARM does not work on newer hardware
180 # so you CANNOT use --with-mutex=ARM/gcc-assembly anymore.
181 # Specifically, it uses the SWPB op, which was deprecated:
182 # http://www.keil.com/support/man/docs/armasm/armasm_dom1361289909499.htm
183 # The op ALSO cannot be used in ARM-Thumb mode.
184 # Trust the compiler instead.
185 # >=db-6.1 uses LDREX instead.
188 multilib_src_install() {
189 emake DESTDIR="${D}" install
191 db_src_install_headerslot
193 db_src_install_usrlibcleanup
195 if multilib_is_native_abi && use java; then
196 java-pkg_regso "${ED}"/usr/"$(get_libdir)"/libdb_java*.so
197 java-pkg_dojar "${ED}"/usr/"$(get_libdir)"/*.jar
198 rm -f "${ED}"/usr/"$(get_libdir)"/*.jar
202 multilib_src_install_all() {
203 db_src_install_usrbinslot
208 # This file is not always built, and no longer exists as of db-4.8
209 if [[ -f "${ED}"/usr/bin/berkeley_db_svc ]] ; then
210 mv "${ED}"/usr/bin/berkeley_db_svc \
211 "${ED}"/usr/sbin/berkeley_db"${SLOT/./}"_svc || die
216 multilib_foreach_abi db_fix_so
220 multilib_foreach_abi db_fix_so
224 # db_repsite is impossible to build, as upstream strips those sources.
225 # db_repsite is used directly in the setup_site_prog,
226 # setup_site_prog is called from open_site_prog
227 # which is called only from tests in the multi_repmgr group.
229 # -e '/set subs/s,multi_repmgr,,g' \
230 # "${S_BASE}/test/testparams.tcl"
232 -e '/multi_repmgr/d' \
233 -i "${S_BASE}/test/tcl/test.tcl" || die
235 # This is the only failure in 5.2.28 so far, and looks like a false positive.
236 # Repmgr018 (btree): Test of repmgr stats.
237 # Repmgr018.a: Start a master.
238 # Repmgr018.b: Start a client.
239 # Repmgr018.c: Run some transactions at master.
240 # Rep_test: btree 20 key/data pairs starting at 0
241 # Rep_test.a: put/get loop
242 # FAIL:07:05:59 (00:00:00) perm_no_failed_stat: expected 0, got 1
244 -e '/set parms.*repmgr018/d' \
245 -e 's/repmgr018//g' \
246 -i "${S_BASE}/test/tcl/test.tcl" || die
248 multilib-minimal_src_test
251 multilib_src_test() {
252 multilib_is_native_abi || return
254 S="${BUILD_DIR}" db_src_test