summaryrefslogtreecommitdiff
blob: 4cebfef54a682c64fcfaf484eba76b55cd6ddd97 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/depend.apache.eclass,v 1.35 2007/11/25 14:27:52 hollow Exp $

# @ECLASS: depend.apache.eclass
# @MAINTAINER: apache-devs@gentoo.org
# @BLURB: Functions to allow ebuilds to depend on apache
# @DESCRIPTION:
# This eclass handles depending on apache in a sane way and providing
# information about where certain interfaces are located.
#
# @NOTE: If you use this, be sure you use the need_* call after you have defined
# DEPEND and RDEPEND. Also note that you can not rely on the automatic
# RDEPEND=DEPEND that portage does if you use this eclass.
#
# See bug 107127 for more information.

inherit multilib

# ==============================================================================
# INTERNAL VARIABLES
# ==============================================================================

# @ECLASS-VARIABLE: APACHE_VERSION
# @DESCRIPTION:
# Stores the version of apache we are going to be ebuilding. This variable is
# set by the need_apache functions.
#APACHE_VERSION="2"

# @ECLASS-VARIABLE: APXS2
# @DESCRIPTION:
# Paths to the apxs tool
APXS2="/usr/sbin/apxs2"

# @ECLASS-VARIABLE: APACHECTL2
# @DESCRIPTION:
# Path to the apachectl tool
APACHECTL2="/usr/sbin/apache2ctl"

# @ECLASS-VARIABLE: APACHE2_BASEDIR
# @DESCRIPTION:
# Path to the server root directory
APACHE2_BASEDIR="/usr/$(get_libdir)/apache2"

# @ECLASS-VARIABLE: APACHE2_CONFDIR
# @DESCRIPTION:
# Path to the configuration file directory
APACHE2_CONFDIR="/etc/apache2"

# @ECLASS-VARIABLE: APACHE2_MODULES_CONFDIR
# @DESCRIPTION:
# Path where module configuration files are kept
APACHE2_MODULES_CONFDIR="${APACHE2_CONFDIR}/modules.d"

# @ECLASS-VARIABLE: APACHE2_VHOSTDIR
# @DESCRIPTION:
# Path where virtual host configuration files are kept
APACHE2_VHOSTDIR="${APACHE2_CONFDIR}/vhosts.d"

# @ECLASS-VARIABLE: APACHE2_MODULESDIR
# @DESCRIPTION:
# Path where we install modules
APACHE2_MODULESDIR="${APACHE2_BASEDIR}/modules"

# @ECLASS-VARIABLE: APACHE2_DEPEND
# @DESCRIPTION:
# Dependencies for Apache 2.x
APACHE2_DEPEND="=www-servers/apache-2*"

# @ECLASS-VARIABLE: APACHE2_0_DEPEND
# @DESCRIPTION:
# Dependencies for Apache 2.0.x
APACHE2_0_DEPEND="=www-servers/apache-2.0*"

# @ECLASS-VARIABLE: APACHE2_2_DEPEND
# @DESCRIPTION:
# Dependencies for Apache 2.2.x
APACHE2_2_DEPEND="=www-servers/apache-2.2*"

# @ECLASS-VARIABLE: WANT_APACHE_DEPEND
# @DESCRIPTION:
# Dependency magic based on useflag to use the right DEPEND
WANT_APACHE_DEPEND="apache2? ( ${APACHE2_DEPEND} )"

# ==============================================================================
# INTERNAL FUNCTIONS
# ==============================================================================

# @FUNCTION: uses_apache2
# @DESCRIPTION:
# sets up all of the environment variables required for an apache2 module
uses_apache2() {
	debug-print-function $FUNCNAME $*

	# WARNING: Do not use these variables with anything that is put
	# into the dependency cache (DEPEND/RDEPEND/etc)
	APACHE_VERSION="2"
	USE_APACHE="2"
	APXS="${APXS2}"
	APACHECTL="${APACHECTL2}"
	APACHE_BASEDIR="${APACHE2_BASEDIR}"
	APACHE_CONFDIR="${APACHE2_CONFDIR}"
	APACHE_MODULES_CONFDIR="${APACHE2_MODULES_CONFDIR}"
	APACHE_VHOSTSDIR="${APACHE2_VHOSTSDIR}"
	APACHE_MODULESDIR="${APACHE2_MODULESDIR}"
}

# @FUNCTION: doesnt_use_apache
# @DESCRIPTION:
# sets up all of the environment variables required for optional apache usage
doesnt_use_apache() {
	debug-print-function $FUNCNAME $*

	APACHE_VERSION="0"
	USE_APACHE="0"
}

# ==============================================================================
# PUBLIC FUNCTIONS
# ==============================================================================

# @FUNCTION: want_apache
# @DESCRIPTION:
# An ebuild calls this to get the dependency information for optional apache-2.x
# support.
want_apache() {
	debug-print-function $FUNCNAME $*

	IUSE="${IUSE} apache2"
	DEPEND="${DEPEND} ${WANT_APACHE_DEPEND}"
	RDEPEND="${RDEPEND} ${WANT_APACHE_DEPEND}"

	if use apache2 ; then
		uses_apache2
	else
		doesnt_use_apache
	fi
}

# @FUNCTION: need_apache2
# @DESCRIPTION:
# An ebuild calls this to get the dependency information for apache-2.x. An
# ebuild should use this in order for future changes to the build infrastructure
# to happen seamlessly. All an ebuild needs to do is include the line
# need_apache2 somewhere.
need_apache2() {
	debug-print-function $FUNCNAME $*

	DEPEND="${DEPEND} ${APACHE2_DEPEND}"
	RDEPEND="${RDEPEND} ${APACHE2_DEPEND}"
	uses_apache2
}

# @FUNCTION: need_apache2_0
# @DESCRIPTION:
# Works like need_apache2 above, but its used by modules that only support
# apache 2.0 and do not work with higher versions.
need_apache2_0() {
	debug-print-function $FUNCNAME $*

	DEPEND="${DEPEND} ${APACHE2_0_DEPEND}"
	RDEPEND="${RDEPEND} ${APACHE2_0_DEPEND}"
	uses_apache2
}

# @FUNCTION: need_apache2_2
# @DESCRIPTION:
# Works like need_apache2 above, but its used by modules that only support
# apache 2.2 and do not work with lower versions.
need_apache2_2() {
	debug-print-function $FUNCNAME $*

	DEPEND="${DEPEND} ${APACHE2_2_DEPEND}"
	RDEPEND="${RDEPEND} ${APACHE2_2_DEPEND}"
	uses_apache2
}

# @FUNCTION: need_apache
# @DESCRIPTION:
# Legacy alias for need_apache2
need_apache() {
	need_apache2
}

# @FUNCTION: apr_config
# @DESCRIPTION:
# Version magic to get the correct apr-config binary based on the (probably)
# installed version of apache.  This is needed to get modules to link to the
# same apr/apu as apache (i.e. link 0.9 for 2.0, 1.x for 2.2)
apr_config() {
	debug-print-function $FUNCNAME $*

	local default="${1:-1}"
	if [[ "${USE_APACHE}" == "2" ]]; then
		if has_version ${APACHE2_0_DEPEND}; then
			echo apr-config
		else
			echo apr-1-config
		fi
	else
		if [[ "${default}" == "0" ]]; then
			echo apr-config
		elif [[ "${default}" == "1" ]]; then
			echo apr-1-config
		else
			die "Unknown version specifier: ${default}"
		fi
	fi
}

# @FUNCTION: apu_config
# @DESCRIPTION:
# Version magic to get the correct apu-config binary based on the (probably)
# installed version of apache.  This is needed to get modules to link to the
# same apr/apu as apache (i.e. link 0.9 for 2.0, 1.x for 2.2)
apu_config() {
	debug-print-function $FUNCNAME $*

	local default="${1:-1}"
	if [[ "${USE_APACHE}" == "2" ]]; then
		if has_version ${APACHE2_0_DEPEND}; then
			echo apu-config
		else
			echo apu-1-config
		fi
	else
		if [[ "${default}" == "0" ]]; then
			echo apu-config
		elif [[ "${default}" == "1" ]]; then
			echo apu-1-config
		else
			die "Unknown version specifier: ${default}"
		fi
	fi
}