# -*- 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 # $Id: Portfile 73102 2010-11-04 01:17:13Z michaelld@macports.org $ PortSystem 1.0 # use the qt4 group; set 'building_qt4' so that the portgroup # does not include certain parts set building_qt4 1 PortGroup qt4 1.0 name qt4-mac conflicts qt4-mac-devel version 4.7.0 revision 1 categories aqua platforms macosx maintainers michaelld homepage http://qt.nokia.com/ description Qt Tool Kit long_description Qt Tool Kit: A cross-platform framework \ (headers, data, and libraries) for writing \ cross-platform GUI-based applications. master_sites trolltech distname qt-everywhere-opensource-src-${version} checksums md5 3a2f25b9b115037277f4fb759194a7a5 \ sha1 a5796c8f468c8f59249e5c696f913864c979f411 \ rmd160 3e9c0f0d9843b5c03ad4bd6193aff98531ee0746 depends_lib-append port:zlib port:dbus port:openssl port:sqlite3 \ port:tiff port:libpng port:libmng port:jpeg archcheck.files lib/libz.dylib lib/libdbus-1.dylib \ lib/libssl.dylib lib/libsqlite3.dylib \ lib/libtiff.dylib lib/libpng.dylib \ lib/libmng.dylib lib/libjpeg.dylib # (0) Fix the testing script to properly handle both +universal as # well as the native arch for both CXX and CC compiling; also make # sure it does not create a Mac app bundle. patchfiles-append patch-config.tests_unix_compile.test.diff # (1) Test for Precompiled-headers support requires a C++ compiler, # but configure calls it, by default, with a C compiler. patchfiles-append patch-precomp.test.diff # (2) Tweak various scripts to allow easy replacement of # MACOSX_DEPLOYMENT_TARGET: build for just the user's current OS. patchfiles-append patch-macosx-deployment-target.diff # (3) Tweak the configure script to allow easy replacement of arch # type(s). The location of this patch is dependent on patch (2), but # 'patch' should be able to figure it out. patchfiles-append patch-configure-arch.diff # (4) Tweak Qt spec files: # (4a) Place the -I path for local moc-created headers -before- # all other -I paths. patchfiles-append patch-mkspecs-features-moc.prf.diff # (4b) Remove Qt's LIBDIR and INCDIR from various Qmake internal # variables, since they are already included in the user-supplied # LIBS and INCLUDEPATH. patchfiles-append patch-mkspecs-features-qt.prf.diff # (4c) Change placement of Qt's LIBDIR and INCDIR, to always be after # those supplied by the user's QMake (.pro) files. By the time QMake # gets to the patched function, it is creating the Makefile parts to # find Qt's headers and libraries, so moving these paths to this # location should always work. patchfiles-append patch-mkspecs-features-qt_functions.prf.diff # (4d) Add "absolute_library_soname" to the default CONFIG variables, # so that when a DYLIB is created, if "target.path" is set for it then # that path is prepended to its "install_name". patchfiles-append patch-mkspecs-macx-g++-qmake.prf.diff # (4e) allow use of 'ccache' via "qmake && make CCACHE=ccache", in mac # only; this patch requires that (2) already be in place. patchfiles-append patch-mkspecs_common_mac.conf.diff post-patch { # set ARCHES in configure (per the third patchfile above), for # building QMake. join any 2 or more arch entries with the GCC # arch flag (join does not effect a single entry). first "-arch" # is already in place in the 'configure' script (since there has # to be at least 1 arch). set ARCHES "" if {[variant_exists universal] && [variant_isset universal]} { set ARCHES [join ${universal_archs} " -arch "] } else { set ARCHES ${build_arch} } reinplace "s|@ARCHES@|${ARCHES}|g" ${worksrcpath}/configure # set MACOSX_DEPLOYMENT_TARGET version in various places. These # were all patched in (2) above, and can be easily changed or # overridden by the user in a project-local qmake .pro script. set minor [expr [lindex [split ${os.version} "."] 0] - 4] set MACOSX_DEPLOYMENT_TARGET "10.${minor}" foreach fixfile {configure mkspecs/common/mac-g++.conf \ mkspecs/common/mac.conf qmake/qmake.pri \ src/tools/bootstrap/bootstrap.pro } { reinplace "s|@MACOSX_DEPLOYMENT_TARGET@|${MACOSX_DEPLOYMENT_TARGET}|g" \ ${worksrcpath}/${fixfile} } # Ensure that correct C/C++ compilers are used. reinplace "s| g++\$| ${configure.cxx}|" \ ${worksrcpath}/mkspecs/common/g++.conf reinplace "s| gcc\$| ${configure.cc}|" \ ${worksrcpath}/mkspecs/common/g++.conf reinplace "s| g++\$| ${configure.cxx}|" \ ${worksrcpath}/mkspecs/macx-g++/qmake.conf reinplace "s| gcc\$| ${configure.cc}|" \ ${worksrcpath}/mkspecs/macx-g++/qmake.conf # fix up tests to work with ccache, if used foreach fixfile [exec find ${worksrcpath}/config.tests \ -name "*.test"] { reinplace "s@\\\"\\\$COMPILER\\\"@\$COMPILER@g" ${fixfile} } # fix 'configure' script to find the correct QMAKE CXX compiler by # removing possibilities that include the character "$". Yes, # that's a lot of "\"s: each "\\\\" -> a single "\" in the patched # file, and need "\\\\$" (with the "s) there. reinplace "/QMAKE_CONF_COMPILER/ \ s@tail@grep -v \"\\\\\\\\\\\\\\\\\$\" | tail@" \ ${worksrcpath}/configure } # The build process uses -fconstant-cfstrings. # configure.compiler should therefore not be one of the MacPorts compilers. # --prefix is not recognized. configure.pre_args-delete --prefix=${prefix} # --disable-dependency-tracking is not recognized. configure.universal_args-delete --disable-dependency-tracking ################################################################################ # We do not want flags of any kind -- QT is smart enough to set up its own. # ################################################################################ configure.cflags configure.cppflags configure.cxxflags configure.ldflags configure.universal_cflags configure.universal_cppflags configure.universal_cxxflags configure.universal_ldflags configure.cc_archflags configure.cxx_archflags if {[info exists configure.ld_archflags]} { configure.ld_archflags } # use compiler.cpath and compiler.library_path, as per # http://trac.macports.org/ticket/25321 for all -I and -L entries, # so-as to avoid conflicts with already-installed headers and # libraries (giving preference to internal-to-this-port first) # # CPATH is used instead of -I to avoid conflicts with other ports. # See http://trac.macports.org/ticket/15219 and # http://trac.macports.org/ticket/18723. # # set the default paths to include those for SQLITE3 and DBUS-1 set header_path [ list ${prefix}/include/dbus-1.0 \ ${prefix}/lib/dbus-1.0/include \ ${prefix}/include ] set library_path [ list ${prefix}/lib ] # -system-sqlite ensures the use SQLite provided by MacPorts instead of Qt. # # -dbus-linked prevends qt4 from trying to dynamically load libdbus-1, # which it is not able to find in ${prefix}. # # -openssl-linked ensures that the MacPorts openssl is used. # # -no-framework ensures that this port is installed as separate # libraries and headers, with guaranteed locations and names that # can be used for archcheck. # # -no-phonon ensures that Qt does not install the 3rd-parth Phonon # port or its backend to QuickTime 7; Phonon is now installed via # the 'phonon' port, which is more up to date than that provided # by Qt. configure.args \ -v \ -confirm-license \ -opensource \ -prefix ${qt_dir} \ -bindir ${qt_bins_dir} \ -libdir ${qt_libs_dir} \ -docdir ${qt_docs_dir} \ -headerdir ${qt_includes_dir} \ -plugindir ${qt_plugins_dir} \ -importdir ${qt_imports_dir} \ -datadir ${qt_data_dir} \ -translationdir ${qt_translations_dir} \ -sysconfdir ${qt_sysconf_dir} \ -examplesdir ${qt_examples_dir} \ -demosdir ${qt_demos_dir} \ -system-sqlite \ -openssl-linked \ -dbus-linked \ -fast \ -optimized-qmake \ -no-framework \ -no-phonon \ -no-phonon-backend # Stop configure script from searching for SQL Drivers # not available from MacPorts. foreach driver {db2 ibase oci tds} { configure.args-append -no-sql-${driver} } # By default, disable most SQL Drivers. # There must be at least one enabled (http://trac.macports.org/ticket/15627). # SQLite is chosen to be always enabled because a copy of it is distributed # with Qt, so it is reasonable for the user to expect it. foreach driver {mysql odbc psql sqlite2} { configure.args-append -no-sql-${driver} } pre-configure { # use the corrected CPATH and LIBRARY_PATH for build compiler.cpath [join ${header_path} :] compiler.library_path [join ${library_path} :] } platform darwin 8 { # build as Carbon only, not cocoa. configure.args-append -carbon configure.ldflags-append -lcrypto -ldbus-1 -ljpeg -llcms -lsqlite3 -lssl -lz post-configure { fs-traverse item ${worksrcpath} { if {"Makefile" == [file tail ${item}]} { reinplace "s|-framework QtHelp|-framework QtHelp -lQtCLucene|" ${item} } } } } platform darwin { pre-configure { # retrieve the arch type(s) to use, in Qt-speak configure.args-append -arch \"${qt_arch_types}\" # cannot use pre-compiled headers when compiling with more than 1 # arch type (typically +universal) or for X11 if {[llength ${qt_arch_types}] != 1 || [variant_isset x11]} { configure.args-append -no-pch } else { configure.args-append -pch } # check to see if not compiling for the native machine hardware # (e.g., compiling for just i386 but CPU is x86_64); optimization # of QMake does not work in this circumstance. if {[lsearch -exact ${qt_arch_types} ${os.arch}] == -1} { # not building for native arch: disable optimizing qmake configure.args-delete -optimized-qmake } # find a way to specify the SDK to use set SDK "" if {[variant_exists universal] && [variant_isset universal]} { if {[info exists universal_sysroot]} { set SDK ${universal_sysroot} } } if {${SDK} == ""} { # else use the one for this OS version, if installed set minor [expr [lindex [split ${os.version} "."] 0] - 4] # set SDK version depending on OS version set sdk_version "" if {${minor} == "4"} { # OSX 10.4 requires an additional 'u' set sdk_version "10.4u" } else { set sdk_version "10.${minor}" } set SDK ${developer_dir}/SDKs/MacOSX${sdk_version}.sdk } if {[file exists ${SDK}]} { configure.args-append -sdk ${SDK} } else { ui_msg \ "No SDK found in ${developer_dir}/SDKs for ${sdk_version} ; \ configure will probably fail. \n \ Please install Apple's Developer Tools again." } } } platform darwin 10 i386 { # optimization of QMake does not work on 10.6 32-bit native configure.args-delete -optimized-qmake } # Remove any '-I' string from the C*FLAGS for SQLITE and DBUS, so that # what remains are just non-I flags; these paths are in compiler.cpath . # The includes for all the other variants are not used by # 'configure', and are already included in the compiler.cpath . post-configure { # SQLITE reinplace "/CFLAGS_SQLITE/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \ ${worksrcpath}/.qmake.cache # DBUS reinplace "/CFLAGS_DBUS/s@-I${prefix}/\[^ \]*include\[^ \]*@@g" \ ${worksrcpath}/.qmake.cache # during the 'build' stage, 'make' will rebuild the Makefiles that # depend on any of these changed files. } pre-build { # use the corrected CPATH and LIBRARY_PATH for build compiler.cpath [join ${header_path} :] compiler.library_path [join ${library_path} :] } build.target first post-destroot { set destroot_qt ${destroot}${qt_dir} # Fix .pc and .prl files by changing ${worksrcpath}\${prefix} to # ${qt_dir}\${prefix} ("\" means 'take away'). Cannot use # "find -E" since it is not necessarily portable. regsub ${prefix} ${worksrcpath} "" from_dir regsub ${prefix} ${qt_dir} "" to_dir foreach fixfile [exec find ${destroot_qt} -name "*.pc"] { reinplace "s|${from_dir}|${to_dir}|g" ${fixfile} } foreach fixfile [exec find ${destroot_qt} -name "*.prl"] { reinplace "s|${from_dir}|${to_dir}|g" ${fixfile} } # Install documentation. xinstall -m 755 -d ${worksrcpath}/${qt_docs_dir} xinstall -m 644 -W ${worksrcpath} \ INSTALL LGPL_EXCEPTION.txt LICENSE.FDL \ LICENSE.GPL3 LICENSE.LGPL README \ ${destroot}${qt_docs_dir} # Fix includes: Remove include/Qt. # It should never be used in Qt4 or newer. # It is there for legacy purposes: it's how # Qt3's headers were installed. if {[file exists ${destroot}/${qt_includes_dir}/Qt]} { delete ${destroot}/${qt_includes_dir}/Qt } # Move .apps into the applications_dir xinstall -m 755 -d ${destroot}${qt_apps_dir} foreach app [glob ${destroot}/${qt_bins_dir}/*.app] { move ${app} ${destroot}${qt_apps_dir} } # Install cmake files (taken from port 'kdelibs4'). To use this # file, include '-DCMAKE_MODULE_PATH=...' in configure.args during # the initial 'configure' stage (which uses CMake), to the full # path of where the CMake files are installed. xinstall -m 755 -d ${destroot}${qt_cmake_module_dir} xinstall -m 644 -W ${filespath} \ FindQt4.cmake Qt4ConfigDependentSettings.cmake \ Qt4Macros.cmake MacroPushRequiredVars.cmake \ ${destroot}${qt_cmake_module_dir} # install qt_menu.nib, used by any applications making use of Qt's # application class. xinstall -m 755 -d ${destroot_qt}/lib/Resources copy ${worksrcpath}/src/gui/mac/qt_menu.nib \ ${destroot_qt}/lib/Resources # Fix import and plugin library ID (self name) foreach fixfile [exec find ${destroot_qt}/share/${qt_name} \ -name "*.dylib" -type f | \ sed -e "s@${destroot}@@g" ] { system "install_name_tool -id ${fixfile} ${destroot}${fixfile}" } } pre-activate { # make sure 'none' is selected by qt4_select, so that there is no # conflict between it and this port. if {[file exists ${prefix}/bin/qt4_select]} { if {[exec ${prefix}/bin/qt4_select -s] != "none"} { ui_msg "Disabling 'qt4_select' selection." system "exec ${prefix}/bin/qt4_select none" } } } # make sure the universal variant exists variant universal {} variant mysql description {Enable MySQL SQL Driver} { depends_lib-append path:lib/mysql5:mysql5 archcheck.files-append lib/mysql5/mysql/libmysqlclient.dylib lunshift header_path ${prefix}/include/mysql5/mysql lunshift library_path ${prefix}/lib/mysql5/mysql configure.args-delete -no-sql-mysql configure.args-append -plugin-sql-mysql } variant odbc description {Enable iODBC SQL Driver} { depends_lib-append port:libiodbc archcheck.files-append lib/libiodbc.dylib configure.args-delete -no-sql-odbc configure.args-append -plugin-sql-odbc } variant psql83 conflicts psql84 psql90 psql91 \ description {Enable Postgre SQL Driver version 8.3} {} variant psql84 conflicts psql83 psql90 psql91 \ description {Enable Postgre SQL Driver version 8.4} {} variant psql90 conflicts psql83 psql84 psql91 \ description {Enable Postgre SQL Driver version 9.0} {} variant psql91 conflicts psql83 psql84 psql90 \ description {Enable Postgre SQL Driver version 9.1} {} set psql_version "" if {[variant_isset psql83]} { set psql_version "83" } elseif {[variant_isset psql84]} { set psql_version "84" } elseif {[variant_isset psql90]} { set psql_version "90" } elseif {[variant_isset psql91]} { set psql_version "91" } if {${psql_version} != ""} { depends_lib-append port:postgresql${psql_version} archcheck.files-append lib/postgresql${psql_version}/libpgtypes.dylib lunshift header_path ${prefix}/include/postgresql${psql_version} lunshift library_path ${prefix}/lib/postgresql${psql_version} configure.args-delete -no-sql-psql configure.args-append -plugin-sql-psql } variant sqlite2 description {Enable SQLite version 2 SQL Driver} { depends_lib-append port:sqlite2 archcheck.files-append lib/libsqlite.dylib configure.args-delete -no-sql-sqlite2 configure.args-append -plugin-sql-sqlite2 } variant raster description {Use raster graphics system by default} { configure.args-append -graphicssystem raster } variant demos description {Build demos} {} if {![variant_isset demos]} { configure.args-append -nomake demos } variant examples description {Build examples} {} if {![variant_isset examples]} { configure.args-append -nomake examples } variant debug description {Build both release and debug library} {} if {[variant_isset debug]} { configure.args-append -debug-and-release } else { configure.args-append -release } variant quartz conflicts x11 \ description {Build for Native OSX Quartz GUI, not X11 (default)} {} variant x11 conflicts quartz \ description {Build for X11 GUI, not Native OSX Quartz} {} # if neither +x11 or +quartz were specified, default to the latter if {![variant_isset quartz] && ![variant_isset x11]} { default_variants +quartz } # check to see if user specified just "-quartz", which can't work. if {![variant_isset quartz] && ![variant_isset x11]} { return -code error \ "\n\nThe variant -quartz will not work alone. Please select one of +quartz or +x11 as a variant.\n" } if {[variant_isset x11]} { return -code error "\n\nVariant +x11 is not yet functional; \ please use +quartz for now.\n" } livecheck.type regex livecheck.url http://get.qt.nokia.com/qt/source/ livecheck.regex "qt-everywhere-opensource-src-(\[0-9a-z.-\]+)${extract.suffix}"