
			Cross-configuring Lsof

Introduction
============

Lsof cross-configuration is useful when the target dialect or target
dialect version for which lsof is to be configured and built differs
from the one on which the Configure operation is done.

Marty Leisner <leisner@sdsp.mc.xerox.com> suggested the method
described here for lsof cross-configuration, and he supplied
modifications to the Configure script for cross-configuring Linux
lsof.

Marty says:

    "I used this to successfully compile (lsof) on the same machine
     for (Linux) 2.0.30 and 2.1.42.  (I normally don't bring up a
     2.1.42 machine all the time).  Also it (the 2.0.30 system)
     doesn't have much storage and compiles on it are slow.

     Set LSOF_VERS if it's not the (version of the) current system.
     (Actually, you should get the version out of include/linux/version.h.)

     Define LINUX_KERNEL to (the path) where the kernel sources
     are (located).

     This should work on most systems; they put a kernel in
     /usr/src/linux, which is the default.

     Now I can just do:

	LINUX_KERNEL=/some/other/kernel LSOF_VERS=2142 ./Configure linux

     Comments?  Its very convenient when running multiple kernels.
     (It would be (have been) very handy when the structures changed
     between 2.0.2* and 2.0.30 , or whatever.)

     I run multiple OSes at a time (not to mention multiple
     architectures.  It's very pleasant to cross-build either
     operating systems or versions."

So, the situation is that you have lsof sources on a UNIX dialect
version, and you want to configure them to build lsof for some
other version of the same dialect, or perhaps for some other UNIX
dialect altogether.


The Cross-Configure Method
==========================

The lsof cross-configure method uses environment variables to tell
the lsof Configure script about the target dialect.  The environment
variables may specify alternate locations for Configure to examine
when it determines characteristics of the target, or they may
specify the values Configure would discover when it examined the
target's characteristics.

Consult each environment variable description for the UNIX dialect
in which you're interested to see how it affects the operation of
the Configure script.

The number and values of the variables differ by dialect.  Each
variable begins with an upper case version of the dialect's Configure
abbreviation -- e.g., AIX for aix or aixgcc, LINUX for linux,
UW for uw (UnixWare), etc.

Of course, the UNIX dialect's version is probably different from
that of the system on which you're doing the cross-configuration,
so you will need to specify the new version, too.  For example, to
configure for FreeBSD 3.0 on a 2.1.7 system, where the standard
3.0 header files are in /3.0/usr/include and the 3.0 system sources
are in /3.0/sys, do this:

	LSOF_VERS=300 LSOF_INCLUDE=/3.0/usr/include \
	FREEBSD_SYS=/3.0/sys Configure -n freebsd


Special Environment Variables
=============================

There are seven special environment variables whose names don't
begin with an upper case rendering of a dialect abbreviation.

The first, AFS_VICE, is for AFS configuration.   It need be set
only if lsof supports AFS on your dialect and you want to specify
an alternate path to the VICE files.

The second, LSOF_ARCH, is the architecture type string for the
system.  Usually this is the output of `uname -m`.  Consult the
Configure script for details.  The LSOF_ARCH value may have to be
quoted if it contains spaces.

The third, LSOF_CC, is the path to the C compiler.  You may need
to specify it if your C compiler is in a non-standard place, not
found by your path.  If you specify a compiler different from the
expected default, you may have to change the compile time flags by
specifying new CFGF, CFGL, and DEBUG strings on the make command
line.

The fourth, LSOF_CCV, is the C compiler version.  You should specify
it if you have specified a compiler path in LSOF_CC.

The fifth, LSOF_INCLUDE, is the path to the standard header files.
You may need to specify it if you want Configure to test header
files in a tree different from /usr/include, and you want to compile
lsof from the header files in that different tree.

The sixth, LSOF_VERS, is the target dialect version number.  It
must be stated in the dialect's form -- e.g., FreeBSD 2.0.5 is
given as 205, Solaris 7 as 70000, etc.  The table, "Abbreviations,
Variable Prefixes, and Version Numbers," in this file gives the
form for LSOF_VERS for each dialect lsof supports.

The seventh, LSOF_VSTR, is the version string from which LSOF_VERS
is derived.  Usually this is the output of `uname -r` or `uname
-v`.  Consult the Configure script for details.   The LSOF_VSTR
value may have to be quoted if it contains spaces.

AFS_VICE                specifies the path to the AFS "vice" directory.

			default: /usr/vice

LSOF_ARCH               specifies the system architecture type.

			default: auto-detection (e.g., from `uname -m`)

LSOF_CC			specifies the path to the C compiler.

			default: normally cc, but some dialects have other
				 defaults and some have auto-detection.

				 Check the dialect stanza in the lsof Configure
				 script to see how LSOF_CC is set by default.

LSOF_CCV		specifies the version of the C compiler specified in
			LSOF_CCV.  This variable is ignored if LSOF_CC isn't
			defined.

			default: the lsof Configure script knows how to find
				 the version number of gcc and some other
				 dialect-specific compilers.

				 Check the dialect stanza in ths lsof Configure
				 script to see how lsof_CCV is set by default.

LSOF_INCLUDE		specifies the path to the standard header files.

			default: /usr/include

LSOF_VERS		specifies the target dialect's version in its form.

			default: auto-detection (e.g., from `uname -r`)

LSOF_VSTR		specifies the dialect version string.

			default: auto-detection (e.g., output from
				 `hostname`, `uname -r`, or `uname -v)


Make Strings
============

The CFGF, CFGL, and DEBUG strings can be specified on the make
command line to change default values placed in the top-level and
library Makefiles by Configure.  For example, Configure usually
defines the compiler optimization level to be -O, but you can change
that with "DEBUG=-g" on the make command -- e.g.,

	$ make DEBUG=-g lsof

Similarly, the CFGF string contains miscellaneous compile-time
options, and CFGL contains loader options.  Consult the Makefiles
generated by Configure for the values it defines by default for
CFGF and CFGL.

As an example, Configure might define CFGL to be "-L./lib -llsof -w"
for NextStep 3.1; to remove "-w", use this make invocation:

	$ make CFGL="-L./lib -llsof"


Abbreviations, Variable Prefixes, and Version Numbers
=====================================================

The following table describes the relationship between Configure
abbreviations, environment variable prefixes, and lsof UNIX dialect
version numbers.  The lsof UNIX dialect version number must be
declared exactly in the listed form when supplied via the LSOF_VERS
environment variable.

				Dialect	   Lsof Version
   Configure	Variable	Version      Number for
Abbreviation*	  Prefix	 Number       LSOF_VERS

	 aix	     AIX	  3.2.5		   3250
      aixgcc			  4.1.0		   4100
				  4.1.4		   4140
				  4.1.4		   4150
				  4.2.0		   4200
				  4.2.1		   4210
				  4.3		   4300
				  4.3.1		   4310
				  4.3.2		   4320
	bsdi	    BSDI	  2.0.x		  20000
				  2.1.x		  20100
				  3.0.x		  30000
				  3.1.x		  30100
				  4.0		  40000
				  4.1		  40100
	  du	      DU	  2.0		  20000
				  3.0		  30000
				  3.2		  30200
				  4.0		  40000
				  5.0-Beta	  50000
     freebsd	 FREEBSD	  1.x		    100
				  2.x		    200
				  2.0.5		    205
				  2.1.x		    210
				  2.2.x		    220
				  3.x		    300
				  4.x		    400
	hpux	    HPUX	  9.1		    901
     hpuxgcc			  9.5		    905
				  10.0		   1000
				  10.10		   1010
				  10.20		   1020
				  11.00		   1100
      linux	   LINUX	  1.3.68	  13068
				  2.0.33	  20033
				  2.1.91	  21091
				  2.2.5		  20205
     netbsd	  NETBSD	  1.0		   1000
				  1.1		   1010
				  1.2		   1020
				  1.3		   1030
				  1.4		   1040
	 ns	NEXTSTEP	  3.1		     31
    openbsd	 OPENBSD	  1.2		   1020
				  2.0		   2000
				  2.1		   2010
				  2.2		   2020
				  2.3		   2030
				  2.4		   2040
				  2.5		   2050
				  2.6		   2060
         os	OPENSTEP	  4.x		     4x
    pyramid	 PYRAMID	  1.1		  10100  (DC/OSx)
				  5.43		  54300  (Reliant UNIX)
				  5.44		  54400  (Reliant UNIX)
	ptx	     PTX	  2.1.9		    219
				  4.0		    400
				  4.1.3		    413
				  4.1.4		    414
				  4.2.1		    421
				  4.3		    430
				  4.4		    440
				  4.4.1		    441
				  4.4.2		    442
				  4.4.4		    444
	osr	      OSR	  3.2v2.0	     20
				  3.2v2.1	     21
				  3.2v4.0	     40
				  3.2v4.1	     41
				  3.2v4.2	     42
				  3.2v5.0.0	    500
				  3.2v5.0.2	    502
				  3.2v5.0.4	    504
    solaris	  SOLARIS	  2.3		  20300
  solariscc			  2.4		  20400
				  2.5		  20500
				  2.5.1		  20501
				  2.6		  20600
				  7		  70000
				  8		  80000
      sunos	    SUNOS	  4.1.3		  40103
    sunoscc			  4.1.4		  40104
     ultrix	   ULTRIX	  4.2		  40200
				  4.3		  40300
				  4.4		  40400
				  4.5		  40500
	 uw	       UW	  2.1		  20100
				  2.1.1		  20101
				  2.1.2		  20102
				  2.1.3		  20103
				  7.0		  70000
				  7.0.1		  70001

* -- The optional Configure abbreviations -- e.g., the ``decosf''
     and ``digital_unix'' alternatives to ``du'' -- aren't listed
     here.


Dialect-Specific Environment Variables
======================================

Here are the dialect-specific environment variables, listed
alphabetically.  The first part of any environment variable will
be the dialect abbreviation, as specified to Configure, converted
to upper case characters.  See the `Configure -help` output for a
listing of the abbreviations.

AIX_USHACK		If this environment variable has a value of "Y" or "y",
			and if the aixgcc Configure abbreviation is selected,
			the AIX 4.1 and greater gcc user structure hack is
			activated; any other non-NULL value, it's not set; a
			NULL value, it's tested by compilation.

			default: none (tested by compilation)

DU_ADVFSV		specifies the DEC OSF/1, Digital UNIX, or Tru64 UNIX
			ADVFS file system version -- e.g., 200 for 2.0, 400
			for 4.0, etc.

			default: determined via /usr/sbin/setld

DU_CDIR			specifies the name of the DEC OSF/1, Digital UNIX, or
			Tru64 UNIX system configuration directory.

			default: first host name component, converted to upper
				 case

DU_SHLIB		specifies the DEC OSF/1, Digital UNIX, or Tru64 UNIX
			shared library directory path.

			default: /usr/shlib

DU_SYSDIR		DEC OSF/1, Digital UNIX, or Tru64 UNIX system
			directory path.

			2.x and 3.x default: /sys
			4.x default: /usr/sys

FREEBSD_KERNEL		specifies the path to the FreeBSD kernel for FreeBSD
			version less than 2.0.

			default: /386bsd

FREEBSD_SYS		specifies the path to the FreeBSD system source
			directory.

			default: /sys

HPUX_CCDIR1		specifies the first directory where Configure might
			find an HP-UX C compiler.  This is ignored when
			LSOF_CC has been specified.

			default: /bin

HPUX_CCDIR2		specifies the second directory where Configure might
			find an HP-UX C compiler.  This is ignored when
			LSOF_CC has been specified.

			default: /usr/ccs/bin

HPUX_RNODE3		If this environment variable has a value of "1", the
			Configure script will define HASRNODE3 in the Makefile
			CFGF flags.   If it is defined, but not "1", Configure
			will not define HASRNODE2.

			default: determined using `nm -x /stand/vmunix` and
				 `grep r_fh3 /usr/include/nfs/rnode.h`

HPUX_IPC_S_PATCH	If this environment variable has a value of "1", the
			ipc_s structure of the HP-UX 11 kernel is assumed to
			have an ipc_ipis member, but it is assumed the ipis_s
			structure lacks the ipis_msgsqueued member; "2", ipc_s
			has ipc_ipis, but ipis_s has ipis_msgsqueued; "n" or
			"N", ipc_s lacks ipc_ipis; any other non-NULL value is
			considered an error; a NULL value, HPUX_IPC_S_PATCH is
			determined by testing.
			
			default: determined with q4 and grep

HPUX_KERNBITS		specifies the number of bits (32 or 64) in the HP-UX
			11 "basic kernel word.

			default: `getconf _SC_KERNEL_BITS`

HPUX_LIBC1		specifies the first directory that might contain the
			HP-UX C library, libc.sl.

			default: /usr/lib

HPUX_LIBC2		specifies the second directory that might contain the
			HP-UX C library, libc.sl.

			default: /lib

HPUX_X25DIR		specifies path to the HP-UX X25 directory that contains
			configuration header files.

			default: /etc/conf

LINUX_BASE		specifies the source base -- "/proc" or "/dev/kmem"
			that should be used.

			default: determined by examining the output of
				 `ls -l /proc/self/fd`.

LINUX_CLIB		specifies the definition of the Linux C library:

			default: "" 		(standard C library)
			others: -DGLIBCV=2  	(glibc2)

LINUX_KERNEL		specifies the path to the Linux kernel sources.

			default: /usr/src/linux

LINUX_LSEEK		If this environment variable has a value of "Y" or "y",
			Configure uses Makefile.lseek in place of Makefile in
			order to enable use of the private lseek() function for
			2.1.x kernels; any other non-NULL value, Makefile.lseek
			will isn't used; a NULL value, the alternate lseek()
			need is determined by compilation.

			default: determined by test program

NETBSD_SYS		specifies the path to the NetBSD system source
			directory.

			default: /sys

NETBSD_UVM		If this environment variable has a value of "Y" or "y",
			the NetBSD system uses the UVM virtual memory system;
			any other non-NULL value, it does not; a NULL value,
			it will be determined by the contents of /etc/mk.conf.

			default: tested by grep'ping /etc/mk.conf

OPENBSD_SYS		specifies the path to the OpenBSD system source
			directory.

			default: /sys

OSR_STATLSTAT		If this environment variable has a value of "Y" or "y",
			HAS_STATLSTAT is defined in the Makefile's CFGL string;
			any other non-NULL value, it's not defined; a NULL
			value, it is determined with nm and grep.

			default: determined with nm and grep

PYRAMID_ARCH		If this environment variable has a non-NULL value, it
			is interpreted as the output of the command:

				/bin/pkgparam dcosx ARCH
			
			default: `/bin/pkgparam dcosx ARCH`

PYRAMID_DCOSXVERS	If this environment variable has a non-NULL value, it
			is interpreted as the output of the command:

				/bin/pkgparam dcosx VERSION

			default: `/bin/pkgparam dcosx VERSION`

PYRAMID_PROC		If this environment variable has a non-NULL value, it
			is interpreted as the output of the command:

				/bin/uname -p
			
			default: `/bin/uname -p`

PYRAMID_SYSNM		If this environment variable has a non-NULL value, it
			is interpreted as the output of the command:

				/bin/uname -s
			
			default: `/bin/uname -s`

PTX_CONF		specifies the path to the configuration header files.

			default: /usr/conf/uts

PTX_TCP_NAME		specifies the path configuration file where the PTX TCP
			version name is located.

			default: /usr/options/tcp/tcp.name

PTX_TCPV		specifies the PTX TCP version as a 3 digit decimal
			number, formed from the first three numbers separated by
			decimal points in the file PTX_TCP_NAME -- e.g., PTX
			TCP/IP V4.2.1 becomes 421, PTX TCP/IP V4.2.2.1 becomes
			422, PTX TCP/IP V4.4.3 becomes 443, PTX TCP/IP V4.5.1.1
			becomes 451.  PTX_TCPV should be set to 0 if no
			PTX_TCP_NAME test is possible (e.g., for PTX below 4.0).

			default: formed with awk from the contents of the file
				 PTX_TCP_NAME

SOLARIS_23P101318	If this environment variable has a non-NULL value, the
			value is interpreted as the patch level of the Solaris
			2.3 P101318 patch.

			default: pkginfo tested with grep

SOLARIS_24P101945	If this environment variable has a non-NULL value, the
			value is interpreted as the patch level of the Solaris
			2.4 P101945 patch.

			default: pkginfo tested with grep

SOLARIS_24P102303	If this environment variable has a non-NULL value, the
			value is interpreted as the patch level of the Solaris
			2.4 P102303 patch.

			default: pkginfo tested with grep

SOLARIS_26PR_GWINDOWS	If this environment variable has a value of "Y" or "y",
			the HASPR_GWINDOWS definition is set in the Solaris 2.6
			and 7 Makefile's CFG string; any other non-NULL value,
			it's not set; a NULL value, it's tested by compilation.

			default: tested by compilation

SOLARIS_26PR_LDT	If this environment variable has value of "Y" or "y",
			the HASPR_LDT definition is set in the Solaris 2.6
			Makefile's CFGL string; any other non-NULL value, it's
			not set; a NULL value, it's tested by compilation.

			default: tested by compilation

SOLARIS_KERNBITS	specifies the nuber of bits in the Solaris 7 or 8
			kernel: 32 or 64.

			default: tested with /bin/isainfo -kv

SOLARIS_CCDIR		specifies the path to the Sun C compiler -- i.e., when
			`Configure solariscc` is used.  This is ignored when
			LSOF_CC has been specified.

			default: /opt/SUNWspro/bin

SOLARIS_VSOCK		If this environment variable has value of "Y" or "y",
			the HAS_VSOCK definition is in the Solaris Makefile's
			CFGL string; any other non-NULL value, it's not set; a
			NULL value, it's tested by compilation.

			default: tested by compilation

SUN_AFSAPATHDEF		specifies the path to the AFS library modload file
			for either Solaris or SunOS.

			default: /usr/vice/etc/modload/libafs
				 Verified with ls.

SUNOS_ACC		specifies the path to the SunOS acc C compiler.  This
			is ignored when LSOF_CC has been specified.

			default: /usr/lang

SUNOS_AUSPEXV		specifies the Auspex LFS version in use on the SunOS
			4.1.4 or greater system in the form %d%02d%02d -- e.g.,
			1.8.1 becomes 10801.

			default: derived from `uname -a` with sed and awk

SUNOS_NOCONST		If this environment variable has a value of "Y" or "y",
			the NOCONST definition is set in the SunOS (Solaris
			1.x) Makefile's CFGL string; any other non- NULL value,
			it's not set; a NULL value, it's tested by compilation.
			
			default: tested by compilation

SUNOS_VSOCK		If this environment variable has a value of "Y" or "y",
			the HAS_VSOCK definition is set in the SunOS (Solaris
			1.x) Makefile's CFGL string; any other non-NULL value,
			it's not set; a NULL value, it's tested by compilation.

			default: tested by compilation

ULTRIX_HWNM		specifies the Ultrix hardware name in the form of
			the output of `uname -m`.

			default: `uname -m`

ULTRIX_DECNET		If this environment variable has a value of "Y" or "y",
			the DECnet definition is set in the Ultrix Makefile's
			CFGL string, and the -ldnet Makefile loader flag is
			defined; any other non-NULL value, they're not set; a
			NULL value, they're determined by testing for
			${ULTRIX_USRLIB}.libdnet.a and
			${LSOF_INCLUDE}/netdnet/dn.h.

			default: based on test for <netdnet/dn.h>

ULTRIX_USRLIB		specifies an alternate path to the Ultrix /usr/lib.

			default: /usr/lib

Vic Abell <abe@purdue.edu>
Purdue University Computing Center (PUCC)
November 28, 1999
