summaryrefslogtreecommitdiff
blob: 306189efce35639f616f49705ebce8ca0bd953ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# Copyright 1999-2004 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/sys-libs/db/db-3.2.9-r7.ebuild,v 1.11 2004/02/22 12:39:55 mr_bones_ Exp $

IUSE=""

inherit libtool
inherit eutils

S="${WORKDIR}/${P}"
DESCRIPTION="Berkeley DB for transaction support in MySQL"
SRC_URI="http://www.sleepycat.com/update/snapshot/${P}.tar.gz"
HOMEPAGE="http://www.sleepycat.com/"

SLOT="3"
LICENSE="DB"
# This ebuild is to be the compatibility ebuild for when db4 is put
# in the tree.
KEYWORDS="x86 ppc sparc alpha mips hppa amd64"

RDEPEND="virtual/glibc"
DEPEND="${RDEPEND}
	=sys-libs/db-1.85-r1
	sys-devel/libtool
	sys-devel/m4"
# We need m4 too else build fails without config.guess

# This doesn't build without exceptions
export CXXFLAGS="${CXXFLAGS/-fno-exceptions/-fexceptions}"

src_unpack() {
	unpack ${A}

	chmod -R ug+w *

	cd ${WORKDIR}/${P}
	epatch ${FILESDIR}/patch.3.2.9.1
	epatch ${FILESDIR}/patch.3.2.9.2

	# Get db to link libdb* to correct dependencies ... for example if we use
	# NPTL or NGPT, db detects usable mutexes, and should link against
	# libpthread, but does not do so ...
	# <azarah@gentoo.org> (23 Feb 2003)
	epatch ${FILESDIR}/${P}-fix-dep-link.patch

	# We should get dump185 to link against system db1 ..
	# <azarah@gentoo.org> (23 Feb 2003)
	mv ${S}/dist/Makefile.in ${S}/dist/Makefile.in.orig
	sed -e 's:DB185INC=:DB185INC= -I/usr/include/db1:' \
		-e 's:DB185LIB=:DB185LIB= -ldb1:' \
		${S}/dist/Makefile.in.orig > ${S}/dist/Makefile.in || die "Failed to sed"

	# Fix invalid .la files
	cd ${WORKDIR}/${P}/dist
	rm -f ltversion.sh

	# remove config.guess else we have problems with gcc-3.2
	rm -f config.guess
	sed -i "s,\(-D_GNU_SOURCE\),\1 ${CFLAGS}," configure
}

src_compile() {
	local conf=

	conf="--host=${CHOST} \
		--build=${CHOST} \
		--enable-cxx \
		--enable-compat185 \
		--enable-dump185 \
		--prefix=/usr"
	# --enable-rpc aparently does not work .. should verify this
	# at some stage ...

	# NOTE: we should not build both shared and static versions
	#       of the libraries in the same build root!

	einfo "Configuring ${P} (static)..."
	mkdir -p ${S}/build-static
	cd ${S}/build-static
	../dist/configure ${conf} \
		--enable-static || die

	einfo "Configuring ${P} (shared)..."
	mkdir -p ${S}/build-shared
	cd ${S}/build-shared
	../dist/configure ${conf} \
		--enable-shared || die

	# Parallel make does not work
	MAKEOPTS="${MAKEOPTS} -j1"
	einfo "Building ${P} (static)..."
	cd ${S}/build-static
	emake || die "Static build failed"
	einfo "Building ${P} (shared)..."
	cd ${S}/build-shared
	emake || die "Shared build failed"
}

src_install () {
	cd ${S}/build-shared
	make libdb=libdb-3.2.a \
		libcxx=libcxx_3.2.a \
		prefix=${D}/usr \
		install || die

	cd ${S}/build-static
	cp libdb.a libdb-3.2.a
	cp libdb_cxx.a libdb_cxx-3.2.a
	dolib.a libdb-3.2.a libdb_cxx-3.2.a

	dodir usr/include/db3
	cd ${D}/usr/include
	mv *.h db3
	ln db3/db.h db.h

	cd ${D}/usr/lib
	ln -s libdb-3.2.so libdb.so.3

	# For some reason, db.so's are *not* readable by group or others,
	# resulting in no one but root being able to use them!!!
	# This fixes it -- DR 15 Jun 2001
	cd ${D}/usr/lib
	chmod go+rx *.so
	# The .la's aren't readable either
	chmod go+r *.la

	cd ${S}
	dodoc README LICENSE

	dodir /usr/share/doc/${PF}/html
	mv ${D}/usr/docs/* ${D}/usr/share/doc/${PF}/html
	rm -rf ${D}/usr/docs

	#making things work better with the db4 ebuild
	for fname in ${D}/usr/bin/db_*
	do
		mv ${fname} ${fname//\/db_/\/db3_}
	done
	ln -sf /usr/include/db3/db.h ${D}/usr/include/db.h
}

fix_so () {
	cd ${ROOT}/usr/lib
	target=`find -type f -maxdepth 1 -name "libdb-*.so" |sort |tail -n 1`
	[ -n "${target}" ] && ln -sf ${target//.\//} libdb.so
	target=`find -type f -maxdepth 1 -name "libdb_cxx*.so" |sort |tail -n 1`
	[ -n "${target}" ] && ln -sf ${target//.\//} libdb_cxx.so
	target=`find -type f -maxdepth 1 -name "libdb_tcl*.so" |sort |tail -n 1`
	[ -n "${target}" ] && ln -sf ${target//.\//} libdb_tcl.so
	target=`find -type f -maxdepth 1 -name "libdb_java*.so" |sort |tail -n 1`
	[ -n "${target}" ] && ln -sf ${target//.\//} libdb_java.so

	cd ${ROOT}/usr/include
	target=`ls -d db?|sort |tail -n 1`
	[ -n "${target}" ] && ln -sf ${target}/db.h .
	[ -n "${target}" ] && ln -sf ${target}/db_185.h .
}

pkg_postinst () {
	fix_so
}

pkg_postrm () {
	fix_so
}