aboutsummaryrefslogtreecommitdiff
blob: 78f4748bc47d92fca5e4ec1bd4174f370e209abd (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
236
237
238
239
240
# Copyright 1999-2013 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

# @ECLASS: qt4-build-multilib.eclass
# @MAINTAINER:
# Greg Turner <gmt@be-evil.net>
# @BLURB: provides a multi-abi-compatible framework similar to qt4-build.eclass
# @DESCRIPTION:
# This eclass wraps the qt4-build.eclass phase functions, providing
# a quick(-ish) migration path for ebuilds based on qt4-build.eclass to
# support multi-ABI profiles.

case ${EAPI} in
	4|5)	: ;;
	*)	die "qt4-build.eclass: unsupported EAPI=${EAPI:-0}" ;;
esac

inherit qt4-build multilib-build ehooker

# @FUNCTION: qt4-build-multilib_pkg_setup
# @DESCRIPTION:
# Sets up PATH and LD_LIBRARY_PATH.
qt4-build-multilib_pkg_setup() {
	debug-print-function "${FUNCNAME}" "$@"
	qt4-build_pkg_setup "$@"
}

# @ECLASS-VARIABLE: QT4_EXTRACT_DIRECTORIES
# @DEFAULT_UNSET
# @DESCRIPTION:
# Space-separated list including the directories that will be extracted from
# Qt tarball.

# @ECLASS-VARIABLE: QT4_TARGET_DIRECTORIES
# @DEFAULT_UNSET
# @DESCRIPTION:
# Arguments for build_target_directories. Takes the directories in which the
# code should be compiled. This is a space-separated list.

# @FUNCTION: qt4-build-multilib_src_unpack
# @DESCRIPTION:
# Unpacks the sources.
qt4-build-multilib_src_unpack() {
	debug-print-function "${FUNCNAME}" "$@"
	qt4-build_src_unpack "$@"
}

# @ECLASS-VARIABLE: PATCHES
# @DEFAULT_UNSET
# @DESCRIPTION:
# PATCHES array variable containing all various patches to be applied.
# This variable is expected to be defined in global scope of ebuild.
# Make sure to specify the full path. This variable is utilised in
# src_prepare() phase.
#
# @CODE
#   PATCHES=( "${FILESDIR}/mypatch.patch"
#             "${FILESDIR}/patches_folder/" )
# @CODE

# @FUNCTION: qt4-build-multilib_src_prepare
# @DESCRIPTION:
# Prepare the build directories for configuration
qt4-build-multilib_src_prepare() {
	debug-print-function "${FUNCNAME}" "$@"

	# unfortunately, qt4-build runs its paches much, much
	# later after several extremely aggressive changes have
	# been made.  We'll just have to shore our patches up to
	# work before instead of after :(
	[[ -n ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
	declare -a PATCHES=( )

	# sadly, qt4-build simply isn't designed for out-of-tree
	# builds, even though qt does support them according to
	# the website.  Even if it did, there are so many
	# ABI-specific hacks injected during qt4-build_src_prepare
	# that we would have to do both qt4-build_src_prepare and
	# qt4-build_src_configure in the qt4-build-multilib_src_configure
	# step to make it work.  What really needs to happen is a full
	# rewrite of qt4-build, which, I suppose, is what qt4-r2 is about.
	#
	# Another alternative would be to stop relying on qt4-build.
	# That way we could create an elegant multilib qt4 framework
	# but unfortunately, without some coordination with developers
	# this invovles maintaining a complete fork of Gentoo's
	# qt4 framework :(
	#
	# Therefore, we follow the path of least resistance and just....
	multilib_copy_sources

	debug-print "${FUNCNAME}___0: $(ls -l ${S})"

	_qt4-build-multilib_src_prepare_hookwrap() {
		local S="${BUILD_DIR}"
		if ehook_fire qt4-build-multilib-pre_src_prepare ; then
			debug-print "${FUNCNAME}___1${ABI}: $(ls -l ${S})"

			qt4-build_src_prepare "$@"

			debug-print "${FUNCNAME}___2${ABI}: $(ls -l ${S})"
			# make sure PKG_CONFIG_{LIBDIR,PATH} go into the forced variables
			# lest we end up pulling in all kinds of DEFAULT_ABI crap

			debug-print "${FUNCNAME}: applying PKG_CONFIG_LIBDIR and PKG_CONFIG_PATH overrides in configure"
			sed -e "/^SYSTEM_VARIABLES=/i \
PKG_CONFIG_LIBDIR='${EPREFIX}/usr/$(get_libdir)/pkgconfig'\n\
PKG_CONFIG_PATH='${EPREFIX}/usr/share/pkgconfig'\n" \
				-i configure \
				|| die "sed SYSTEM_VARIABLES failed"
# 			sed -e '/^SYSTEM_VARIABLES=/s/"$/ PKG_CONFIG_LIBDIR PKG_CONFIG_PATH"/' -i configure \
#				|| die "sed SYSTEM VARIABLES (part II) failed"
			debug-print "${FUNCNAME}___3${ABI}: $(ls -l ${S})"
		fi
		ehook_fire qt4-build-multilib-post_src_prepare -u
	}

	multilib_parallel_foreach_abi run_in_build_dir \
		_qt4-build-multilib_src_prepare_hookwrap "$@"
}

# @FUNCTION: qt4-build-multilib_src_configure
# @DESCRIPTION:
qt4-build-multilib_src_configure() {
	debug-print-function "${FUNCNAME}" "$@"

	_qt4-build-multilib_src_configure_hookwrap() {
		debug-print-function "${FUNCNAME}" "$@"

		_qt4_get_libdir_subst_myconf() {
			local oldconfarg newconfarg newmyconf
			for oldconfarg in ${myconf} ; do
				newconfarg="$(get_libdir_subst "${oldconfarg}")"
				[[ ${newconfarg} == ${oldconfarg} ]] || \
					einfo "patched configure argument for ABI ${ABI}: \"${newconfarg}\""
				newmyconf="${newmyconf}${newmyconf:+ }${newconfarg}"
			done
			myconf="${newmyconf}"
		}

		# we definitely don't want changes to "myconf" flowing
		# down the call stack and out of
		# qt4-build-multilib_src_configure.  The fact that
		# it doesn't is an implementation quirk
		# of multiprocessing.eclass that we shouldn't be
		# relying on, somebody might "fix" that (very doubtful)
		# or it might not apply when MAKEOPTS=-j1
		# anyhow doing this is just cleaner/safer
		local myconf="${myconf}"
		_qt4_get_libdir_subst_myconf

		local S="${BUILD_DIR}"
		ehook_fire qt4-build-multilib-pre_src_configure && \
			qt4-build_src_configure "$@"
		ehook_fire qt4-build-multilib-post_src_configure -u
	}

	multilib_parallel_foreach_abi run_in_build_dir \
		_qt4-build-multilib_src_configure_hookwrap "$@"
}

# @FUNCTION: qt4-build-multilib_src_compile
# @DESCRIPTION:
# Compile the sources
qt4-build-multilib_src_compile() {
	debug-print-function "${FUNCNAME}" "$@"

	_qt4-build-multilib_src_compile_hookwrap() {
		debug-print-function "${FUNCNAME}" "$@"
		local S="${BUILD_DIR}"
		ehook_fire qt4-build-multilib-pre_src_compile && \
			qt4-build_src_compile "$@"
		ehook_fire qt4-build-multilib-post_src_compile -u
	}

	multilib_parallel_foreach_abi run_in_build_dir \
		_qt4-build-multilib_src_compile_hookwrap "$@"
}

# @FUNCTION: qt4-build-multilib_src_test
# @DESCRIPTION:
# Run the test suite for each supported ABI
qt4-build-multilib_src_test() {
	debug-print-function "${FUNCNAME}" "$@"

	_qt4-build-multilib_src_test_hookwrap() {
		debug-print-function "${FUNCNAME}" "$@"
		local S="${BUILD_DIR}"
		ehook_fire qt4-build-multilib-pre_src_test && \
			qt4-build_src_test "$@"
		ehook_fire qt4-build-multilib-post_src_test -u
	}

	multilib_parallel_foreach_abi run_in_build_dir \
		qt4-build-multilib_src_test_hookwrap "$@"
}

# @FUNCTION: qt4-build-multilib_src_install
# @DESCRIPTION:
# Install the compiled software
qt4-build-multilib_src_install() {
	debug-print-function "${FUNCNAME}" "$@"

	_qt4-build-multilib_secure_install() {
		debug-print-function "${FUNCNAME}" "$@"
		local S="${BUILD_DIR}"
		ehook_fire qt4-build-multilib-pre_src_install && \
			qt4-build_src_install "${@}"
		ehook_fire qt4-build-multilib-post_src_install -u
		# Do multilib magic only when >1 ABI is used.
		if [[ ${#MULTIBUILD_VARIANTS[@]} -gt 1 ]]; then
			multilib_prepare_wrappers
			# Make sure all headers are the same for each ABI.
			multilib_check_headers
		fi
	}
	multilib_foreach_abi run_in_build_dir \
		_qt4-build-multilib_secure_install "$@"
	# merge the wrappers
	multilib_install_wrappers
}

# @FUNCTION: qt4-build-multilib_pkg_postinst
# @DESCRIPTION:
# Regenerate configuration when the package is installed.
qt4-build-multilib_pkg_postinst() {
	debug-print-function "${FUNCNAME}" "$@"
	qt4-build_pkg_postinst "$@"
}

# @FUNCTION: qt4-build-multilib_pkg_postrm
# @DESCRIPTION:
# Regenerate configuration when the package is completely removed.
qt4-build-multilib_pkg_postrm() {
	debug-print-function "${FUNCNAME}" "$@"
	qt4-build_pkg_postrm "$@"
}

EXPORT_FUNCTIONS pkg_setup src_unpack src_prepare src_configure src_compile src_test src_install pkg_postrm pkg_postinst