dev-ruby/metaclass-0.0.4-r0: add alpha keyword
[gentoo.git] / sys-libs / db / db-4.8.30-r1.ebuild
1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Id$
4
5 EAPI=4
6
7 inherit eutils db flag-o-matic java-pkg-opt-2 autotools multilib multilib-minimal
8
9 #Number of official patches
10 #PATCHNO=`echo ${PV}|sed -e "s,\(.*_p\)\([0-9]*\),\2,"`
11 PATCHNO=${PV/*.*.*_p}
12 if [[ ${PATCHNO} == "${PV}" ]] ; then
13         MY_PV=${PV}
14         MY_P=${P}
15         PATCHNO=0
16 else
17         MY_PV=${PV/_p${PATCHNO}}
18         MY_P=${PN}-${MY_PV}
19 fi
20
21 S="${WORKDIR}/${MY_P}/build_unix"
22 DESCRIPTION="Oracle Berkeley DB"
23 HOMEPAGE="http://www.oracle.com/technology/software/products/berkeley-db/index.html"
24 SRC_URI="http://download.oracle.com/berkeley-db/${MY_P}.tar.gz"
25 for (( i=1 ; i<=${PATCHNO} ; i++ )) ; do
26         export SRC_URI="${SRC_URI} http://www.oracle.com/technology/products/berkeley-db/db/update/${MY_PV}/patch.${MY_PV}.${i}"
27 done
28
29 LICENSE="Sleepycat"
30 SLOT="4.8"
31 KEYWORDS="alpha amd64 arm arm64 hppa ia64 m68k ~mips ppc ppc64 s390 sh sparc x86 ~amd64-fbsd ~sparc-fbsd ~x86-fbsd"
32 IUSE="doc java cxx tcl test"
33
34 # the entire testsuite needs the TCL functionality
35 DEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0[${MULTILIB_USEDEP}] )
36         test? ( >=dev-lang/tcl-8.5.15-r1:0[${MULTILIB_USEDEP}] )
37         java? ( >=virtual/jdk-1.5 )
38         >=sys-devel/binutils-2.16.1"
39 RDEPEND="tcl? ( >=dev-lang/tcl-8.5.15-r1:0[${MULTILIB_USEDEP}] )
40         java? ( >=virtual/jre-1.5 )
41         abi_x86_32? (
42                 !<=app-emulation/emul-linux-x86-baselibs-20140508-r2
43                 !app-emulation/emul-linux-x86-baselibs[-abi_x86_32(-)]
44         )"
45
46 src_unpack() {
47         unpack "${MY_P}".tar.gz
48 }
49
50 src_prepare() {
51         cd "${WORKDIR}"/"${MY_P}" || die
52         for (( i=1 ; i<=${PATCHNO} ; i++ ))
53         do
54                 epatch "${DISTDIR}"/patch."${MY_PV}"."${i}"
55         done
56         epatch "${FILESDIR}"/${PN}-4.8-libtool.patch
57         epatch "${FILESDIR}"/${PN}-4.8.24-java-manifest-location.patch
58         epatch "${FILESDIR}"/${PN}-4.8.30-rename-atomic-compare-exchange.patch
59
60         # use the includes from the prefix
61         epatch "${FILESDIR}"/${PN}-4.6-jni-check-prefix-first.patch
62         epatch "${FILESDIR}"/${PN}-4.3-listen-to-java-options.patch
63
64         sed -e "/^DB_RELEASE_DATE=/s/%B %e, %Y/%Y-%m-%d/" -i dist/RELEASE \
65                 || die
66
67         # Include the SLOT for Java JAR files
68         # This supersedes the unused jarlocation patches.
69         sed -r -i \
70                 -e '/jarfile=.*\.jar$/s,(.jar$),-$(LIBVERSION)\1,g' \
71                 "${S}"/../dist/Makefile.in || die
72
73         cd "${S}"/../dist || die
74         rm -f aclocal/libtool.m4
75         sed -i \
76                 -e '/AC_PROG_LIBTOOL$/aLT_OUTPUT' \
77                 configure.ac || die
78         sed -i \
79                 -e '/^AC_PATH_TOOL/s/ sh, none/ bash, none/' \
80                 aclocal/programs.m4 || die
81         AT_M4DIR="aclocal aclocal_java" eautoreconf
82         # Upstream sucks - they do autoconf and THEN replace the version variables.
83         . ./RELEASE
84         sed -i \
85                 -e "s/__EDIT_DB_VERSION_MAJOR__/$DB_VERSION_MAJOR/g" \
86                 -e "s/__EDIT_DB_VERSION_MINOR__/$DB_VERSION_MINOR/g" \
87                 -e "s/__EDIT_DB_VERSION_PATCH__/$DB_VERSION_PATCH/g" \
88                 -e "s/__EDIT_DB_VERSION_STRING__/$DB_VERSION_STRING/g" \
89                 -e "s/__EDIT_DB_VERSION_UNIQUE_NAME__/$DB_VERSION_UNIQUE_NAME/g" \
90                 -e "s/__EDIT_DB_VERSION__/$DB_VERSION/g" configure || die
91 }
92
93 src_configure() {
94         # Add linker versions to the symbols. Easier to do, and safer than header file
95         # mumbo jumbo.
96         if use userland_GNU ; then
97                 append-ldflags -Wl,--default-symver
98         fi
99
100         multilib-minimal_src_configure
101 }
102
103 multilib_src_configure() {
104         local myconf=()
105
106         # compilation with -O0 fails on amd64, see bug #171231
107         if [[ ${ABI} == amd64 ]]; then
108                 local CFLAGS=${CFLAGS} CXXFLAGS=${CXXFLAGS}
109                 replace-flags -O0 -O2
110                 is-flagq -O[s123] || append-flags -O2
111         fi
112
113         # use `set` here since the java opts will contain whitespace
114         if multilib_is_native_abi && use java ; then
115                 myconf+=(
116                         --with-java-prefix="${JAVA_HOME}"
117                         --with-javac-flags="$(java-pkg_javac-args)"
118                 )
119         fi
120
121         # Bug #270851: test needs TCL support
122         if use tcl || use test ; then
123                 myconf+=(
124                         --enable-tcl
125                         --with-tcl=/usr/$(get_libdir)
126                 )
127         else
128                 myconf+=(--disable-tcl )
129         fi
130
131         ECONF_SOURCE="${S}"/../dist \
132         STRIP="true" \
133         econf \
134                 --enable-compat185 \
135                 --enable-o_direct \
136                 --without-uniquename \
137                 $([[ ${ABI} == arm ]] && echo --with-mutex=ARM/gcc-assembly) \
138                 $([[ ${ABI} == amd64 ]] && echo --with-mutex=x86/gcc-assembly) \
139                 $(use_enable cxx) \
140                 $(use_enable cxx stl) \
141                 $(multilib_native_use_enable java) \
142                 "${myconf[@]}" \
143                 $(use_enable test)
144 }
145
146 multilib_src_test() {
147         multilib_is_native_abi || return
148
149         S=${BUILD_DIR} db_src_test
150 }
151
152 multilib_src_install() {
153         emake install DESTDIR="${D}"
154
155         db_src_install_headerslot
156
157         db_src_install_usrlibcleanup
158
159         if multilib_is_native_abi && use java; then
160                 java-pkg_regso "${D}"/usr/"$(get_libdir)"/libdb_java*.so
161                 java-pkg_dojar "${D}"/usr/"$(get_libdir)"/*.jar
162                 rm -f "${D}"/usr/"$(get_libdir)"/*.jar
163         fi
164 }
165
166 multilib_src_install_all() {
167         db_src_install_usrbinslot
168
169         db_src_install_doc
170
171         dodir /usr/sbin
172         # This file is not always built, and no longer exists as of db-4.8
173         if [[ -f "${D}"/usr/bin/berkeley_db_svc ]] ; then
174                 mv "${D}"/usr/bin/berkeley_db_svc \
175                         "${D}"/usr/sbin/berkeley_db"${SLOT/./}"_svc || die
176         fi
177 }
178
179 pkg_postinst() {
180         multilib_foreach_abi db_fix_so
181 }
182
183 pkg_postrm() {
184         multilib_foreach_abi db_fix_so
185 }