920 923




Linux Unleashed, Third Edition:Working with the Kernel





-->















Previous
Table of Contents
Next




Adding Drivers to the Kernel
You may want to link in new device drivers or special software to the kernel without going through the upgrade process of the kernel itself. This is often necessary when a new device such as a multiport board or an optical drive is added to the system and should be loaded during the boot process. Alternatively, you may be adding special security software that must be linked into the kernel.

The add-in kernel software usually has installation instructions provided, but the general process is to locate the source in a directory that can be found by the kernel recompilation process (such as /usr/src). To instruct the make utility to add the new code to the kernel, modifications are often needed to the Makefile. These may be performed manually or by an installation script. Some software has its own Makefile supplied for this reason.
Then, the kernel recompilation is begun with the new software added in to the load. The process is the same as shown in the section above, with the kernel installed in the boot location or set by LILO. Typically, the entire process takes about 10 minutes and is quite trouble-free, unless the vendor of the kernel modification did a sloppy job. Make sure that the source code provided for the modification will work with your version of the Linux kernel by reading any text files that accompany the code as well as the software compatibility files included with most distributions of Linux.
Upgrading Libraries
Most of the software on a Linux system is set to use shared libraries (a set of subroutines used by many programs). When you see the message



Incompatible library version


display after you have performed an upgrade to the system and you try to execute a utility, it means that the libraries have been updated and need to be recompiled. Most libraries are backward-compatible, so existing software should work properly even after a library upgrade.

Library upgrades are less frequent than kernel upgrades, and you can find them in the same places. Usually there are documents that guide you to the latest version of a library or there may be a file explaining which libraries are necessary with new versions of the operating system kernel.
Most library upgrades are gzipped tar files, and the process for unpacking them is the same as for kernel source code except the target directories are usually /lib, /usr/lib and /usr/include. Usually, any files that have the extension .a or .aa go in the /usr/lib directory. Shared library image files, which have the format libc.so. version are installed into /lib.
You may have to change symbolic links within the file system to point to the latest version of the library. For example, if you are running library version libc.so.4.4.1 and upgraded to libc.so.4.4.2, you must alter the symbolic link set in /lib to this file. The command is


ln -sf /lib/libc/so/4/4/1 /lib/libc.so.4


where the last name in the link command is the name of the current library file in /lib. Your library name may be different, so check the directory and release or installation notes first.
You will also have to change the symbolic link for the file libm.so. version in the same manner. Do not delete the symbolic links, because all programs that depend on the shared library (including ls) will be unable to function.
The Linux C Compiler
Linux uses a C compiler for every compilation of the kernel (and most utilities, too). The C compiler that is available for all versions of Linux is the GNU C compiler, abbreviated gcc. This compiler was created under the Free Software Foundation’s programming license and is therefore freely distributable.
The GNU C Compiler that is packaged with the Slackware Linux distribution is a fully functional ANSI C-compatible compiler. If you are familiar with a C compiler on a different operating system or hardware platform you will be able to learn gcc very quickly.
The GCC compiler is invoked by passing it a number of options and one or more filenames. The basic syntax for gcc is


gcc [options] [filenames]


The operations specified by the command line options will be performed on each of the files on the command line. There are well over 100 compiler options that can be passed to gcc. You will probably never use most of these options, but some of them you will use on a regular basis.
Many of the gcc options consist of more than one character. For this reason, you must specify each option with its own hyphen. You cannot group options after a single hyphen as you can with most Linux commands. For example, the following two commands are not the same:


gcc -p -g test.c
gcc -pg test.c


The first command tells gcc to compile test.c with profile information (-p) and also to store debugging information with the executable (-c). The second command simply tells gcc to compile test.c with profile information for the gprof command (-pc).



Previous
Table of Contents
Next














Wyszukiwarka

Podobne podstrony:
Brother Fax 910, 920, 921, 930, 931, 940, 945, MFC
920 05
920 03
923 (2)
920 15 (2)
920 10
920 11 (2)
920 17

więcej podobnych podstron