--- /usr/portage/eclass/qt4.eclass 2008-09-21 03:35:55.000000000 +0200 +++ qt4.eclass 2008-10-27 22:45:23.000000000 +0100 @@ -226,39 +226,86 @@ # Davide Pesavento # @DESCRIPTION: # Runs qmake on the specified .pro file (defaults to -# ${PN}.pro if eqmake4 was called with no argument). -# Additional parameters are passed unmodified to qmake. +# ${PN}.pro if eqmake4 was called without arguments). +# Additional parameters are appended unmodified to +# qmake command line. eqmake4() { - local LOGFILE="${T}/qmake-$$.out" - local projprofile="${1}" - [[ -z ${projprofile} ]] && projprofile="${PN}.pro" - shift 1 - - ebegin "Processing qmake ${projprofile}" - - # file exists? - if [[ ! -f ${projprofile} ]]; then - echo - eerror "Project .pro file \"${projprofile}\" does not exists" - eerror "qmake cannot handle non-existing .pro files" - echo - eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org" + local logfile="${T}"/eqmake4-$$.log + local projectfile="${1:-${PN}.pro}" + local outputfile="$(dirname "${projectfile}")"/Makefile + shift + + if [[ ! -f ${projectfile} ]]; then + echo + eerror "Project file '${projectfile}' does not exists!" + eerror "eqmake4 cannot handle non-existing project files." + eerror + eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" echo - die "Project file not found in ${PN} sources" + die "Project file not found in ${CATEGORY}/${PN} sources." fi - echo >> ${LOGFILE} - echo "****** qmake ${projprofile} ******" >> ${LOGFILE} - echo >> ${LOGFILE} - - # as a workaround for broken qmake, put everything into file + # examine arguments to detect if a different + # output file was specified by the -o option + local arg= i= + for ((i=$#; i > 0; i--)); do + eval arg=\$$i + if [[ "${arg}" = "-o" ]]; then + eval outputfile=\$$(expr ${i} + 1) + break + fi + done + + ebegin "Running qmake on ${projectfile}" + + echo >> "${logfile}" + echo "****** qmake ${projectfile} ******" >> "${logfile}" + echo >> "${logfile}" + + # make sure CONFIG variable is correctly set for both release and debug builds + local CONFIG_ADD="release" + local CONFIG_REMOVE="debug" if has debug ${IUSE} && use debug; then - echo -e "\nCONFIG -= release\nCONFIG += no_fixpath debug" >> ${projprofile} - else - echo -e "\nCONFIG -= debug\nCONFIG += no_fixpath release" >> ${projprofile} + CONFIG_ADD="debug" + CONFIG_REMOVE="release" fi + local awkscript='BEGIN { + fixed=0; + } + /^[[:blank:]]*CONFIG[[:blank:]]*[\+\*]?=/ { + for (i=1; i <= NF; i++) { + if ($i ~ rem || $i ~ /debug_and_release/) + { $i=add; fixed=1; } + } + } + /^[[:blank:]]*CONFIG[[:blank:]]*-=/ { + for (i=1; i <= NF; i++) { + if ($i ~ add) { $i=rem; fixed=1; } + } + } + { + print >> file; + } + END { + printf "CONFIG -= debug_and_release %s\n", rem >> file; + printf "CONFIG += %s\n", add >> file; + print fixed; + }' + local file= + while read file; do + local retval=$({ + rm -f "${file}" + awk -- "${awkscript}" file="${file}" add=${CONFIG_ADD} rem=${CONFIG_REMOVE} \ + || die "awk failed to process '${file}'." + } < "${file}") + if [[ ${retval} -eq 1 ]]; then + einfo " Fixed CONFIG in ${file}" + elif [[ ${retval} -ne 0 ]]; then + ewarn " An error occurred while processing ${file}: awk script returned ${retval}" + fi + done < <(find "$(dirname "${projectfile}")" -type f -name "*.pr[io]" -printf '%P\n' 2>/dev/null) - /usr/bin/qmake ${projprofile} \ + /usr/bin/qmake -makefile -nocache \ QTDIR=/usr/$(get_libdir) \ QMAKE=/usr/bin/qmake \ QMAKE_CC=$(tc-getCC) \ @@ -271,22 +318,26 @@ QMAKE_LFLAGS_RELEASE="${LDFLAGS}" \ QMAKE_LFLAGS_DEBUG="${LDFLAGS}" \ QMAKE_RPATH= \ - "${@}" >> ${LOGFILE} 2>&1 + "${projectfile}" \ + "${@}" >> "${logfile}" 2>&1 - local result=$? - eend ${result} + eend $? # was qmake successful? - if [[ ${result} -ne 0 ]]; then - echo - eerror "Running qmake on \"${projprofile}\" has failed" + if [[ $? -ne 0 ]]; then echo - eerror "This shouldn't happen - please send a bug report to bugs.gentoo.org" + eerror "Running qmake on '${projectfile}' has failed!" + eerror + eerror "This shouldn't happen - please send a bug report to http://bugs.gentoo.org/" + eerror "A complete log of qmake output is located at '${logfile}'." echo - die "qmake failed on ${projprofile}" + die "qmake failed on '${projectfile}'." fi - return ${result} + # remove stripping from generated Makefile (bug #221745) + sed -i -e '/strip /d' "${outputfile}" || ewarn "sed failed to remove stripping from ${outputfile}" + + return 0 } EXPORT_FUNCTIONS pkg_setup