summaryrefslogtreecommitdiff
blob: 40423e154b8cad0ca222a80ff722b5e4eb2eec9b (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
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/php/files/eblits/src_compile-v2.eblit,v 1.1 2010/05/27 23:05:04 mabi Exp $

eblit-php-src_compile() {
	SAPI_DIR="${WORKDIR}/sapis"
	local is_first_sapi=1

	for sapi in ${SAPIS} ; do
		use "${sapi}" || continue
		if [[ ${is_first_sapi} == 1 ]]; then
			is_first_sapi=0
		else
			emake clean
		fi

		php_sapi_build "${sapi}"
		php_sapi_copy "${sapi}"
	done
}

php_sapi_build() {
	local sapi="$1"
	php_set_ini_dir "${sapi}"

	mkdir -p "${SAPI_DIR}/${sapi}"

	sapi_conf="${my_conf} --with-config-file-path=${PHP_INI_DIR}
		--with-config-file-scan-dir=${PHP_EXT_INI_DIR_ACTIVE}"

	for one_sapi in $SAPIS ; do
		case "$one_sapi" in
			cli|cgi|embed)
				if [[ "${one_sapi}" == "${sapi}" ]] ; then
					sapi_conf="${sapi_conf} --enable-${available_sapi}"
				else
					sapi_conf="${sapi_conf} --disable-${available_sapi}"
				fi
				;;

			apache2)
				if [[ "${one_sapi}" == "${sapi}" ]] ; then
					sapi_conf="${sapi_conf} --with-apxs2=/usr/sbin/apxs"
				else
					sapi_conf="${sapi_conf} --without-apxs2"
				fi
				;;

		esac
	done

	econf ${sapi_conf}
	emake || die "emake failed"
}

php_sapi_copy() {
	local sapi="$1"
	local source=""

	case "$sapi" in
		cli)
			source="sapi/cli/php"
			;;
		cgi)
			source="sapi/cgi/php-cgi"
			;;
		embed)
			source="libs/libphp${PHP_MV}.so"
			;;

		apache2)
			# apache2 is a special case; the necessary files
			# (yes, multiple) are copied by make install, not
			# by the ebuild; that's the reason, why apache2 has
			# to be the last sapi
			emake INSTALL_ROOT="${SAPI_DIR}/${sapi}/" install-sapi
			;;

		*)
			die "unhandled sapi in php_sapi_copy"
			;;
	esac

	if [[ "${source}" ]] ; then
		cp "$source" "${SAPI_DIR}/$sapi" || die "Unable to copy ${sapi} SAPI"
	fi
}