Index: postinstall
===================================================================
--- postinstall 12 Aug 2014 09:12:18 -0000      1.179
+++ postinstall 14 Aug 2014 09:15:58 -0000
@@ -728,7 +728,22 @@ get_makevar()
detect_x11()
{
       if $SOURCEMODE; then
-               get_makevar MKX11 X11ROOTDIR X11SRCDIR
+               if [ -n "${XSRC_DIR}" ]; then
+                       # -x XSRC_DIR on command line forces MKX11=yes
+                       # and forces X11SRCDIR, but X11ROOTDIR comes
+                       # from get_makevar.
+                       MKX11=yes
+                       X11SRCDIR="${XSRC_DIR}"
+                       get_makevar X11ROOTDIR
+               else
+                       # No -x on command line.  Use get_makevar, and
+                       # set XSRC_DIR according to the result.
+                       get_makevar MKX11 X11ROOTDIR X11SRCDIR
+                       case "${MKX11:-no}" in
+                       [yY][eE][sS]) XSRC_DIR="${X11SRCDIR}" ;;
+                       esac
+
+               fi
       else
               if [ -f "${SRC_DIR}/etc/mtree/set.xetc" ]; then
                       MKX11=yes
@@ -738,6 +753,9 @@ detect_x11()
                       X11ROOTDIR=
               fi
               X11SRCDIR=/nonexistent/xsrc
+               if [ -n "${XSRC_DIR}" ]; then
+                       err 2 "-x option is allowed only in source mode"
+               fi
       fi
}

@@ -938,6 +956,9 @@ do_fontconfig()
       if ! $SOURCEMODE; then
               FONTCONFIG_DIR="${SRC_DIR}/etc/fonts/conf.avail"
       else
+               if [ -z "${XSRC_DIR}" ]; then
+                       msg "No xsrc dir; skipping fontconfig check"
+               fi
               FONTCONFIG_DIR="${XSRC_DIR}/external/mit/fontconfig/dist/conf.d"
       fi

@@ -2053,7 +2074,7 @@ Usage: ${PROGNAME} [-s srcdir] [-x xsrcd
                                                       [${SRC_DIR:-/usr/src}]
       -x xsrcdir      Location of the X11 source files.  This must be
                       a directory that contains a NetBSD xsrc tree.
-                                                       [${XSRC_DIR:-/usr/src/../xsrc}]
+                                                       [automatic]
       -d destdir      Destination directory to check. [${DEST_DIR:-/}]
       -m mach         MACHINE.                        [${MACHINE}]
       -a arch         MACHINE_ARCH.                   [${MACHINE_ARCH}]
@@ -2096,7 +2117,7 @@ main()
       TGZLIST=                # quoted list list of tgz files
       SRC_ARGLIST=            # quoted list of one or more "-s" args
       SRC_DIR="${SRC_ARG}"    # set default value for early usage()
-       XSRC_DIR="${SRC_ARG}/../xsrc"
+       XSRC_DIR=""
       N_SRC_ARGS=0            # number of "-s" args
       TGZMODE=false           # true if "-s" specifies a tgz file
       DIRMODE=false           # true if "-s" specified a directory
Index: postinstall.8
===================================================================
--- postinstall.8       15 Aug 2012 16:21:41 -0000      1.16
+++ postinstall.8       14 Aug 2014 09:25:43 -0000
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd August 15, 2012
+.Dd August 14, 2014
.Dt POSTINSTALL 8
.Os
.Sh NAME
@@ -39,6 +39,7 @@
.Op Fl d Ar destdir
.Op Fl m Ar machine
.Op Fl s Brq Ar srcdir | Ar tgzdir | Ar tgzfile
+.Op Fl x Ar xsrcdir
.Ar operation
.Op Ar item Op ...
.Sh DESCRIPTION
@@ -118,6 +119,24 @@ The
.Dq Pa xetc.tgz
set file is optional.
.El
+.It Fl x Ar xsrcdir
+Location of the X11 source files.
+If specified, this must be a directory that contains a
+.Nx
+.Sy xsrc
+tree.
+This option is valid only in source mode (when the
+.Fl s
+option specifies a directory that contains a
+.Nx
+.Sy src
+tree).
+By default, this is derived from the
+.Ev MKX11
+and
+.Ev X11SRCDIR
+variables in the environment and
+.Xr mk.conf 5 .
.El
.Pp
The