3.3. How to build and install

Assuming you have fetched the distfiles, become root and change into the relevant subdirectory of /usr/pkgsrc. Then you can type

	make
  
at the shell prompt to build the various components of the package, and
	make install
  
at the shell prompt to install the various components into the correct places on your system.

Taking the top system utility as an example, we can install it on our system by building as shown in appendix Building top.

The program is installed under the default root of the packages tree, /usr/pkg. Should this not conform to your tastes, simply set the LOCALBASE variable in /etc/mk.conf, and it will use that value as the root of your packages tree. So, to use /usr/local, put

	LOCALBASE=/usr/local
  
in your /etc/mk.conf file. There is, of course, one exception to this. X11 packages are traditionally installed in the X11 tree, which is identified by X11BASE and defaults to /usr/X11R6.

It is possible to install X11 packages in the LOCALBASE tree, for which you must install the xpkgwedge package (pkgsrc/pkgtools/xpkgwedge), see Program locations for further details.

Some packages look in /etc/mk.conf to alter some configuration options at build time. Have a look at /usr/pkgsrc/mk/mk.conf.example to get an overview of what you can set there.

If you want to (re)install a binary package that you've created (see below) or that you put into .../pkgsrc/packages manually, you can use the the "bin-install" target, which will install a binary package - if available - via ``pkg_add'', and do a ``make package'' else.