6.9. Using KDE

6.9.1. Variable definitions

表格 6.7. Variables for ports that use KDE
USE_KDELIBS_VERThe port uses KDE libraries. It specifies the major version of KDE to use and implies USE_QT_VER of the appropriate version. The only possible value is 3.
USE_KDEBASE_VERThe port uses KDE base. It specifies the major version of KDE to use and implies USE_QT_VER of the appropriate version. The only possible value is 3.

6.9.2. Ports that require Qt

表格 6.8. Variables for ports that use Qt
USE_QT_VERThe port uses the Qt toolkit. Possible values are 3 and 4; each specify the major version of Qt to use. Appropriate parameters are passed to configure script and make.
QT_PREFIXSet to the path where Qt installed to (read-only variable).
MOCSet to the path of moc (read-only variable). Default set according to USE_QT_VER value.
QTCPPFLAGSAdditional compiler flags passed via CONFIGURE_ENV for Qt toolkit. Default set according to USE_QT_VER.
QTCFGLIBSAdditional libraries for linking passed via CONFIGURE_ENV for Qt toolkit. Default set according to USE_QT_VER.
QTNONSTANDARDSuppress modification of CONFIGURE_ENV, CONFIGURE_ARGS, and MAKE_ENV.

表格 6.9. Additional variables for ports that use Qt 4.x
QT_COMPONENTSSpecify tool and library dependencies for Qt4. See below for details.
UICSet to the path of uic (read-only variable). Default set according to USE_QT_VER value.
QMAKESet to the path of qmake (read-only variable). Default set according to USE_QT_VER value.
QMAKESPECSet to the path of configuration file for qmake (read-only variable). Default set according to USE_QT_VER value.

When USE_QT_VER is set, some useful settings are passed to configure script:

CONFIGURE_ARGS+= --with-qt-includes=${QT_PREFIX}/include \ --with-qt-libraries=${QT_PREFIX}/lib \ --with-extra-libs=${LOCALBASE}/lib \ --with-extra-includes=${LOCALBASE}/include CONFIGURE_ENV+= MOC="${MOC}" CPPFLAGS="${CPPFLAGS} ${QTCPPFLAGS}" LIBS="${QTCFGLIBS}" \ QTDIR="${QT_PREFIX}" KDEDIR="${KDE_PREFIX}"

If USE_QT_VER is set to 4, the following settings are also deployed:

CONFIGURE_ENV+= UIC="${UIC}" QMAKE="${QMAKE}" QMAKESPEC="${QMAKESPEC}" MAKE_ENV+= QMAKESPEC="${QMAKESPEC}"

6.9.3. Component selection (Qt 4.x only)

When USE_QT_VER is set to 4, individual Qt4 tool and library dependencies can be specified in the QT_COMPONENTS variable. Every component can be suffixed by either _build or _run, the suffix indicating whether the component should be depended on at buildtime or runtime, respectively. If unsuffixed, the component will be depended on at both build- and runtime. Usually, library components should be specified unsuffixed, tool components should be specified with the _build suffix and plugin components should be specified with the _run suffix. The most commonly used components are listed below (all available components are listed in _QT_COMPONENTS_ALL in /usr/ports/Mk/bsd.qt.mk):

表格 6.10. Available Qt4 library components
NameDescription
corelibcore library (can be omitted unless the port uses nothing but corelib)
guigraphical user interface library
networknetwork library
openglOpenGL library
qt3supportQt3 compatibility library
qtestlibunit testing library
scriptscript library
sqlSQL library
xmlXML library

You can determine which libraries the application depends on, by running ldd on the main executable after a successful compilation.

表格 6.11. Available Qt4 tool components
NameDescription
mocmeta object compiler (needed for almost every Qt application at buildtime)
qmakeMakefile generator / build utility
rccresource compiler (need if the application comes with *.rc or *.qrc files)
uicuser interface compiler (needed if the application comes with *.ui files created by Qt Designer - in practice, every Qt application with a GUI)

表格 6.12. Available Qt4 plugin components
NameDescription
iconenginesSVG icon engine plugin (if the application ships SVG icons)
imageformatsimageformat plugins for GIF, JPEG, MNG and SVG (if the application ships image files)

範例 6.3. Selecting Qt4 components

In this example, the ported application uses the Qt4 graphical user interface library, the Qt4 core library, all of the Qt4 code generation tools and Qt4's Makefile generator. Since the gui library implies a dependency on the core library, corelib does not need to be specified. The Qt4 code generation tools moc, uic and rcc, as well as the Makefile generator qmake are only needed at buildtime, thus they are specified with the _build suffix:

USE_QT_VER= 4 QT_COMPONENTS= gui moc_build qmake_build rcc_build uic_build

6.9.4. Additional considerations

If the application does not provide a configure file but a .pro file, you can use the following:

HAS_CONFIGURE= yes do-configure: @cd ${WRKSRC} && ${SETENV} ${CONFIGURE_ENV} \ ${QMAKE} -unix PREFIX=${PREFIX} texmaker.pro

Note the similarity to the qmake line from the provided BUILD.sh script. Passing CONFIGURE_ENV ensures qmake will see the QMAKESPEC variable, without which it cannot work. qmake generates standard Makefiles, so it is not necessary to write our own build target.

Qt applications often are written to be cross-platform and often X11/Unix isn't the platform they are developed on, which in turn often leads to certain loose ends, like:

  • Missing additional includepaths. Many applications come with system tray icon support, but neglect to look for includes and/or libraries in the X11 directories. You can tell qmake to add directories to the include and library searchpaths via the commandline, for example:

    ${QMAKE} -unix PREFIX=${PREFIX} INCLUDEPATH+=${LOCALBASE}/include \ LIBS+=-L${LOCALBASE}/lib sillyapp.pro
  • Bogus installation paths. Sometimes data such as icons or .desktop files are by default installed into directories which aren't scanned by XDG-compatible applications. editors/texmaker is an example for this - look at patch-texmaker.pro in the files directory of that port for a template on how to remedy this directly in the Qmake project file.

本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/

若有 FreeBSD 方面疑問,請先閱讀 FreeBSD 相關文件,如不能解決的話,再洽詢 <questions@FreeBSD.org>。

關於本文件的問題,請洽詢 <doc@FreeBSD.org>。