1 |
The out-of-source.eclass is a simple multilib-minimal-style wrapper |
2 |
to perform out of source builds of autotools (and other) packages. It is |
3 |
mostly derived from the function served in the past by autotools-utils |
4 |
since a number of developers found it useful. However, in order to avoid |
5 |
the mistakes of autotools-utils, it is meant to be focused on a single |
6 |
feature and have a better API. |
7 |
|
8 |
This eclass has two use cases: |
9 |
|
10 |
1. Ensuring that packages are tested with out-of-source builds. |
11 |
|
12 |
2. Improving consistency between multilib and non-multilib packages. |
13 |
|
14 |
// NB: I've even considered naming the phases multilib_*() to make |
15 |
// switching to multilib even easier. |
16 |
|
17 |
In the most basic form, it just redefines the phases from src_configure() |
18 |
to src_install() with out-of-source wrappers. However, each phase can |
19 |
be overriden using my_src_*() sub-phase that is run inside build dir |
20 |
(alike multilib_src_*() in multilib-minimal). There is also |
21 |
my_src_install_all() for the trailing source-dir actions. |
22 |
|
23 |
// I'm wondering whether ECONF_SOURCE should be declared unconditionally |
24 |
// as it is now in the patch, or if it should only be included |
25 |
// in the default and required to be specified in my_src_configure() |
26 |
// when redefined. FWICS, multilib-minimal currently requires it |
27 |
// explicitly specified all the time. |
28 |
--- |
29 |
eclass/out-of-source.eclass | 123 ++++++++++++++++++++++++++++++++++++++++++++ |
30 |
1 file changed, 123 insertions(+) |
31 |
create mode 100644 eclass/out-of-source.eclass |
32 |
|
33 |
diff --git a/eclass/out-of-source.eclass b/eclass/out-of-source.eclass |
34 |
new file mode 100644 |
35 |
index 000000000000..e19256426882 |
36 |
--- /dev/null |
37 |
+++ b/eclass/out-of-source.eclass |
38 |
@@ -0,0 +1,123 @@ |
39 |
+# Copyright 1999-2017 Gentoo Foundation |
40 |
+# Distributed under the terms of the GNU General Public License v2 |
41 |
+ |
42 |
+# @ECLASS: out-of-source.eclass |
43 |
+# @MAINTAINER: |
44 |
+# Michał Górny <mgorny@g.o> |
45 |
+# @BLURB: convenient wrapper to build autotools packages out-of-source |
46 |
+# @DESCRIPTION: |
47 |
+# This eclass provides a minimalistic wrapper interface to easily |
48 |
+# build autotools (and alike) packages out-of-source. It is meant |
49 |
+# to resemble the interface used by multilib-minimal without actually |
50 |
+# requiring the package to be multilib. |
51 |
+# |
52 |
+# For the simplest ebuilds, it is enough to inherit the eclass |
53 |
+# and the new phase functions will automatically build the package |
54 |
+# out-of-source. If you need to redefine one of the default phases |
55 |
+# between src_configure() and src_install(), you need to define |
56 |
+# the sub-phases: my_src_configure(), my_src_compile(), my_src_test() |
57 |
+# and my_src_install() instead that will be run inside the build |
58 |
+# directory. Additionally, my_src_install_all() is provided to perform |
59 |
+# doc-install and other common tasks done in source directory. |
60 |
+# |
61 |
+# Example use: |
62 |
+# @CODE |
63 |
+# inherit out-of-source |
64 |
+# |
65 |
+# my_src_configure() { |
66 |
+# econf \ |
67 |
+# --disable-static |
68 |
+# } |
69 |
+# @CODE |
70 |
+ |
71 |
+case ${EAPI} in |
72 |
+ 6);; |
73 |
+ *) die "EAPI ${EAPI:-0} unsupported (too old)";; |
74 |
+esac |
75 |
+ |
76 |
+EXPORT_FUNCTIONS src_configure src_compile src_test src_install |
77 |
+ |
78 |
+if [[ ! ${_OUT_OF_SOURCE_ECLASS} ]]; then |
79 |
+ |
80 |
+# @FUNCTION: out-of-source_src_configure |
81 |
+# @DESCRIPTION: |
82 |
+# The default src_configure() implementation establishes a BUILD_DIR, |
83 |
+# sets ECONF_SOURCE to the current directory (usually S), and runs |
84 |
+# my_src_configure() (or the default) inside it. |
85 |
+out-of-source_src_configure() { |
86 |
+ debug-print-function ${FUNCNAME} "$@" |
87 |
+ |
88 |
+ # set some BUILD_DIR if we don't have one yet |
89 |
+ : "${BUILD_DIR:=${WORKDIR}/${P}_build}" |
90 |
+ local ECONF_SOURCE=${PWD} |
91 |
+ |
92 |
+ mkdir -p "${BUILD_DIR}" || die |
93 |
+ pushd "${BUILD_DIR}" >/dev/null || die |
94 |
+ if declare -f my_src_configure >/dev/null ; then |
95 |
+ my_src_configure |
96 |
+ else |
97 |
+ default_src_configure |
98 |
+ fi |
99 |
+ popd >/dev/null || die |
100 |
+} |
101 |
+ |
102 |
+# @FUNCTION: out-of-source_src_compile |
103 |
+# @DESCRIPTION: |
104 |
+# The default src_compile() implementation runs my_src_compile() |
105 |
+# (or the default) inside the build directory. |
106 |
+out-of-source_src_compile() { |
107 |
+ debug-print-function ${FUNCNAME} "$@" |
108 |
+ |
109 |
+ pushd "${BUILD_DIR}" >/dev/null || die |
110 |
+ if declare -f my_src_compile >/dev/null ; then |
111 |
+ my_src_compile |
112 |
+ else |
113 |
+ default_src_compile |
114 |
+ fi |
115 |
+ popd >/dev/null || die |
116 |
+} |
117 |
+ |
118 |
+# @FUNCTION: out-of-source_src_test |
119 |
+# @DESCRIPTION: |
120 |
+# The default src_test() implementation runs my_src_test() |
121 |
+# (or the default) inside the build directory. |
122 |
+out-of-source_src_test() { |
123 |
+ debug-print-function ${FUNCNAME} "$@" |
124 |
+ |
125 |
+ pushd "${BUILD_DIR}" >/dev/null || die |
126 |
+ if declare -f my_src_test >/dev/null ; then |
127 |
+ my_src_test |
128 |
+ else |
129 |
+ default_src_test |
130 |
+ fi |
131 |
+ popd >/dev/null || die |
132 |
+} |
133 |
+ |
134 |
+# @FUNCTION: out-of-source_src_install |
135 |
+# @DESCRIPTION: |
136 |
+# The default src_install() implementation runs my_src_install() |
137 |
+# (or the 'make install' part of the default) inside the build directory, |
138 |
+# followed by a call to my_src_install_all() (or 'einstalldocs' part |
139 |
+# of the default) in the original working directory. |
140 |
+out-of-source_src_install() { |
141 |
+ debug-print-function ${FUNCNAME} "$@" |
142 |
+ |
143 |
+ pushd "${BUILD_DIR}" >/dev/null || die |
144 |
+ if declare -f my_src_install >/dev/null ; then |
145 |
+ my_src_install |
146 |
+ else |
147 |
+ if [[ -f Makefile || -f GNUmakefile || -f makefile ]] ; then |
148 |
+ emake DESTDIR="${D}" install |
149 |
+ fi |
150 |
+ fi |
151 |
+ popd >/dev/null || die |
152 |
+ |
153 |
+ if declare -f my_src_install_all >/dev/null ; then |
154 |
+ my_src_install_all |
155 |
+ else |
156 |
+ einstalldocs |
157 |
+ fi |
158 |
+} |
159 |
+ |
160 |
+_OUT_OF_SOURCE_ECLASS=1 |
161 |
+fi |
162 |
-- |
163 |
2.14.1 |