6.9. Using X11

6.9.1. X.Org Components

The X11 implementation available in The Ports Collection is X.Org. If the application depends on X components, set USE_XORG to the list of required components. A full list can be found in Table 6.7, “Available X.Org Components”. An always up-to-date list can be found in /usr/ports/Mk/bsd.xorg.mk.

Table 6.7. Available X.Org Components
NameDescription
dmxDMX extension library
fontencThe fontenc Library
fontutilCreate an index of X font files in a directory
iceInter Client Exchange library for X11
libfsThe FS library
oldxOld X library
pciaccessGeneric PCI access library
pixmanLow-level pixel manipulation library
smSession Management library for X11
x11X11 library
xauAuthentication Protocol library for X11
xawX Athena Widgets library
xaw6X Athena Widgets library
xaw7X Athena Widgets library
xbitmapsX.Org bitmaps data
xcbThe X protocol C-language Binding (XCB) library
xcompositeX Composite extension library
xcursorX client-side cursor loading library
xdamageX Damage extension library
xdmcpX Display Manager Control Protocol library
xevieThe Xevie library
xextX11 Extension library
xfixesX Fixes extension library
xfontX font library
xfont2X font library version 2.x
xfontcacheThe Xfontcache library
xftClient-sided font API for X applications
xiX Input extension library
xineramaX11 Xinerama library
xkbfileXKB file library
xkbuiThe xkbui library
xmuX Miscellaneous Utilities libraries
xmuuX Miscellaneous Utilities libraries
xorg-macrosX.Org development aclocal macros
xorg-serverX.Org X server and related programs
xorgprotoX.Org protocol headers
xpX print library
xpmX Pixmap library
xprintapputilThe XprintAppUtil library
xprintutilThe XprintUtil library
xrandrX Resize and Rotate extension library
xrenderX Render extension library
xresX Resource usage library
xscrnsaverThe XScrnSaver library
xshmfenceShared memory 'SyncFence' synchronization primitive
xtX Toolkit library
xtransAbstract network code for X
xtrapThe XTrap library
xtstX Test extension
xvX Video Extension library
xvmcX Video Extension Motion Compensation library
xxf86dgaX DGA Extension
xxf86miscX XF86-Misc Extension
xxf86vmX Vidmode Extension

The Mesa Project is an effort to provide free OpenGL implementation. To specify a dependency on various components of this project, use USES= gl and USE_GL. See Section 17.30, “gl for a full list of available components. For backwards compatibility, the value of yes maps to glu.

Example 6.14. USE_XORG Example
USES=		gl
USE_GL=		glu
USE_XORG=	xrender xft xkbfile xt xaw

Table 6.8. Variables for Ports That Use X
USES= imakeThe port uses imake.
XMKMFSet to the path of xmkmf if not in the PATH. Defaults to xmkmf -a.

Example 6.15. Using X11-Related Variables
# Use some X11 libraries
USE_XORG=	x11 xpm

6.9.2. Ports That Require Motif

If the port requires a Motif library, define USES= motif in the Makefile. Default Motif implementation is x11-toolkits/open-motif. Users can choose x11-toolkits/lesstif instead by setting WANT_LESSTIF in their make.conf.

MOTIFLIB will be set by motif.mk to reference the appropriate Motif library. Please patch the source of the 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, 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 -lXp or /usr/local/lib/libXm.a, so there is no need to add -L or -l in front.

6.9.3. X11 Fonts

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

6.9.4. Getting a Fake DISPLAY with Xvfb

Some applications require a working X11 display for compilation to succeed. This poses a problem for machines that operate headless. When this variable is used, the build infrastructure will start the virtual framebuffer X server. The working DISPLAY is then passed to the build. See USES=display for the possible arguments.

USES=	display

6.9.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.9.5.1. Using Predefined .desktop Files

Ports that include predefined *.desktop must 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.9.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.9.5.3. Creating Desktop Entries with DESKTOP_ENTRIES

Desktop entries can be easily created for applications by using DESKTOP_ENTRIES. A file named name.desktop will be created, installed, and added to 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 must 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

All FreeBSD documents are available for download at https://download.freebsd.org/ftp/doc/

Questions that are not answered by the documentation may be sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.