Gentoo Archives: gentoo-dev

From: Davide Pesavento <pesa@g.o>
To: "Michał Górny" <mgorny@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [RFC] qt5-build.eclass
Date: Wed, 27 Aug 2014 00:24:54
Message-Id: CADfzvvaFyC1vdTOW+d0R-cXJs6gHKYntr6ytb9Pj8W-_aSJB4w@mail.gmail.com
In Reply to: Re: [gentoo-dev] [RFC] qt5-build.eclass by "Michał Górny"
1 On Wed, Aug 20, 2014 at 10:07 AM, Michał Górny <mgorny@g.o> wrote:
2 > Dnia 2014-08-17, o godz. 20:38:18
3 > Davide Pesavento <pesa@g.o> napisał(a):
4 >
5 >> # @FUNCTION: qt5-build_src_unpack
6 >> # @DESCRIPTION:
7 >> # Unpacks the sources.
8 >> qt5-build_src_unpack() {
9 >> if [[ $(gcc-major-version) -lt 4 ]] || [[ $(gcc-major-version) -eq 4 && $(gcc-minor-version) -lt 5 ]]; then
10 >> ewarn
11 >> ewarn "Using a GCC version lower than 4.5 is not supported."
12 >> ewarn
13 >> fi
14 >>
15 >> if [[ ${PN} == qtwebkit ]]; then
16 >> eshopts_push -s extglob
17 >> if is-flagq '-g?(gdb)?([1-9])'; then
18 >
19 > Wouldn't that be equivalent to '-g[^0]'? And I think this would
20 > actually work without extglob.
21
22 That doesn't match '-g' though, does it?
23
24 >
25 >> ewarn
26 >> ewarn "You have enabled debug info (probably have -g or -ggdb in your CFLAGS/CXXFLAGS)."
27 >> ewarn "You may experience really long compilation times and/or increased memory usage."
28 >> ewarn "If compilation fails, please try removing -g/-ggdb before reporting a bug."
29 >> ewarn "For more info check out https://bugs.gentoo.org/307861"
30 >> ewarn
31 >> fi
32 >> eshopts_pop
33 >> fi
34 >>
35 >> case ${QT5_BUILD_TYPE} in
36 >> live) git-r3_src_unpack ;;
37 >> release) default ;;
38 >> esac
39 >> }
40 >>
41 >> # @FUNCTION: qt5-build_src_prepare
42 >> # @DESCRIPTION:
43 >> # Prepares the sources before the configure phase.
44 >> qt5-build_src_prepare() {
45 >> qt5_prepare_env
46 >>
47 >> if [[ ${QT5_MODULE} == qtbase ]]; then
48 >> # Avoid unnecessary qmake recompilations
49 >> sed -i -re "s|^if true;.*(\[ '\!').*(\"\\\$outpath/bin/qmake\".*)|if \1 -e \2 then|" \
50 >> configure || die "sed failed (skip qmake bootstrap)"
51 >
52 > Any chance for something more readable? :) Like a inline patch.
53
54 I think it's a fairly straightforward substitution, not pretty maybe
55 but... heh ;) Also, it's not something that you have to look at all
56 the time since the configure line doesn't change often, and the intent
57 is clear from the comment, so I'm not going to change it.
58
59 >
60 >> # Respect CC, CXX, *FLAGS, MAKEOPTS and EXTRA_EMAKE when bootstrapping qmake
61 >> sed -i -e "/outpath\/qmake\".*\"\$MAKE\")/ s:): \
62 >> ${MAKEOPTS} ${EXTRA_EMAKE} 'CC=$(tc-getCC)' 'CXX=$(tc-getCXX)' \
63 >> 'QMAKE_CFLAGS=${CFLAGS}' 'QMAKE_CXXFLAGS=${CXXFLAGS}' 'QMAKE_LFLAGS=${LDFLAGS}'&:" \
64 >> -e '/"$CFG_RELEASE_QMAKE"/,/^\s\+fi$/ d' \
65 >> configure || die "sed failed (respect env for qmake build)"
66 >
67 > Ditto ;).
68
69 ditto ;)
70
71 >
72 >> sed -i -e '/^CPPFLAGS\s*=/ s/-g //' \
73 >> qmake/Makefile.unix || die "sed failed (CPPFLAGS for qmake build)"
74 >>
75 >> # Respect CXX in {bsymbolic_functions,fvisibility,precomp}.test
76 >> sed -i -e "/^QMAKE_CONF_COMPILER=/ s:=.*:=\"$(tc-getCXX)\":" \
77 >> configure || die "sed failed (QMAKE_CONF_COMPILER)"
78 >>
79 >> # Respect toolchain and flags in config.tests
80 >> find config.tests/unix -name '*.test' -type f -print0 \
81 >> | xargs -0 sed -i -e '/bin\/qmake/ s/-nocache //' \
82 >> || die "sed failed (config.tests)"
83 >
84 > find ... -exec sed ... {} +
85 >
86 >> fi
87 >>
88 >> if [[ ${PN} != qtcore ]]; then
89 >> qt5_symlink_tools_to_build_dir
90 >> fi
91 >>
92 >> # apply patches
93 >> [[ ${PATCHES[@]} ]] && epatch "${PATCHES[@]}"
94 >> epatch_user
95 >> }
96 >
97 > [...]
98 >
99 >> # @FUNCTION: qt5-build_src_install
100 >> # @DESCRIPTION:
101 >> # Performs the actual installation of target directories.
102 >> qt5-build_src_install() {
103 >> qt5_foreach_target_subdir emake INSTALL_ROOT="${D}" install
104 >>
105 >> if [[ ${PN} == qtcore ]]; then
106 >> pushd "${QT5_BUILD_DIR}" >/dev/null || die
107 >> einfo "Running emake INSTALL_ROOT=${D} install_{mkspecs,qmake,syncqt}"
108 >
109 > You can put that command-line in an array or set to argv.
110 >
111 >> emake INSTALL_ROOT="${D}" install_{mkspecs,qmake,syncqt}
112 >> popd >/dev/null || die
113 >>
114 >> # install an empty Gentoo/gentoo-qconfig.h in ${D}
115 >> # so that it's placed under package manager control
116 >> > "${T}"/gentoo-qconfig.h
117 >> (
118 >> insinto "${QT5_HEADERDIR#${EPREFIX}}"/Gentoo
119 >> doins "${T}"/gentoo-qconfig.h
120 >> )
121 >>
122 >> # include gentoo-qconfig.h at the beginning of QtCore/qconfig.h
123 >> sed -i -e '1a#include <Gentoo/gentoo-qconfig.h>\n' \
124 >> "${D}${QT5_HEADERDIR}"/QtCore/qconfig.h \
125 >> || die "sed failed (qconfig.h)"
126 >> fi
127 >>
128 >> qt5_install_module_qconfigs
129 >> prune_libtool_files
130 >> }
131 >
132 > [...]
133 >
134 >> # @FUNCTION: qt5_base_configure
135 >> # @INTERNAL
136 >> # @DESCRIPTION:
137 >> # Runs ./configure for modules belonging to qtbase.
138 >> qt5_base_configure() {
139 >> # setup toolchain variables used by configure
140 >> tc-export CC CXX RANLIB STRIP
141 >> export LD="$(tc-getCXX)"
142 >>
143 >> # configure arguments
144 >> local conf=(
145 >> # installation paths
146 >> -prefix "${QT5_PREFIX}"
147 >> -bindir "${QT5_BINDIR}"
148 >> -headerdir "${QT5_HEADERDIR}"
149 >> -libdir "${QT5_LIBDIR}"
150 >> -archdatadir "${QT5_ARCHDATADIR}"
151 >> -plugindir "${QT5_PLUGINDIR}"
152 >> -libexecdir "${QT5_LIBEXECDIR}"
153 >> -importdir "${QT5_IMPORTDIR}"
154 >> -qmldir "${QT5_QMLDIR}"
155 >> -datadir "${QT5_DATADIR}"
156 >> -docdir "${QT5_DOCDIR}"
157 >> -translationdir "${QT5_TRANSLATIONDIR}"
158 >> -sysconfdir "${QT5_SYSCONFDIR}"
159 >> -examplesdir "${QT5_EXAMPLESDIR}"
160 >> -testsdir "${QT5_TESTSDIR}"
161 >>
162 >> # debug/release
163 >> $(use debug && echo -debug || echo -release)
164 >> -no-separate-debug-info
165 >>
166 >> # licensing stuff
167 >> -opensource -confirm-license
168 >>
169 >> # let configure automatically figure out if C++11 is supported
170 >> #-c++11
171 >
172 > Doesn't switching C++11 support involve changing ABI? I suspect Qt may
173 > be actually free of that.
174
175 No, the ABI doesn't change. I asked upstream some time ago.
176
177 >
178 >> # build shared libraries
179 >> -shared
180 >>
181 >> # always enable large file support
182 >> -largefile
183 >>
184 >> # disabling accessibility is not recommended by upstream, as
185 >> # it will break QStyle and may break other internal parts of Qt
186 >> -accessibility
187 >>
188 >> # disable all SQL drivers by default, override in qtsql
189 >> -no-sql-db2 -no-sql-ibase -no-sql-mysql -no-sql-oci -no-sql-odbc
190 >> -no-sql-psql -no-sql-sqlite -no-sql-sqlite2 -no-sql-tds
191 >>
192 >> # obsolete flag, does nothing
193 >> #-qml-debug
194 >>
195 >> # use pkg-config to detect include and library paths
196 >> -pkg-config
197 >>
198 >> # prefer system libraries (only common deps here)
199 >> -system-zlib
200 >> -system-pcre
201 >>
202 >> # don't specify -no-gif because there is no way to override it later
203 >> #-no-gif
204 >>
205 >> # disable everything to prevent automagic deps (part 1)
206 >> -no-mtdev
207 >> -no-journald
208 >> -no-libpng -no-libjpeg
209 >> -no-freetype -no-harfbuzz
210 >> -no-openssl
211 >> -no-xinput2 -no-xcb-xlib
212 >>
213 >> # always enable glib event loop support
214 >> -glib
215 >>
216 >> # disable everything to prevent automagic deps (part 2)
217 >> -no-pulseaudio -no-alsa
218 >>
219 >> # disable gtkstyle because it adds qt4 include paths to the compiler
220 >> # command line if x11-libs/cairo is built with USE=qt4 (bug 433826)
221 >> -no-gtkstyle
222 >>
223 >> # exclude examples and tests from default build
224 >> -nomake examples
225 >> -nomake tests
226 >> -no-compile-examples
227 >>
228 >> # disable rpath on non-prefix (bugs 380415 and 417169)
229 >> $(use prefix || echo -no-rpath)
230 >>
231 >> # print verbose information about each configure test
232 >> -verbose
233 >>
234 >> # doesn't actually matter since we override CXXFLAGS
235 >> #-no-optimized-qmake
236 >>
237 >> # obsolete flag, does nothing
238 >> #-nis
239 >>
240 >> # always enable iconv support
241 >> -iconv
242 >>
243 >> # disable everything to prevent automagic deps (part 3)
244 >> -no-cups -no-evdev -no-icu -no-fontconfig -no-dbus
245 >>
246 >> # don't strip
247 >> -no-strip
248 >>
249 >> # precompiled headers are not that useful for us
250 >> # and cause problems on hardened, so turn them off
251 >> -no-pch
252 >>
253 >> # reduced relocations cause major breakage on at least arm and ppc, so we
254 >> # don't specify anything and let configure figure out if they are supported,
255 >> # see also https://bugreports.qt-project.org/browse/QTBUG-36129
256 >> #-reduce-relocations
257 >>
258 >> # let configure automatically detect if GNU gold is available
259 >> #-use-gold-linker
260 >>
261 >> # disable all platform plugins by default, override in qtgui
262 >> -no-xcb -no-eglfs -no-directfb -no-linuxfb -no-kms
263 >>
264 >> # disable undocumented X11-related flags, override in qtgui
265 >> # (not shown in ./configure -help output)
266 >> -no-xkb -no-xrender
267 >>
268 >> # disable obsolete/unused X11-related flags
269 >> # (not shown in ./configure -help output)
270 >> -no-mitshm -no-xcursor -no-xfixes -no-xinerama -no-xinput
271 >> -no-xrandr -no-xshape -no-xsync -no-xvideo
272 >>
273 >> # always enable session management support: it doesn't need extra deps
274 >> # at configure time and turning it off is dangerous, see bug 518262
275 >> -sm
276 >>
277 >> # typedef qreal to double (warning: changing this flag breaks the ABI)
278 >> -qreal double
279 >>
280 >> # disable opengl and egl by default, override in qtgui and qtopengl
281 >> -no-opengl -no-egl
282 >>
283 >> # use upstream default
284 >> #-no-system-proxies
285 >>
286 >> # do not build with -Werror
287 >> -no-warnings-are-errors
288 >>
289 >> # module-specific options
290 >> "${myconf[@]}"
291 >> )
292 >>
293 >> mkdir -p "${QT5_BUILD_DIR}" || die
294 >> pushd "${QT5_BUILD_DIR}" >/dev/null || die
295 >>
296 >> einfo "Configuring with: ${conf[@]}"
297 >> "${S}"/configure "${conf[@]}" || die "configure failed"
298 >>
299 >> popd >/dev/null || die
300 >> }
301 >
302 > --
303 > Best regards,
304 > Michał Górny