summaryrefslogtreecommitdiff
blob: df3d00eb923722056e623102bcb0290171d2fe20 (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
# Copyright 1999-2008 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.35 2008/11/09 15:47:47 loki_val Exp $

# @ECLASS: base.eclass
# @MAINTAINER:
# Peter Alfredsen <loki_val@gentoo.org>
#
# Original author Dan Armak <danarmak@gentoo.org>
# @BLURB: The base eclass defines some default functions and variables.
# @DESCRIPTION:
# The base eclass defines some default functions and variables. Nearly
# everything else inherits from here.
#
# NOTE: You must define EAPI before inheriting from base, or the wrong functions
# may be exported.


inherit eutils

case "${EAPI:-0}" in
	2)
		EXPORT_FUNCTIONS src_unpack src_prepare src_configure src_compile src_install
		;;
	*)
		EXPORT_FUNCTIONS src_unpack src_compile src_install
		;;
esac

DESCRIPTION="Based on the $ECLASS eclass"

# @FUNCTION: base_src_unpack
# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base src_unpack function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "unpack" if EAPI=2.
base_src_unpack() {

	debug-print-function $FUNCNAME "$@"

	if [ -z "$1" ]
	then
		case "${EAPI:-0}" in
			2)
				base_src_util unpack
				;;
			*)
				base_src_util all
				;;
		esac
	else
		base_src_util $@
	fi
}

# @FUNCTION: base_src_prepare
# @DESCRIPTION:
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_util autopatch".
base_src_prepare() {

	debug-print-function $FUNCNAME "$@"

	base_src_util autopatch
}

# @FUNCTION: base_src_util
# @USAGE: [ unpack ] [ patch ] [ autopatch ] [ all ]
# @DESCRIPTION:
# The base_src_util function is the grunt function for base src_unpack
# and base src_prepare.
base_src_util() {

	debug-print-function $FUNCNAME "$@"

	cd "${WORKDIR}"

	while [ "$1" ]; do

	case $1 in
		unpack)
			debug-print-section unpack
			unpack ${A}
			;;
		patch)
			debug-print-section patch
			cd "${S}"
			epatch "${FILESDIR}/${P}-gentoo.diff"
			;;
		autopatch)
			debug-print-section autopatch
			debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES, PATCHES1=$PATCHES1"
			cd "${S}"
			if [[ ${#PATCHES[@]} -gt 1 ]]; then
				for x in "${PATCHES[@]}"; do
					debug-print "$FUNCNAME: autopatch: patching from ${x}"
					epatch "${x}"
				done
			else
				for x in ${PATCHES} ${PATCHES1}; do
					debug-print "$FUNCNAME: autopatch: patching from ${x}"
					epatch "${x}"
				done
			fi
			;;
		all)
			debug-print-section all
			base_src_util unpack autopatch
			;;
		esac

	shift
	done

}

# @FUNCTION: base_src_configure
# @DESCRIPTION:
# The base src_prepare function, which is exported when EAPI=2. Performs
# "base_src_work configure".
base_src_configure() {

	debug-print-function $FUNCNAME "$@"

	base_src_work configure
}

# @FUNCTION: base_src_compile
# @USAGE: [ configure ] [ make ] [ all ]
# @DESCRIPTION:
# The base src_compile function, which is exported. If no argument is given,
# "all" is assumed if EAPI!=2, "make" if EAPI=2.
base_src_compile() {

	debug-print-function $FUNCNAME "$@"

	if [ -z "$1" ]
	then
		case "${EAPI:-0}" in
			2)
				base_src_work make
				;;
			*)
				base_src_work all
				;;
		esac
	else
		base_src_work $@
	fi
}

# @FUNCTION: base_src_work
# @USAGE: [ configure ] [ make ] [ all ]
# @DESCRIPTION:
# The base_src_work function is the grunt function for base src_configure
# and base src_compile.
base_src_work() {

	debug-print-function $FUNCNAME "$@"

	cd "${S}"

	while [ "$1" ]; do

	case $1 in
		configure)
			debug-print-section configure
			econf || die "died running econf, $FUNCNAME:configure"
			;;
		make)
			debug-print-section make
			emake || die "died running emake, $FUNCNAME:make"
			;;
		all)
			debug-print-section all
			base_src_work configure make
			;;
	esac

	shift
	done

}

# @FUNCTION: base_src_install
# @USAGE: [ make ] [ all ]
# @DESCRIPTION:
# The base src_install function, which is exported. If no argument is given,
# "all" is assumed.
base_src_install() {

	debug-print-function $FUNCNAME "$@"
	[ -z "$1" ] && base_src_install all

	cd "${S}"

	while [ "$1" ]; do

	case $1 in
		make)
			debug-print-section make
			make DESTDIR="${D}" install || die "died running make install, $FUNCNAME:make"
			;;
		all)
			debug-print-section all
			base_src_install make
			;;
	esac

	shift
	done

}