General guide to build and install
==================================

Some packages can have their own requirements and installation details,
see appropriate README and INSTALL files of that packages.


For impatients:

	tar -xzf SOMEWHERE/PACKAGE-M.N.tar.gz
	cd PACKAGE-M.N

	make config && make all
	su
	make install



Prerequisites
-------------

* GNU/Linux system;

* GNU make 3.76+;

* GNU C and C++ compilers 2.7.* - 2.95.3+ (maybe 2.96)
  and companion binutils;

* libc5 or libc6 (glibc2) with their include files (*-devel packages);

* GNU readline library and headers ("readline", "readline-devel" packages)
  (for some packages only);

* ncurses library ("ncurses" package) and headers ("ncurses-devel" package);

* Linux kernel 2.0.x - 2.4.x (for Linux kernel modules only);

* Linux kernel headers (for Linux kernel modules only)
  which are corresponding to target kernel with the same kernel build
  options exactly, generated for target kernel instance.
  If target machine is not a build machine, then you must obtain kernel
  headers generated for target kernel instance.
  If you don't know how to do this, don't even try to build kernel
  modules and ask your tech support.
  If target machine is the same as build machine then just ensure that
  package "kernel-headers" of current running kernel installed.
  On RedHat-7.x the "kernel-source" package should be installed instead
  of "kernel-headers".



Preparation
-----------

Log in as ordinary user.

Unpack archive:
	tar -xzf SOMEWHERE/PACKAGE-M.N.tar.gz

where M.N is major and minor release numbers,
SOMEWHERE is directory with supplied archive.

'cd' to PACKAGE-M.N directory.



Configure
---------

	make config


Configuration stage is controlled by environment variables.
List almost all of environment variable names and their values:

env. var.	default value		note
--------------	----------------	--------------------------------
prefix		/usr/local
lkmod_prefix			|	kernel modules will be installed in
				|	$lkmod_prefix/lib/modules/VERSION/
				|	misc/ directory
exec_prefix	$prefix
bindir		$exec_prefix/bin
libdir		$exec_prefix/lib
includedir	$prefix/include
devdir		/dev

CC		gcc or  kgcc		C   compiler
CXX		g++ or 'kgcc -xc++'	C++ compiler
CPP		$CC -E			C   preprocessor
CXXPP		$CXX -E			C++ preprocessor
AS		as			assembler
LD		ld			linker
GENKSYMS	genksyms		for kernel modules only
MAKE		make

CPPFLAGS			|	these variable values are appended
CFLAGS				|	to end of Makefile flag variables
CXXFLAGS			|	so user supplied flag values
LDFLAGS				|	overrides a Makefile defaults

INCDIRS					space-separated list of extra
					include file directories
					(use absolute paths only)

OPTIMIZELEVEL	3			-O flag value
--------------	----------------	--------------------------------


Complex example:

CC=/usr/local/gcc/2.95.3/bin/gcc CXX=/usr/local/gcc/2.95.3/bin/g++ \
OPTIMIZELEVEL=9 \
INCDIRS=~/linux-include/2.2.19 prefix=/usr/local/stow/some-application-1.1 \
make config

Don't forget to check completion status of last command and do not
proceed if error encountered.


Build
-----
	make all


Install
-------

Become root:
	su

Install headers, libraries, utilities, kernel modules, documents:
	make install

Everything except the kernel modules installed in /usr/local tree by
default, use 'prefix' environment variable at 'make config' stage to
change this.

Linux kernel modules should be loaded by "/sbin/insmod" command by user.
If "insmod" fails with error "Unresolved symbols ..." this mean that you
have build modules with kernel headers which are not correspond to target
kernel.

What should be done for loading driver automatically on system boot
depends from Linux distribution:

RedHat-derived:
	place the line with 'insmod' command into one of start
	scripts, /etc/rc.d/rc.modules is appropriate place for it.

Debian-derived:
	add new line with driver name to file /etc/modules;

	for driver with parameters create new file
	/etc/modutils/DRIVER-NAME
	with line 'options DRIVER-NAME io=0xNNN,0xNNN'
	where 0xNNN is base addresses of boards 0,1, ...;

	run 'update-modules' script.


Uninstall
---------

Removes headers, libraries, utilities, kernel modules, documents:
	make uninstall

You need set 'prefix' env. var. if you call 'make uninstall' from
misconfigured source directory:
	prefix=/usr/local make uninstall

