$Id: INSTALL,v 1.15 2003/03/10 16:31:19 mikpe Exp $

		    INSTALLATION INSTRUCTIONS
		    =========================

KERNEL
------
The kernel source code of this package consists of two parts:
the driver proper, and patches to integrate it into various
versions of the kernel.

The recommended kernel build and installation procedure is as follows:

1. Get the source code for the kernel of your choice, and unpack it
   in some directory.

   Let KDIR be the root directory of the kernel source, and PDIR be
   the root directory of the unpacked perfctr package.

   Supported kernel versions are those that have a corresponding patch
   file in $PDIR/patches/. Currently, supported kernels include
   standard kernels from www.kernel.org and some RedHat update kernels.
   The naming convention is that patches for RedHat kernels include a
   "-redhat" suffix in their names.

   ** Using this package with a kernel not listed in $PDIR/patches is
   ** UNSUPPORTED. You are strongly advised to choose a supported kernel.

   ** RedHat users: Please note that RedHat kernels are extensively
   ** modified compared to their baseline standard kernels, and that
   ** patches for standard kernels often do NOT work for RedHat kernels
   ** even if the version numbers are similar. If your current kernel
   ** is unsupported, then upgrading to a newer RedHat "update" kernel
   ** may be required.

   In your shell, `cd' to $KDIR.

   Save a copy of the .config file if it exists and you need it later.
   Then `make mrproper' (this is VERY important).

2. Apply all patches for all add-on features you want in this kernel.

   With the current directory being $KDIR, execute:

	$PDIR/update-kernel

   This will apply the patch file that matches the kernel version,
   and install the new files for the perfctr driver.

   If update-kernel does not find a matching patch file, it will fail
   with an error message. If you insist on using an unsupported kernel
   version V1, but you believe the patch file for version V2 will work,
   then you can try it as follows:

	$PDIR/update-kernel --test --patch=$V2

   This applies the patch in testing mode, without actually altering
   any files. If the patch applies cleanly without any rejects, then
   you can force the use of this patch simply by removing the --test
   option to update-kernel. This usage mode is intended for experienced
   kernel builders only.

   Finally, edit $KDIR/Makefile and change EXTRAVERSION to include
   something unique for THIS kernel, for example by appending "-perfctr"
   (without the quotes). While not strictly necessary, this step is
   strongly recommended if you are adding the perfctr driver to
   a kernel version which is already installed on the machine.

3. If you have a saved .config file, copy it to $KDIR.
   Then configure the kernel using your favorite kernel configuration tool,
   for instance `make menuconfig', `make config', or `make oldconfig'.

   You should either configure with modules (CONFIG_MODULES=y) AND module
   versions (CONFIG_MODVERSIONS=y), or completely without modules
   (CONFIG_MODULES=n). Modules without module versions is an inherently
   unsafe configuration which is not recommended.

   You should also enable at least CONFIG_PERFCTR, CONFIG_PERFCTR_VIRTUAL,
   and CONFIG_PERFCTR_GLOBAL.

   You may also select CONFIG_PERFCTR=m to build the bulk of the driver
   as a loadable kernel module; the module will be named `perfctr'.

   Note: The perfctr kernel patch adds one word to the `thread_struct'
   type, which makes the patched kernel binary incompatible with an
   unpatched one. This is why it is important to distinguish the patched
   kernel via EXTRAVERSION and CONFIG_MODVERSIONS.

4. `make dep vmlinux modules'. This compiles the kernel and its modules.

5. As root, `make modules_install' to install the modules under /lib/modules/.

6. As root, edit /etc/lilo.conf to include a new entry for the new kernel.
   Copy an existing entry and edit the image= and label= lines to reflect
   the new kernel's name, including whatever you put in EXTRAVERSION.
   Then `make install' to install the new kernel's boot image and update
   the boot loader.

   Non-LILO users will have to adapt this step to whatever boot method
   they are using.

7. Reboot the machine.


DEVICE FILE
-----------
The global-mode perfctr facility is implemented as a character device
driver, which has been assigned major number 10 and minor number 182.
The first time you install the package, a special file representing
this device must be created. As root, execute:

	mknod /dev/perfctr c 10 182
	chmod 644 /dev/perfctr

If the driver was built as a module, it will be have to be loaded
into the kernel before it can be used. This will happen automatically
if the kernel was built with support for the kernel module loader
(CONFIG_KMOD=y), and you add the following to /etc/modules.conf:

	alias char-major-10-182 perfctr


LIBRARY
-------
To build the user-space library and the example programs, simply run

	make

The source code directory of the patched kernel you built and installed
above does not have to be available when you build the library.

To install the user-space library, the include files, and the 'perfex'
application program, run

	make PREFIX=$PREFIX install

This will install binaries in $PREFIX/bin, libraries in $PREFIX/lib,
and include files in $PREFIX/include. Each of these destinations can
also be overridden individually:

	make BINDIR=$BINDIR LIBDIR=$LIBDIR INCLDIR=$INCLDIR install
