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
|
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/eclass/autotools-multilib.eclass,v 1.19 2013/11/24 10:53:43 mgorny Exp $
# @ECLASS: autotools-multilib.eclass
# @MAINTAINER:
# Michał Górny <mgorny@gentoo.org>
# @BLURB: autotools-utils wrapper for multilib builds
# @DESCRIPTION:
# The autotools-multilib.eclass is an autotools-utils.eclass(5) wrapper
# introducing support for building for more than one ABI (multilib).
#
# Inheriting this eclass sets the USE flags and exports autotools-utils
# phase function wrappers which build the package for each supported ABI
# when the relevant flag is enabled. Other than that, it works like
# regular autotools-utils.
#
# The multilib phase functions can be overriden via defining multilib_*
# phase functions as in multilib-minimal.eclass. In some cases you may
# need to call the underlying autotools-utils_* phase though.
#
# Note that the multilib support requires out-of-source builds to be
# enabled. Thus, it is impossible to use AUTOTOOLS_IN_SOURCE_BUILD with
# it.
# EAPI=4 is required for meaningful MULTILIB_USEDEP.
case ${EAPI:-0} in
4|5) ;;
*) die "EAPI=${EAPI} is not supported" ;;
esac
if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]]; then
die "${ECLASS}: multilib support requires out-of-source builds."
fi
inherit autotools-utils eutils multilib-build multilib-minimal ehooker multilib my-god-its-full-of-quotation-marks
EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
# Note: _at_args[@] passing is a backwards compatibility measure.
# Don't use it in new packages.
autotools-multilib_src_prepare() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
if ehook_fire autotools-multilib-global-pre_src_prepare ; then
autotools-utils_src_prepare "${@}"
[[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]] && multilib_copy_sources
fi
ehook_fire autotools-multilib-global-post_src_prepare -u
}
# generate ehook listeners for autotools-utils per-phase pre/post ehooks, which
# fire an equivalent (but less confusingly named) autotools-multilib-level e-hook.
_autotools-multilib_wrap_autotools_utils_phase_hooks() {
local phase evaltext
for phase in src_configure src_compile src_test src_install ; do
read -r -d '' evaltext <<-EOF
_autotools-multilib-autotools-utils-pre_${phase}_wrapper() {
debug-print-function \${FUNCNAME} "\$(my-god-its-full-of-quotation-marks "\$@")"
ehook_fire autotools-multilib-per-abi-pre_${phase}
local rslt=\$?
if [[ \${rslt} == 0 ]] ; then
if multilib_is_best_abi ; then
ehook_fire autotools-multilib-best-abi-pre_${phase}
rslt=\$?
fi
fi
[[ \$rslt == 0 ]] && _AUTOTOOLS_MULTILIB_PHASE=${phase} ehook_fire autotools-multilib-internal-per-abi_postproc -u
return \$rslt
}
_autotools-multilib-autotools-utils-post_${phase}_wrapper() {
debug-print-function \${FUNCNAME} "\$(my-god-its-full-of-quotation-marks "\$@")"
ehook_fire autotools-multilib-per-abi-post_${phase} -u
if multilib_is_best_abi ; then
ehook_fire autotools-multilib-best-abi-post_${phase} -u
fi
}
EOF
eval "${evaltext}"
done
_AUTOTOOLS_MULTILIB_AUTOTOOLS_UTILS_HOOKS_WRAPPED=yes
}
[[ ${_AUTOTOOLS_MULTILIB_AUTOTOOLS_UTILS_HOOKS_WRAPPED} ]] || \
_autotools-multilib_wrap_autotools_utils_phase_hooks
# do @GET_LIBDIR@ substitution in each of the named arrays
_autotools-multilib_libdir_subst() {
local _array _array_reference _item
for _array in "$@"; do
local _new_array=()
_array_reference="${_array}[@]"
for _item in "${!_array_reference}"; do
_new_array+=("${_item//@GET_LIBDIR@/$(get_libdir)}")
done
eval "${_array}=(\"\${_new_array[@]}\")"
done
}
ehook autotools-multilib-internal-per-abi_postproc _autotools-multilib_abi_postproc
# munge @GET_LIBDIR@ arguments flowing into phase actions as appropriate
_autotools-multilib_abi_postproc() {
case ${_AUTOTOOLS_MULTILIB_PHASE} in
src_configure) _autotools-multilib_libdir_subst myeconfargs othereconfargs ;;
src_compile) _autotools-multilib_libdir_subst myemakeargs otheremakeargs ;;
src_test) _autotools-multilib_libdir_subst myemaketestargs otheremaketestargs ;;
src_install) _autotools-multilib_libdir_subst myemakeinstallargs otheremakeinstallargs ;;
*) die "Don't know what to do about phase \"${_AUTOTOOLS_MULTILIB_PHASE}\"" ;;
esac
}
_autotools-multilib_munge_build_dir() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
# playing games with BUILD_DIR, S, and ECONF_SOURCE, as we do here, is problematic when
# AUTOTOOLS_IN_SOURCE_BUILD is on, as this can trigger complex interactions with
# _check_build_dir in autotools-utils, which leaves a bit of a mess behind after per-abi
# processing in some cases. Forgetting them after each ABI is processed prevents this.
local S="${S}"
local BUILD_DIR="${BUILD_DIR}"
local ECONF_SOURCE="${ECONF_SOURCE}"
local AUTOTOOLS_IN_SOURCE_BUILD_DIR="${AUTOTOOLS_IN_SOURCE_BUILD_DIR}"
if [[ ${AUTOTOOLS_IN_SOURCE_BUILD} ]] ; then
AUTOTOOLS_IN_SOURCE_BUILD_DIR="${AUTOTOOLS_IN_SOURCE_BUILD_DIR:-${BUILD_DIR}}"
# it's debatable if we should change S here. But I think doing so leads to a more intuitive
# result. Certainly, it'd allow more code to work unmodified, when porting non-multibuild ebuilds
S="${AUTOTOOLS_IN_SOURCE_BUILD_DIR}"
fi
"$@"
}
multilib_src_configure() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
ehook autotools-utils-pre_src_configure _autotools-multilib-autotools-utils-pre_src_configure_wrapper
ehook autotools-utils-post_src_configure _autotools-multilib-autotools-utils-post_src_configure_wrapper
_autotools-multilib_munge_build_dir \
autotools-utils_src_configure "${_at_args[@]}"
eunhook autotools-utils-pre_src_configure _autotools-multilib-autotools-utils-pre_src_configure_wrapper
eunhook autotools-utils-post_src_configure _autotools-multilib-autotools-utils-post_src_configure_wrapper
}
autotools-multilib_src_configure() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
local _at_args=( "${@}" )
ehook_fire autotools-multilib-global-pre_src_configure && \
multilib-minimal_src_configure
ehook_fire autotools-multilib-global-post_src_configure -u
}
multilib_src_compile() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
ehook autotools-utils-pre_src_compile _autotools-multilib-autotools-utils-pre_src_compile_wrapper
ehook autotools-utils-post_src_compile _autotools-multilib-autotools-utils-post_src_compile_wrapper
_autotools-multilib_munge_build_dir \
autotools-utils_src_compile "${_at_args[@]}"
eunhook autotools-utils-pre_src_compile _autotools-multilib-autotools-utils-pre_src_compile_wrapper
eunhook autotools-utils-post_src_compile _autotools-multilib-autotools-utils-post_src_compile_wrapper
}
autotools-multilib_src_compile() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
local _at_args=( "${@}" )
ehook_fire autotools-multilib-global-pre_src_compile && \
multilib-minimal_src_compile
ehook_fire autotools-multilib-global-post_src_compile -u
}
multilib_src_test() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
ehook autotools-utils-pre_src_test _autotools-multilib-autotools-utils-pre_src_test_wrapper
ehook autotools-utils-post_src_test _autotools-multilib-autotools-utils-post_src_test_wrapper
_autotools-multilib_munge_build_dir \
autotools-utils_src_test "${_at_args[@]}"
eunhook autotools-utils-pre_src_test _autotools-multilib-autotools-utils-pre_src_test_wrapper
eunhook autotools-utils-post_src_test _autotools-multilib-autotools-utils-post_src_test_wrapper
}
autotools-multilib_src_test() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
local _at_args=( "${@}" )
ehook_fire autotools-multilib-global-pre_src_test && \
multilib-minimal_src_test
ehook_fire autotools-multilib-global-post_src_test -u
}
multilib_src_install() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
# override some variables that autotools-utils would attempt to process, but
# for which we have alternate processing in multilib_src_install_all. This
# prevents pointless repeat-installation of nongenerated documentation.
local AUTOTOOLS_PRUNE_LIBTOOL_FILES="none" DOCS=() HTML_DOCS=()
ehook autotools-utils-pre_src_install _autotools-multilib-autotools-utils-pre_src_install_wrapper
ehook autotools-utils-post_src_install _autotools-multilib-autotools-utils-post_src_install_wrapper
_autotools-multilib_munge_build_dir \
autotools-utils_src_install "${_at_args[@]}"
eunhook autotools-utils-pre_src_install _autotools-multilib-autotools-utils-pre_src_install_wrapper
eunhook autotools-utils-post_src_install _autotools-multilib-autotools-utils-post_src_install_wrapper
}
multilib_src_install_all() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
einstalldocs
# Remove libtool files and unnecessary static libs
local prune_ltfiles=${AUTOTOOLS_PRUNE_LIBTOOL_FILES}
if [[ ${prune_ltfiles} != none ]]; then
prune_libtool_files ${prune_ltfiles:+--${prune_ltfiles}}
fi
}
autotools-multilib_src_install() {
debug-print-function ${FUNCNAME} "$(my-god-its-full-of-quotation-marks "$@")"
local _at_args=( "${@}" )
ehook_fire autotools-multilib-global-pre_src_install && \
multilib-minimal_src_install
ehook_fire autotools-multilib-global-post_src_install -u
}
|