6.7. Using X11
前一頁 | 章 6. Special considerations | 下一頁

## 6.7. Using X11

### 6.7.1. X.Org components

The X11 implementation available in The Ports Collection is X.Org. If your application depends on X components, set `USE_XORG` to the list of required components. Available components, at the time of writing, are:

`bigreqsproto compositeproto damageproto dmx dmxproto evieproto fixesproto fontcacheproto fontenc fontsproto fontutil glproto ice inputproto kbproto libfs oldx printproto randrproto recordproto renderproto resourceproto scrnsaverproto sm trapproto videoproto x11 xau xaw xaw6 xaw7 xaw8 xbitmaps xcmiscproto xcomposite xcursor xdamage xdmcp xevie xext xextproto xf86bigfontproto xf86dgaproto xf86driproto xf86miscproto xf86rushproto xf86vidmodeproto xfixes xfont xfontcache xft xi xinerama xineramaproto xkbfile xkbui xmu xmuu xorg-server xp xpm xprintapputil xprintutil xpr oto xproxymngproto xrandr xrender xres xscrnsaver xt xtrans xtrap xtst xv xvmc xxf86dga xxf86misc xxf86vm`.

Always up-to-date list can be found in `/usr/ports/Mk/bsd.xorg.mk`.

The Mesa Project is an effort to provide free OpenGL implementation. You can specify a dependency on various components of this project with `USE_GL` variable. Valid options are: `glut, glu, glw, gl` and `linux`. For backwards compatibility, the value of `yes` maps to `glu`.

範例 6.1. USE_XORG example
USE_XORG= xrender xft xkbfile xt xaw USE_GL= glu

Many ports define `USE_XLIB`, which makes the port depend on all the 50 or so libraries. This variable exists for backwards compatibility, as it predates modular X.Org, and should not be used on new ports.

表格 6.5. Variables for ports that use X

`USE_XLIB` | The port uses the X libraries. Deprecated - use a list of X.Org components in `USE_XORG` variable instead.
`USE_IMAKE` | 會用到 `imake` 的 port。
`USE_X_PREFIX` | Deprecated. Today it is equivalent to `USE_XLIB` and can be replaced by it freely.
`XMKMF` | Set to the path of `xmkmf` if not in the `PATH`. Defaults to `xmkmf -a`.

表格 6.6. Variables for depending on individual parts of X11

`X_IMAKE_PORT` | Port providing `imake` and several other utilities used to build X11.
`X_LIBRARIES_PORT` | Port providing X11 libraries.
`X_CLIENTS_PORT` | Port providing X clients.
`X_SERVER_PORT` | Port providing X server.
`X_FONTSERVER_PORT` | Port providing font server.
`X_PRINTSERVER_PORT` | Port providing print server.
`X_VFBSERVER_PORT` | Port providing virtual framebuffer server.
`X_NESTSERVER_PORT` | Port providing a nested X server.
`X_FONTS_ENCODINGS_PORT` | Port providing encodings for fonts.
`X_FONTS_MISC_PORT` | Port providing miscellaneous bitmap fonts.
`X_FONTS_100DPI_PORT` | Port providing 100dpi bitmap fonts.
`X_FONTS_75DPI_PORT` | Port providing 75dpi bitmap fonts.
`X_FONTS_CYRILLIC_PORT` | Port providing cyrillic bitmap fonts.
`X_FONTS_TTF_PORT` | Port providing TrueType® fonts.
`X_FONTS_TYPE1_PORT` | Port providing Type1 fonts.
`X_MANUALS_PORT` | Port providing developer oriented manual pages

範例 6.2. Using some X11 related variables in port
# Use X11 libraries and depend on # font server as well as cyrillic fonts. RUN_DEPENDS= ${LOCALBASE}/bin/xfs:${X_FONTSERVER_PORT} \ ${LOCALBASE}/lib/X11/fonts/cyrillic/crox1c.pcf.gz:${X_FONTS_CYRILLIC_PORT} USE_XORG= yes

### 6.7.2. Ports that require Motif

If your port requires a Motif library, define `USE_MOTIF` in the `Makefile`. Default Motif implementation is `x11-toolkits/open-motif`. Users can choose `x11-toolkits/lesstif` instead by setting `WANT_LESSTIF` variable.

The `MOTIFLIB` variable will be set by `bsd.port.mk` to reference the appropriate Motif library. Please patch the source of your port to use `${MOTIFLIB}` wherever the Motif library is referenced in the original `Makefile` or `Imakefile`.

There are two common cases:

- If the port refers to the Motif library as `-lXm` in its `Makefile` or `Imakefile`, simply substitute `${MOTIFLIB}` for it.

- If the port uses `XmClientLibs` in its `Imakefile`, change it to `${MOTIFLIB} ${XTOOLLIB} ${XLIB}`.

Note that `MOTIFLIB` (usually) expands to `-L/usr/X11R6/lib -lXm` or `/usr/X11R6/lib/libXm.a`, so there is no need to add `-L` or `-l` in front.

### 6.7.3. X11 fonts

If your port installs fonts for the X Window System, put them in ``LOCALBASE`/lib/X11/fonts/local`.

### 6.7.4. Getting fake `DISPLAY` using Xvfb

Some applications require a working X11 display for compilation to succeed. This pose a problem for machines which operates headless. When the following variable is used, the build infrastructure will start the virtual framebuffer X server. The working `DISPLAY` is then passed to the build.

USE_DISPLAY= yes

### 6.7.5. Desktop entries

可藉由設定 `DESKTOP_ENTRIES` 變數，以輕鬆設定 port 的 X 選單項目 (Desktop Entries，請參閱 Freedesktop standard)。 這些項目會在相應的桌面環境如 GNOME 或 KDE 的應用程式選單中出現。 `.desktop` 檔案 將會被建立、安裝以及自動加入 `pkg-plist` 中。語法為：

DESKTOP_ENTRIES= "NAME" "COMMENT" "ICON" "COMMAND" "CATEGORY" StartupNotify

可供使用的分類可參考 Freedesktop 網站。 而 `StartupNotify` 變數會決定程式，是否支援 startup noficication 的環境。

範例：

DESKTOP_ENTRIES= "ToME" "Roguelike game based on JRR Tolkien's work" \ "${DATADIR}/xtra/graf/tome-128.png" \ "tome -v -g" "Application;Game;RolePlaying" \ false

前一頁 | 上一層 | 下一頁
6.6. Using `perl` | 起始頁 | 6.8. Using GNOME

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

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