Ticket #49595: patch-kde4-incdir.diff

File patch-kde4-incdir.diff, 11.8 KB (added by RJVB (René Bertin), 5 years ago)
  • kde4-1.1.tcl

    old new  
    11# -*- coding: utf-8; mode: tcl; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4; truncate-lines: t -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
    2 # $Id: kde4-1.1.tcl 142093 2015-11-03 12:20:58Z nicos@macports.org $
     2# $Id: kde4-1.1.tcl 133799 2015-03-11 19:45:29Z mk@macports.org $
    33
    44# Copyright (c) 2010-2014 The MacPorts Project
    55# All rights reserved.
     
    3434# PortGroup     kde4 1.1
    3535
    3636# Use CMake and Qt4 port groups
    37 PortGroup               cmake 1.0
     37PortGroup               cmake 1.1
    3838PortGroup               qt4 1.0
    3939
     40namespace eval kde4 {
     41    # our directory:
     42    variable currentportgroupdir [file dirname [dict get [info frame 0] file]]
     43}
     44
    4045# Make sure to not use any already installed headers and libraries;
    4146# these are set in CPATH and LIBRARY_PATH anyway.
    4247configure.ldflags-delete  -L${prefix}/lib
     
    6065# set compiler to Apple's GCC 4.2
    6166switch ${os.platform}_${os.major} {
    6267    darwin_8 {
    63             configure.compiler  apple-gcc-4.2
     68        configure.compiler  apple-gcc-4.2
    6469    }
    6570    darwin_9 {
    66             configure.compiler  gcc-4.2
     71        configure.compiler  gcc-4.2
     72    }
     73}
     74
     75configure.args-delete   -DCMAKE_BUILD_TYPE=Release
     76# force cmake to use the compiler flags passed through CFLAGS, CXXFLAGS etc. in the environment
     77configure.args-append   -DCMAKE_BUILD_TYPE:STRING=MacPorts \
     78                        -DCMAKE_STRIP:FILEPATH=/bin/echo \
     79                        -DCMAKE_USE_RELATIVE_PATHS:BOOL=ON
     80
     81# Install the kdelibs headerfiles in their own directory to prevent clashes with KF5 headers
     82set kde4.include_prefix KDE4
     83set kde4.include_dirs   ${prefix}/include/${kde4.include_prefix}
     84set kde4.legacy_prefix  ${prefix}/libexec/kde4-legacy
     85set kde4.cmake_module_dir \
     86                        ${prefix}/lib/cmake/${kde4.include_prefix}
     87
     88# Certain ports will need to be installed in "KF5 compatibility mode" if they are to co-exist
     89# with their KF5 counterparts. Call `kde4.use_legacy_prefix` to activate this mode, *before*
     90# the configure step is executed and taking care not to undo the effects.
     91# If a legacy prefix is used, the global variable kde4.legacy_prefix_restored will be defined
     92# and set to 'no'; it is set to 'yes' by kde4.restore_from_legacy_prefix .
     93# An optional boolean argument deactivates the automatic calling of kde4.restore_from_legacy_prefix .
     94proc kde4.use_legacy_prefix {{autorestore 1}} {
     95    upvar #0 kde4.legacy_prefix_restored restored
     96    upvar #0 kde4.legacy_prefix_autorestore dorestore
     97    global prefix
     98    global kde4.legacy_prefix
     99    global kde4.include_dirs
     100    configure.pre_args-replace \
     101                    -DCMAKE_INSTALL_PREFIX=${prefix} -DCMAKE_INSTALL_PREFIX=${kde4.legacy_prefix}
     102    configure.args-replace \
     103                    -DCMAKE_INSTALL_RPATH=${prefix}/lib -DCMAKE_INSTALL_RPATH="${prefix}/lib\;${kde4.legacy_prefix}/lib"
     104    # changing the install prefix will override the KDE4_INCLUDE_INSTALL_DIR path normally set
     105    # to ${kde4.include_dirs} by kdelibs4's cmake modules. Make sure to override it back to that setting.
     106    configure.args-append \
     107                    -DINCLUDE_INSTALL_DIR=${kde4.include_dirs}
     108    set restored no
     109    if {(${autorestore} eq 1) || (${autorestore} eq yes)} {
     110        set dorestore yes
     111    } else {
     112        set dorestore no
     113    }
     114}
     115
     116# kde4.restore_from_legacy_prefix is called from the post-destroot phase of a port that uses
     117# KF5 compatibility mode. That mode is very indiscriminate, installing everything into the
     118# legacy_prefix initially. Most things will actually have to be moved back out into the
     119# regular prefix. This procedure automates what can be automated, but may also overshoot
     120# its goal.
     121# See the post-destroot block at the end of this file.
     122# After completion, the global variable kde4.legacy_prefix_restored will be set to 'yes'.
     123# This procedure is called automatically after calling kde4.use_legacy_prefix ; it can be
     124# avoided by calling `kde4.use_legacy_prefix no`
     125# This procedure is bound to evolve.
     126proc kde4.restore_from_legacy_prefix {} {
     127    global destroot
     128    global prefix
     129    global kde4.legacy_prefix
     130    global kde4.cmake_module_dir
     131    upvar #0 kde4.legacy_prefix_restored restored
     132    if {[info exists restored] && (${restored} eq yes)} {
     133        ui_debug "kde4.restore_from_legacy_prefix already called"
     134        return
     135    }
     136    if {[file exists ${destroot}${kde4.legacy_prefix}/lib/kde4]} {
     137        # move back the kparts, libexec etc. to where they should be
     138        file rename ${destroot}${kde4.legacy_prefix}/lib/kde4 ${destroot}${prefix}/lib/kde4
     139    }
     140    if {[file exists ${destroot}${kde4.legacy_prefix}/include]} {
     141        ui_msg "WARNING: include directory \"${destroot}${kde4.legacy_prefix}/include\" exists!"
     142#         # move back the include directory to where it should be;
     143#         # first delete the include directory that was created for us and should be empty:
     144#         file delete -force ${destroot}${prefix}/include
     145#         file rename ${destroot}${kde4.legacy_prefix}/include ${destroot}${prefix}/include
     146    }
     147    if {[file exists ${destroot}${kde4.legacy_prefix}/share]} {
     148        # move back the share directory to where it should be;
     149        foreach J [glob -nocomplain ${destroot}${kde4.legacy_prefix}/share/*] {
     150            set d [file tail ${J}]
     151            file rename ${J} ${destroot}${prefix}/share/${d}
     152        }
     153    }
     154    if {[file exists ${destroot}${kde4.legacy_prefix}/lib/cmake]} {
     155        # move back the cmake modules to where they should be
     156#         file rename ${destroot}${kde4.legacy_prefix}/lib/cmake ${destroot}${prefix}/lib/cmake
     157        xinstall -m 755 -d [file dirname ${destroot}${kde4.cmake_module_dir}]
     158        file rename ${destroot}${kde4.legacy_prefix}/lib/cmake ${destroot}${kde4.cmake_module_dir}
    67159    }
     160    # check if the "share" symlink is present: it's installed by port:kdelibs4 (which itself doesn't
     161    # have need for a kf5compat variant or the legacy_prefix).
     162    if {![file exists ${kde4.legacy_prefix}/share]} {
     163        ui_msg "WARNING: the installed port:kdelibs4 does not provide ${kde4.legacy_prefix}/share!"
     164        notes-append "WARNING: the installed port:kdelibs4 does not provide ${kde4.legacy_prefix}/share!"
     165    }
     166    set restored yes
    68167}
    69168
    70169# augment the CMake module lookup path, if necessary depending on
    71170# where Qt4 is installed.
    72171if {${qt_cmake_module_dir} ne ${cmake_share_module_dir}} {
    73     set cmake_module_path ${cmake_share_module_dir}\;${qt_cmake_module_dir}
    74     configure.args-delete -DCMAKE_MODULE_PATH=${cmake_share_module_dir}
    75     configure.args-append -DCMAKE_MODULE_PATH="${cmake_module_path}"
    76     unset cmake_module_path
     172    ui_debug "set cmake_module_path kde4.cmake_module_dir\;cmake_share_module_dir\;qt_cmake_module_dir"
     173    set cmake_module_path ${kde4.cmake_module_dir}\;${cmake_share_module_dir}\;${qt_cmake_module_dir}
     174} else {
     175    # prepend our own (new) install location for cmake modules:
     176    ui_debug "set cmake_module_path kde4.cmake_module_dir\;cmake_share_module_dir"
     177    set cmake_module_path ${kde4.cmake_module_dir}\;${cmake_share_module_dir}
    77178}
     179ui_debug "cmake_module_path=${cmake_module_path}"
     180configure.args-delete -DCMAKE_MODULE_PATH=${cmake_share_module_dir}
     181configure.args-append -DCMAKE_MODULE_PATH="${cmake_module_path}" \
     182                        -DCMAKE_PREFIX_PATH="${cmake_module_path}"
    78183
    79184# standard configure args; virtually all KDE ports use CMake and Qt4.
    80185configure.args-append   -DBUILD_doc=OFF \
     
    86191
    87192# explicitly define certain headers and libraries, to avoid
    88193# conflicts with those installed into system paths by the user.
     194# 20151015 RJVB : these are handled in FindMySQL.cmake :
     195#                         -DMYSQL_INCLUDE_DIR=${prefix}/include/mysql5/mysql \
     196#                         -DMYSQL_LIB_DIR=${prefix}/lib/mysql5/mysql \
     197# 20151015 RJVB : these are best left to port select ...
     198#                         -DMYSQLCONFIG_EXECUTABLE=${prefix}/bin/mysql_config5 \
     199#                         -DMYSQLD_EXECUTABLE=${prefix}/libexec/mysqld \
     200
    89201configure.args-append   -DDOCBOOKXSL_DIR=${prefix}/share/xsl/docbook-xsl \
    90202                        -DGETTEXT_INCLUDE_DIR=${prefix}/include \
    91203                        -DGETTEXT_LIBRARY=${prefix}/lib/libgettextlib.dylib \
     
    121233# These two can be removed (see #46240):
    122234#                        -DQCA2_INCLUDE_DIR=${prefix}/include/QtCrypto \
    123235#                        -DQCA2_LIBRARIES=${prefix}/lib/libqca.dylib \
    124 # These ones are obsolete, as purely based on mysql5 paths (see #49296):
    125 #                        -DMYSQLD_EXECUTABLE=${prefix}/libexec/mysqld \
    126 #                        -DMYSQL_INCLUDE_DIR=${prefix}/include/mysql5/mysql \
    127 #                        -DMYSQL_LIB_DIR=${prefix}/lib/mysql5/mysql \
    128 #                        -DMYSQLCONFIG_EXECUTABLE=${prefix}/bin/mysql_config5 \
    129236
    130237# standard variant for building documentation
    131238variant docs description "Build documentation" {
     
    133240    configure.args-delete   -DBUILD_doc=OFF -DBUILD_docs=OFF
    134241}
    135242
    136 notes "
     243if {[info exist ::env(MACPORTS_COMPRESS_WORKDIR)] && $::env(MACPORTS_COMPRESS_WORKDIR)} {
     244    post-build {
     245        if {[file exists ${prefix}/bin/afsctool]} {
     246            ui_msg "--->  Compressing build directory ..."
     247            if {[catch {system "${prefix}/bin/afsctool -cfvv -8 -J${build.jobs} ${build.dir} 2>&1"} result context]} {
     248                ui_msg "Compression failed: ${result}, ${context}; port:afsctool is probably installed without support for parallel compression"
     249            } else {
     250                ui_debug "Compressing ${build.dir}: ${result}"
     251            }
     252        }
     253    }
     254}
     255
     256post-destroot {
     257    if {[info exists kde4.legacy_prefix_autorestore]} {
     258        # check if we need to do automatic restoring (the default). We do that here because this post-destroot
     259        # block should be the first such block. In other words, the calling Portfile should not yet have had
     260        # a chance to modify the destroot in ways that kde4.restore_from_legacy_prefix might overwrite.
     261        # kde4.restore_from_legacy_prefix checks itself if it already completed once.
     262        if {(${kde4.legacy_prefix_autorestore} eq yes) || (${kde4.legacy_prefix_autorestore} eq 1)} {
     263            ui_debug "doing requested auto kde4.restore_from_legacy_prefix (${kde4.legacy_prefix_autorestore})"
     264            kde4.restore_from_legacy_prefix
     265        }
     266    }
     267    if {![info exists kde4.legacy_prefix_restored] || ${kde4.legacy_prefix_restored} eq no} {
     268        # move the port's cmake modules to ${kde4.cmake_module_dir}. This is an operation that might
     269        # be overwritten if the Portfile calls kde4.restore_from_legacy_prefix afterwards, hence the
     270        # call to that function just above.
     271        if {[file exists ${destroot}${prefix}/lib/cmake]} {
     272            # avoid a loop construct here (and a direct rename may not work, e.g. lib/cmake -> lib/cmake/KDE4 won't)
     273            # move the directory out of the way
     274            file rename ${destroot}${prefix}/lib/cmake ${destroot}/cmake_temp_dir
     275            # create the parent for ${kde4.cmake_module_dir}
     276            xinstall -m 755 -d [file dirname ${destroot}${kde4.cmake_module_dir}]
     277            # move the temp dir into place
     278            file rename ${destroot}/cmake_temp_dir ${destroot}${kde4.cmake_module_dir}
     279        }
     280    }
     281}
     282
     283post-activate {
     284    if {[file exists ${prefix}/bin/kbuildsycoca4]} {
     285        ui_msg "--->  Updating KDE's global desktop file system configuration cache ..."
     286        system "${prefix}/bin/kbuildsycoca4 --global"
     287    }
     288}
     289
     290notes-append "
    137291Don't forget that dbus needs to be started as the local\
    138292user (not with sudo) before any KDE programs will launch.
    139293To start it run the following command: