summaryrefslogtreecommitdiff
blob: ba0a683930ea8a6b4f3ea749eb88e84c0cd2ccfe (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
# Copyright 1999-2003 Gentoo Technologies, Inc.
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/php-ext.eclass,v 1.2 2003/06/28 20:23:40 coredumb Exp $
#
# Author: Tal Peer <coredumb@gentoo.org>
#
# The php-ext eclass provides a unified interface for compiling and
# installing standalone PHP extensions ('modules').

ECLASS=php-ext
INHERITED="$INHERITED $ECLASS"

EXPORT_FUNCTIONS src_compile src_install pkg_postinst

# ---begin ebuild configurable settings

# The extension name, this must be set, otherwise we die.
[ -z "$PHP_EXT_NAME" ] && die "No module name specified for the php-ext eclass."

# Wether the extensions is a Zend Engine extension
#(defaults to "no" and if you don't know what is it, you don't need it.)
[ -z "$PHP_EXT_ZENDEXT" ] && PHP_EXT_ZENDEXT="no"

# Wether or not to add a line in the php.ini for the extension
# (defaults to "yes" and shouldn't be changed in most cases)
[ -z "$PHP_EXT_INI" ] && PHP_EXT_INI="yes"

# ---end ebuild configurable settings

DEPEND="${DEPEND}
		virtual/php
		=sys-devel/m4-1.4
		>=sys-devel/libtool-1.4.3"

php-ext_src_compile() {
	#phpize creates configure out of config.m4
	phpize
	econf $myconf
	emake || die
}

php-ext_src_install() {
	chmod +x build/shtool
	#this will usually be /usr/lib/php/extensions/no-debug-no-zts-20020409/ 
	#but i prefer not taking this risk
	EXT_DIR=`php-config --extension-dir`
	insinto $EXT_DIR
	doins modules/$PHP_EXT_NAME.so
}

php-ext_pkg_postinst() {
	if [ "$PHP_EXT_INI" = "yes" ] ; then
		if [ `grep ${EXT_DIR}/${PHP_EXT_NAME}.so /etc/php4/php.ini` ] ; then
			einfo "No changes made to php.ini"
		else
			if [ "$PHP_EXT_ZENDEXT" = "yes" ] ; then
				echo zend_extension=${EXT_DIR}/${PHP_EXT_NAME}.so >> /etc/php4/php.ini
			else
				echo extension=${EXT_DIR}/${PHP_EXT_NAME}.so >> /etc/php4/php.ini
			fi
		
			einfo "${PHP_EXT_NAME} has been added to php.ini"
			einfo "Please check phpinfo() output to verify that ${PHP_EXT_NAME} is loaded."
		fi
	else
		einfo "No changes made to php.ini"
	fi
}