
			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).  (No longer necessary as of lsof revision 4.53.)

     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?  It's 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


General Environment Variables
=============================

There are some environment variables whose names don't begin with
an upper case rendering of a dialect abbreviation.  Generally they
apply to all dialects.

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.

		default: /usr/vice

LSOF_AR         is the path to and arguments for the library archive
		application that is used to build the lsof library,
		liblsof.a.  When this value is placed in the library
		Makefile as the contents of the AR make string, it is
		followed by the path to the library and the relative
		paths of the library module

		default: ar cr

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.

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

LSOF_BLDCMT     may be used to introduce a builder's comment into
		lsof's -v output.  It defaults to the null string,
		causing no builder's comment to appear in -v output.

		default: none

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.

		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        is the C compiler version.  You should specify it
		if you have specified a compiler path in LSOF_CC.

		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 the lsof Configure
			 script to see how lsof_CCV is set by default.

LSOF_CFGF	may be used to specify additional configuration values
		that will appear in the CFGF string of the Makefile.

LSOF_CFGL	may be used to specify additional library specifications
		that will appear in the CFGL string of the Makefile.

LSOF_HOST       may be used to specify a value in lsof's -v output
		other than the name of the host where lsof was
		built.  A value of "none" inhibits host name display
		in -v output.

		default: the dialect's host name application -- e.g.,
			 hostname or uname -n

LSOF_INCLUDE    is the path to a tree of header files that is an exact
		image of the standard header file tree for the
		target dialect.  You may need to specify it if you
		want Configure to test header files in a tree different
		from /usr/include and compile its test programs with
		header files from that tree, then you want to compile
		lsof from the header files in that different, duplicate
		image tree.

		Note: LSOF_INCLUDE should contain a single path
		without any option flags, such as -I.  It is always
		supplied to the compiler in CFLAGS following the -I
		option flag.  If you want to specify other include
		paths, use LSOF_OPINC.

		ADDITIONAL NOTE: all the header files that lsof's
		Configure tests for optional features and uses to
		compile test programs must be in LSOF_CONFIGURE.
		They can't be scattered in the other include path
		that LSOF_OPINC names.

LSOF_LOGNAME    may be used to specify a value in lsof's -v output
		other than the one in the LOGNAME environment
		variable for the login name of the person who built
		lsof.  A value of "none" inhibits login name display
		in -v output.

		default: the LOGNAME environment variable

LSOF_MAKE	is the path to the make command.

		default: the output of `which make`, if it is not NULL;
			 otherwise the string "make".

LSOF_MKC        may be used to specify an alternate method of
		connecting dialect sources to the top-level lsof
		directory.  See 00PORTING for more information.

		default: ln -s

LSOF_OPINC	may be used to specify other include file search
		paths.  Each must be preceded by the compiler's -I
		option file and, if there are muliple paths, they
		must be separated by spaces and the entire set must
		be enclosed in double quote marks -- e.g.,

		LSOF_OPINC="-I/path1 -I/path2 ..."

		The optional include paths thus specified will be
		appended to LSOF_INCLUDE and whatever special
		include paths the lsof Configure script finds
		necessary.

LSOF_RANLIB	may be used to specify an alternate command for the
		randomizing of the lsof library.

		default: ranlib for most dialects
			 none for: IBM AIX; HP-UX; SCO OpenServer; Solaris
				   and SCO|Caldera UnixWare

LSOF_SYSINFO    may be used to specify a value in lsof's -v output
		other than the standard system identification --
		e.g., output from uname.  A value of "none" inhibits
		system information display in -v output.

		default: the dialect's standard system identification
			 application output -- e.g., uname, sysinfo

LSOF_USER	may be used to specify a value in lsof's -v output
		other than the one in the USER environment variable
		for the login name of the person who built lsof.
		A value of "none" inhibits login name display in
		-v output.

		default: the USER environment variable

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.

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

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.

		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
				  4.3.3		   4330
				  5.0.x		   5000
				  5.1.x		   5100
				  5.2.x		   5200
				  5.3.x		   5300
      darwin	  DARWIN	  1.2*		    120
				  1.3*		    130
				  1.4*		    140
				  5.[012]	    500
				  5.[3-9]	    530
				  6.x		    600
				  7.x		    700
				  8.x		    800
     freebsd	 FREEBSD	  1.x		   1000
				  2.x		   2000
				  2.0.5		   2005
				  2.1.x		   2010
				  2.2.x		   2020
				  3.x		   30x0
				  4.x		   40x0
				  4.1x		   41x0
				  5.x		   50x0
				  6.x		   60x0
				  7.x		   70x0
				  8.x		   80x0
				  9.x		   90x0
	hpux	    HPUX	  9.1		    901
     hpuxgcc	    HPUX	  9.5		    905
				  10.0		   1000
				  10.10		   1010
				  10.20		   1020
				  11.00		   1100
				  11.11		   1111
      linux	   LINUX	  2.1.x		  21xxx
				  2.2.x		  22xxx
				  2.3.x	     	  23xxx
				  2.4.x		  24xxx
				  2.6.x		  26xxx
     netbsd	  NETBSD	  1.2		1002000
				  1.3		1003000
				  1.4		1004000
				  1.5		1005000
				  1.6		1006000
				  2.0		2000000
				  2.99.9        2099009
				  2.99.10       2099010
    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
				  2.7		   2070
				  2.8		   2080
				  2.9		   2090
				  3.0		   3000
				  3.1		   3010
				  3.2		   3020
				  3.3		   3030
				  3.4		   3040
				  3.5		   3050
				  3.6		   3060
	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
				  3.2v5.0.6	    506
         ou	      OU	  8.0.0		  80000
    solaris      SOLARIS	  2.3		  20300
  solariscc	 SOLARIS	  2.4		  20400
				  2.5		  20500
				  2.5.1		  20501
				  2.6		  20600
				  7		  70000
				  8		  80000
				  9		  90000
				  10		 100000
	 uw	      UW	  7.0		  70000
	 	       		  7.1.0		  70100
	 	       		  7.1.1		  70101
	 	       		  7.1.3		  70103



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_ARCH		specifies the AIX architecture when the AIX version is
			5.0 or higher.  A value of "" signifies POWER; "ia64",
			64 bit x86 (Itanium).

			default: none (tested via `uname -a`)

AIX_HAS_AFS		specifies the state of AIX ADS support when the AIX
			version is 4.3.3 or lower.  (Lsof doesn't support AFS
			above AIX 4.3.3.)  A value of "" allows the Configure
			script to determine the AFS support state; "no",
			disables AFS support; and "yes", forces the enabling of
			AFS support.

			default: none (tested via presence of AFS files and the
				 lsof AFSConfig shell script)

AIX_KERNBITS		specifies the kernel bit size, 32 or 64, of the Power
			architecture AIX 5.x kernel for which lsof was built.

			default: determined by the Configure script with a test
				 program that uses <sys/systemcfg.h> macros.

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)

DARWIN_XNUDIR		If this environment variable has a value, the value is
			used as the path to the Darwin XNU kernel source code.

			default: none (entry requested)

DARWIN_XNU_HEADERS	If this environment variable has a value, the value is
			used as the path to the Darwin XNU kernel header files.
			This path would match the DSTROOT environment variable
			used when a "make installhdrs" was executed from the
			Darwin XNU kernel source directory.

			default: none

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_BASE		specifies the HP-UX lsof source code base, kmem or
			pstat, to be used.

			default: determined by testing for the
				 /usr/include/sys/pstat subdirectory

HPUX_BOOTFILE		specifies the file in which lsof's Configure script can
			find kernel information.  This specification may be
			useful for defining the path to a copy of /stand/vmunix
			that has been processed by pxdb or q4pxdb.

			default: /stand/vmunix

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_HASONLINEJFS	If this environment variable has a value of "Y" or "y",
			the HASONLINEJFS definition will be enabled in the
			Makefile CFLAGS.  That will cause dnode1.c to use an
			alternate vx_inode.h header file in the hpux11 sub-
			directory of dialects/hpux/kmem.

			default: determined using nm and grep

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_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_X25DIR		specifies path to the HP-UX X25 directory that contains
			configuration header files.

			default: /etc/conf

LINUX_CLIB		specifies the definition of the Linux C library:

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

LINUX_CONF_CC		specifies the location of the C compiler to use during
			the running of the Configure script:

			default: the value of the LSOF_CC variable, if defined,
				 or cc

LINUX_HASSELINUX	If this environment variable has a value of "Y" or "y",
			Configure unconditionally activates SELinux support.
			If it has any other value, Configure unconditionally
			inhibits SELinux support.

			Default: assumed to be "Y" if <selinux/selinux.h>
				 exists

LINUX_INCL		specifies the path to the header file tree:

			default: /usr/include

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

LINUX_VERSION_CODE	specifies the value of the LINUX_VERSION_CODE in the
			same decimal form as found in the LINUX_VERSION_CODE
			#define of /usr/include/linux/version.h:

			default: the value of LINUX_VERSION_CODE in
				 /usr/include/linux/version.h

NETBSD_SYS		specifies the path to the NetBSD system source
			directory.

			default: /usr/include

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

OPENBSD_UVM		If this environment variable has a value of "Y" or "y",
			the OpenBSD system uses the UVM virtual memory system;
			any other non-NULL value, it does not; a NULL value,
			it will be determined by examining /bsd.

			default: tested by grep'ping `nm /bsd` output


OSR_CFGF		The value of this environment variable is made the
			initial value for the compiler flags the lsof Configure
			script constructs for the Makefile CFGF macro.

			default: ""

OSR_CFGL		The value of this environment variable is made the
			initial value for the loader flags the lsof Configure
			script constructs for the Makefile CFGL macro.

			default: ""

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


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 a 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_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_INSTR		specifies the Sun C compiler target instruction set
			when building lsof for a 64 bit kernel -- i.e., when
			the Configure abbreviation is "solariscc".  Possible
			values include amd64 and sparcv9.  This is ignored when
			the Configure abbreviation is "solaris" -- i.e., the
			compiler is gcc.

			default: tested with /bin/isainfo -k

SOLARIS_KERNBITS	specifies the number of bits in the Solaris 7, 8, 9 or
			10 kernel: 32 or 64.

			default: tested with /bin/isainfo -kv

SOLARIS_VSOCK		If this environment variable has a 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

SOLARIS_VXFSINCL	This environment variable defines the path to the
			header files of the VxFS 3.4 or greater version.  If
			SOLARIS_VXFSINCL is not set, the default is used.

			default: VxFS < 4.0:
				    /opt/VRTSvxfs/include
				 VxFS 4.0 and above:
				    /opt/VRTSfssdk/<version>/include

SOLARIS_VXFSLIB		This environment variable defines the path to the
			VxFS 3.4 or greater utility libraries, libvxfsutil.a
			(32 bit) and libvxfsutil64.a (64 bit).  If
			SOLARIS_VXFSLIB is not set, the default is used.

			Note:  end SOLARIS_VXFSLIB at the "/lib" component; do
			       NOT put "/sparcv9" at its end.  The lsof
			       Configure script will add "/sparcv9" if it is
			       required; hence, if Configure finds that
			       "/sparcv9" is needed, your SOLARIS_VXFSLIB
			       directory tree must have a sparcv9 subdirectory.

			default: `dirname $SOLARIS_VXFSINCL`/lib

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.

			Note: the SunOS support is no longer maintained.

UW_HAS_NSC		If this environment variable has a value of "Y" or "y",
			lsof will be configured for a UnixWare 7.1.1 or above
			NonStop Cluster (NSC) system.

			default: tested via /bin/node_self

Vic Abell <abe@purdue.edu>
October 13, 2014
