| 1 | # Copyright 1999-2000 Gentoo Technologies, Inc. |
1 | # Copyright 1999-2011 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # Author Dan Armak <danarmak@gentoo.org> |
|
|
| 4 | # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.18 2002/10/25 19:55:52 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/base.eclass,v 1.55 2011/12/14 23:38:09 vapier Exp $ |
| 5 | # The base eclass defines some default functions and variables. Nearly everything |
|
|
| 6 | # else inherits from here. |
|
|
| 7 | |
4 | |
| 8 | ECLASS=base |
5 | # @ECLASS: base.eclass |
| 9 | INHERITED="$INHERITED $ECLASS" |
6 | # @MAINTAINER: |
| 10 | S=${WORKDIR}/${P} |
7 | # QA Team <qa@gentoo.org> |
| 11 | DESCRIPTION="Based on the $ECLASS eclass" |
8 | # @AUTHOR: |
|
|
9 | # Original author: Dan Armak <danarmak@gentoo.org> |
|
|
10 | # @BLURB: The base eclass defines some default functions and variables. |
|
|
11 | # @DESCRIPTION: |
|
|
12 | # The base eclass defines some default functions and variables. Nearly |
|
|
13 | # everything else inherits from here. |
| 12 | |
14 | |
|
|
15 | if [[ ${___ECLASS_ONCE_BASE} != "recur -_+^+_- spank" ]] ; then |
|
|
16 | ___ECLASS_ONCE_BASE="recur -_+^+_- spank" |
|
|
17 | |
|
|
18 | inherit eutils |
|
|
19 | |
|
|
20 | BASE_EXPF="src_unpack src_compile src_install" |
|
|
21 | case "${EAPI:-0}" in |
|
|
22 | 2|3|4) BASE_EXPF+=" src_prepare src_configure" ;; |
|
|
23 | *) ;; |
|
|
24 | esac |
|
|
25 | |
|
|
26 | EXPORT_FUNCTIONS ${BASE_EXPF} |
|
|
27 | |
|
|
28 | # @ECLASS-VARIABLE: DOCS |
|
|
29 | # @DESCRIPTION: |
|
|
30 | # Array containing documents passed to dodoc command. |
|
|
31 | # |
|
|
32 | # DOCS=( "${S}/doc/document.txt" "${S}/doc/doc_folder/" ) |
|
|
33 | |
|
|
34 | # @ECLASS-VARIABLE: HTML_DOCS |
|
|
35 | # @DESCRIPTION: |
|
|
36 | # Array containing documents passed to dohtml command. |
|
|
37 | # |
|
|
38 | # HTML_DOCS=( "${S}/doc/document.html" "${S}/doc/html_folder/" ) |
|
|
39 | |
|
|
40 | # @ECLASS-VARIABLE: PATCHES |
|
|
41 | # @DESCRIPTION: |
|
|
42 | # PATCHES array variable containing all various patches to be applied. |
|
|
43 | # This variable is expected to be defined in global scope of ebuild. |
|
|
44 | # Make sure to specify the full path. This variable is utilised in |
|
|
45 | # src_unpack/src_prepare phase based on EAPI. |
|
|
46 | # |
|
|
47 | # NOTE: if using patches folders with special file suffixes you have to |
|
|
48 | # define one additional variable EPATCH_SUFFIX="something" |
|
|
49 | # |
|
|
50 | # PATCHES=( "${FILESDIR}/mypatch.patch" "${FILESDIR}/patches_folder/" ) |
|
|
51 | |
|
|
52 | |
|
|
53 | # @FUNCTION: base_src_unpack |
|
|
54 | # @DESCRIPTION: |
|
|
55 | # The base src_unpack function, which is exported. |
|
|
56 | # Calls also src_prepare with eapi older than 2. |
| 13 | base_src_unpack() { |
57 | base_src_unpack() { |
|
|
58 | debug-print-function $FUNCNAME "$@" |
| 14 | |
59 | |
| 15 | debug-print-function $FUNCNAME $* |
60 | pushd "${WORKDIR}" > /dev/null |
| 16 | [ -z "$1" ] && base_src_unpack all |
|
|
| 17 | |
61 | |
| 18 | cd ${WORKDIR} |
62 | [[ -n "${A}" ]] && unpack ${A} |
|
|
63 | has src_prepare ${BASE_EXPF} || base_src_prepare |
| 19 | |
64 | |
| 20 | while [ "$1" ]; do |
65 | popd > /dev/null |
| 21 | |
|
|
| 22 | case $1 in |
|
|
| 23 | unpack) |
|
|
| 24 | debug-print-section unpack |
|
|
| 25 | # rather ugly fix - check for usage of kde-patch.eclass |
|
|
| 26 | [ -n "$PATCH" -a -n "$ORIGPV" -a -n "$DATE" -a -n "$OLDIFS" ] && \ |
|
|
| 27 | A="`echo $A | sed -e s:${PATCH}::g --`" |
|
|
| 28 | unpack ${A} |
|
|
| 29 | ;; |
|
|
| 30 | patch) |
|
|
| 31 | debug-print-section patch |
|
|
| 32 | cd ${S} |
|
|
| 33 | patch -p0 < ${FILESDIR}/${P}-gentoo.diff |
|
|
| 34 | ;; |
|
|
| 35 | autopatch) |
|
|
| 36 | debug-print-section autopatch |
|
|
| 37 | debug-print "$FUNCNAME: autopatch: PATCHES=$PATCHES" |
|
|
| 38 | cd ${S} |
|
|
| 39 | for x in $PATCHES; do |
|
|
| 40 | debug-print "$FUNCNAME: autopatch: patching from ${x}" |
|
|
| 41 | patch -p0 < ${x} |
|
|
| 42 | done |
|
|
| 43 | ;; |
|
|
| 44 | all) |
|
|
| 45 | debug-print-section all |
|
|
| 46 | base_src_unpack unpack autopatch |
|
|
| 47 | ;; |
|
|
| 48 | esac |
|
|
| 49 | |
|
|
| 50 | shift |
|
|
| 51 | done |
|
|
| 52 | |
|
|
| 53 | } |
66 | } |
| 54 | |
67 | |
|
|
68 | # @FUNCTION: base_src_prepare |
|
|
69 | # @DESCRIPTION: |
|
|
70 | # The base src_prepare function, which is exported |
|
|
71 | # EAPI is greater or equal to 2. Here the PATCHES array is evaluated. |
| 55 | base_src_compile() { |
72 | base_src_prepare() { |
|
|
73 | debug-print-function $FUNCNAME "$@" |
|
|
74 | debug-print "$FUNCNAME: PATCHES=$PATCHES" |
| 56 | |
75 | |
| 57 | debug-print-function $FUNCNAME $* |
76 | local patches_failed=0 |
| 58 | [ -z "$1" ] && base_src_compile all |
|
|
| 59 | |
77 | |
| 60 | cd ${S} |
78 | pushd "${S}" > /dev/null |
|
|
79 | if [[ "$(declare -p PATCHES 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
|
|
80 | for x in "${PATCHES[@]}"; do |
|
|
81 | debug-print "$FUNCNAME: applying patch from ${x}" |
|
|
82 | if [[ -d "${x}" ]]; then |
|
|
83 | # Use standardized names and locations with bulk patching |
|
|
84 | # Patch directory is ${WORKDIR}/patch |
|
|
85 | # See epatch() in eutils.eclass for more documentation |
|
|
86 | EPATCH_SUFFIX=${EPATCH_SUFFIX:=patch} |
| 61 | |
87 | |
| 62 | while [ "$1" ]; do |
88 | # in order to preserve normal EPATCH_SOURCE value that can |
|
|
89 | # be used other way than with base eclass store in local |
|
|
90 | # variable and restore later |
|
|
91 | oldval=${EPATCH_SOURCE} |
|
|
92 | EPATCH_SOURCE=${x} |
|
|
93 | EPATCH_FORCE=yes |
|
|
94 | epatch |
|
|
95 | EPATCH_SOURCE=${oldval} |
|
|
96 | elif [[ -f "${x}" ]]; then |
|
|
97 | epatch "${x}" |
|
|
98 | else |
|
|
99 | ewarn "QA: File or directory \"${x}\" does not exist." |
|
|
100 | ewarn "QA: Check your PATCHES array or add missing file/directory." |
|
|
101 | patches_failed=1 |
|
|
102 | fi |
|
|
103 | done |
|
|
104 | [[ ${patches_failed} -eq 1 ]] && die "Some patches failed. See above messages." |
|
|
105 | else |
|
|
106 | for x in ${PATCHES}; do |
|
|
107 | debug-print "$FUNCNAME: patching from ${x}" |
|
|
108 | epatch "${x}" |
|
|
109 | done |
|
|
110 | fi |
| 63 | |
111 | |
| 64 | case $1 in |
112 | # Apply user patches |
| 65 | configure) |
113 | debug-print "$FUNCNAME: applying user patches" |
| 66 | debug-print-section configure |
114 | epatch_user |
| 67 | econf || die "died running econf, $FUNCNAME:configure" |
115 | |
| 68 | ;; |
116 | popd > /dev/null |
| 69 | make) |
|
|
| 70 | debug-print-section make |
|
|
| 71 | emake || die "died running emake, $FUNCNAME:make" |
|
|
| 72 | ;; |
|
|
| 73 | all) |
|
|
| 74 | debug-print-section all |
|
|
| 75 | base_src_compile configure make |
|
|
| 76 | ;; |
|
|
| 77 | esac |
|
|
| 78 | |
|
|
| 79 | shift |
|
|
| 80 | done |
|
|
| 81 | |
|
|
| 82 | } |
117 | } |
| 83 | |
118 | |
| 84 | base_src_install() { |
119 | # @FUNCTION: base_src_configure |
|
|
120 | # @DESCRIPTION: |
|
|
121 | # The base src_configure function, which is exported when |
|
|
122 | # EAPI is greater or equal to 2. Runs basic econf. |
|
|
123 | base_src_configure() { |
|
|
124 | debug-print-function $FUNCNAME "$@" |
| 85 | |
125 | |
| 86 | debug-print-function $FUNCNAME $* |
126 | # there is no pushd ${S} so we can override its place where to run |
| 87 | [ -z "$1" ] && base_src_install all |
127 | [[ -x ${ECONF_SOURCE:-.}/configure ]] && econf "$@" |
| 88 | |
|
|
| 89 | cd ${S} |
|
|
| 90 | |
|
|
| 91 | while [ "$1" ]; do |
|
|
| 92 | |
|
|
| 93 | case $1 in |
|
|
| 94 | make) |
|
|
| 95 | debug-print-section make |
|
|
| 96 | make DESTDIR=${D} install || die "died running make install, $FUNCNAME:make" |
|
|
| 97 | ;; |
|
|
| 98 | all) |
|
|
| 99 | debug-print-section all |
|
|
| 100 | base_src_install make |
|
|
| 101 | ;; |
|
|
| 102 | esac |
|
|
| 103 | |
|
|
| 104 | shift |
|
|
| 105 | done |
|
|
| 106 | |
|
|
| 107 | } |
128 | } |
| 108 | |
129 | |
| 109 | EXPORT_FUNCTIONS src_unpack src_compile src_install |
130 | # @FUNCTION: base_src_compile |
|
|
131 | # @DESCRIPTION: |
|
|
132 | # The base src_compile function, calls src_configure with |
|
|
133 | # EAPI older than 2. |
|
|
134 | base_src_compile() { |
|
|
135 | debug-print-function $FUNCNAME "$@" |
|
|
136 | |
|
|
137 | has src_configure ${BASE_EXPF} || base_src_configure |
|
|
138 | base_src_make "$@" |
|
|
139 | } |
|
|
140 | |
|
|
141 | # @FUNCTION: base_src_make |
|
|
142 | # @DESCRIPTION: |
|
|
143 | # Actual function that runs emake command. |
|
|
144 | base_src_make() { |
|
|
145 | debug-print-function $FUNCNAME "$@" |
|
|
146 | |
|
|
147 | if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then |
|
|
148 | emake "$@" || die "died running emake, $FUNCNAME" |
|
|
149 | fi |
|
|
150 | } |
|
|
151 | |
|
|
152 | # @FUNCTION: base_src_install |
|
|
153 | # @DESCRIPTION: |
|
|
154 | # The base src_install function. Runs make install and |
|
|
155 | # installs documents and html documents from DOCS and HTML_DOCS |
|
|
156 | # arrays. |
|
|
157 | base_src_install() { |
|
|
158 | debug-print-function $FUNCNAME "$@" |
|
|
159 | |
|
|
160 | emake DESTDIR="${D}" "$@" install || die "died running make install, $FUNCNAME" |
|
|
161 | base_src_install_docs |
|
|
162 | } |
|
|
163 | |
|
|
164 | # @FUNCTION: base_src_install_docs |
|
|
165 | # @DESCRIPTION: |
|
|
166 | # Actual function that install documentation from |
|
|
167 | # DOCS and HTML_DOCS arrays. |
|
|
168 | base_src_install_docs() { |
|
|
169 | debug-print-function $FUNCNAME "$@" |
|
|
170 | |
|
|
171 | local x |
|
|
172 | |
|
|
173 | pushd "${S}" > /dev/null |
|
|
174 | |
|
|
175 | if [[ "$(declare -p DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
|
|
176 | for x in "${DOCS[@]}"; do |
|
|
177 | debug-print "$FUNCNAME: docs: creating document from ${x}" |
|
|
178 | dodoc "${x}" || die "dodoc failed" |
|
|
179 | done |
|
|
180 | fi |
|
|
181 | if [[ "$(declare -p HTML_DOCS 2>/dev/null 2>&1)" == "declare -a"* ]]; then |
|
|
182 | for x in "${HTML_DOCS[@]}"; do |
|
|
183 | debug-print "$FUNCNAME: docs: creating html document from ${x}" |
|
|
184 | dohtml -r "${x}" || die "dohtml failed" |
|
|
185 | done |
|
|
186 | fi |
|
|
187 | |
|
|
188 | popd > /dev/null |
|
|
189 | } |
|
|
190 | |
|
|
191 | fi |