9.3 PREFIX

Do try to make your port install relative to PREFIX. The value of this variable will be set to LOCALBASE (default /usr/local). If USE_X_PREFIX or USE_IMAKE is set, PREFIX will be X11BASE (default /usr/X11R6). If USE_LINUX_PREFIX is set, PREFIX will be LINUXBASE (default /compat/linux).

Avoiding the hard-coding of /usr/local or /usr/X11R6 anywhere in the source will make the port much more flexible and able to cater to the needs of other sites. For X ports that use imake, this is automatic; otherwise, this can often be done by simply replacing the occurrences of /usr/local (or /usr/X11R6 for X ports that do not use imake) in the various scripts/Makefiles in the port to read ${PREFIX}, as this variable is automatically passed down to every stage of the build and install processes.

Make sure your application is not installing things in /usr/local instead of PREFIX. A quick test for this is to do this is:

# make clean; make package PREFIX=/var/tmp/$(make -V PORTNAME)

If anything is installed outside of PREFIX, the package creation process will complain that it cannot find the files.

This does not test for the existence of internal references, or correct use of LOCALBASE for references to files from other ports. Testing the installation in /var/tmp/$(make -V PORTNAME) to do that while you have it installed would do that.

Do not set USE_X_PREFIX unless your port truly requires it (i.e., it links against X libs or it needs to reference files in X11BASE).

The variable PREFIX can be reassigned in your Makefile or in the user's environment. However, it is strongly discouraged for individual ports to set this variable explicitly in the Makefiles.

Also, refer to programs/files from other ports with the variables mentioned above, not explicit pathnames. For instance, if your port requires a macro PAGER to be the full pathname of less, use the compiler flag:

-DPAGER=\"${LOCALBASE}/bin/less\"
instead of -DPAGER=\"/usr/local/bin/less\". This way it will have a better chance of working if the system administrator has moved the whole /usr/local tree somewhere else.

For questions about the FreeBSD ports system, e-mail <[email protected]>.
For questions about this documentation, e-mail <[email protected]>.