6.7. Using X11
Prev | Chapter 6. Special Considerations | Next

## 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 dri2proto evieproto fixesproto fontcacheproto fontenc fontsproto fontutil glproto ice inputproto kbproto libfs oldx pciaccess pixman printproto randrproto recordproto renderproto resourceproto scrnsaverproto sm trapproto videoproto x11 xau xaw xaw6 xaw7 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 xproto 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, glew, gl` and `linux`. For backwards compatibility, the value of `yes` maps to `glu`.

Example 6.3. USE_XORG Example
USE_XORG= xrender xft xkbfile xt xaw USE_GL= glu
Table 6.6. Variables for Ports That Use X

`USE_IMAKE` | The port uses `imake`.
`XMKMF` | Set to the path of `xmkmf` if not in the `PATH`. Defaults to `xmkmf -a`.

Table 6.7. 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

Example 6.4. Using X11-Related Variables
# Use some 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= x11 xpm

### 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/local/lib -lXm` or `/usr/local/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 a Fake `DISPLAY` with Xvfb

Some applications require a working X11 display for compilation to succeed. This pose a problem for machines that operate 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 (a Freedesktop standard) provide a way to automatically adjust desktop features when a new program is installed, without requiring user intervention. For example, newly-installed programs automatically appear in the application menus of compatible desktop environments. Desktop entries originated in the GNOME desktop environment, but are now a standard and also work with KDE and Xfce. This bit of automation provides a real benefit to the user, and desktop entries are encouraged for applications which can be used in a desktop environment.

#### 6.7.5.1. Using Predefined `.desktop` Files

Ports that include predefined `*.desktop` files should include those files in `pkg-plist` and install them in the ``$LOCALBASE`/share/applications` directory. The `INSTALL_DATA` macro is useful for installing these files.

#### 6.7.5.2. Updating desktop database

If a port has a MimeType entry in its ``portname`.desktop`, the desktop database must be updated after install and deinstall. To do this, define `USES`= desktop-file-utils.

#### 6.7.5.3. Creating Desktop Entries with the `DESKTOP_ENTRIES` Macro

Desktop entries can be easily created for applications by using the `DESKTOP_ENTRIES` variable. A file named ``name`.desktop` will be created, installed, and added to the `pkg-plist` automatically. Syntax is:

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

The list of possible categories is available on the Freedesktop website. `StartupNotify` indicates whether the application is compatible with startup notifications. These are typically a graphic indicator like a clock that appear at the mouse pointer, menu, or panel to give the user an indication when a program is starting. A program that is compatible with startup notifications clears the indicator after it has started. Programs that are not compatible with startup notifications would never clear the indicator (potentially confusing and infuriating the user), and should have `StartupNotify` set to `false` so the indicator is not shown at all.

Example:

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

Prev | Up | Next
6.6. Using Perl | Home | 6.8. Using GNOME

This, and other documents, can be downloaded from http://ftp.FreeBSD.org/pub/FreeBSD/doc/

For questions about FreeBSD, read the documentation before contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.