Source Code and Software

Source code is the human-readable instructions for building the actual machine code that makes up a program. You’ve probably already been exposed to some form of source code; if not, go look at a few files under /usr/src (assuming, of course, that you installed the source code as I recommended back in Chapter 3). While you don’t have to read source code, you should be able to recognize it.

Once you have a program’s source code, you build (or compile) the program on the type of system on which you want to run it. (Building software for a foreign platform via cross-compiling demands that you know much more about building software, and is not always possible.) If the software was written for an operating system sufficiently similar to what you’re building it on, you’ll create a working program. If the operating system differs too much, either the build fails or the resulting software won’t run. Once you’ve built the software successfully on your system, you can copy the resulting program (or binary) to other systems on the same platform, with the same operating system version and supporting software, and expect it to run.

Some programs are sufficiently well written that you can compile them on many different platforms. A few programs specifically include support for widely divergent platforms. For example, you can compile the Apache web server on Windows, NetWare, and Unix-like platforms by typing make install. This is quite uncommon, however, and takes considerable effort on the part of the software authors. It also makes the code more complex, and supporting all these operating systems means that it cannot easily support all the features that make those operating systems special. (But note that the ability to build software on a variety of platforms doesn’t necessarily mean that it runs well on all of those platforms.)

Generally speaking, if you can build a program from source, it usually runs. A sufficiently experienced sysadmin can use the source code and error messages to learn why a program won’t build, or why it builds but doesn’t run. In many cases, the problem is simple and can be fixed with minimal education.[34] This is one reason why access to source code is important.

Back when every sysadmin was a programmer, debugging software builds absorbed major portions of the sysadmin’s time. Every Unix-like platform was slightly (or wildly) different. To build programs, sysadmins needed to understand their platform, the software’s original platform, and the differences between the two. The duplication of effort to build common programs was truly horrendous. Tools such as autoconf and configure were intended to help simplify this problem, but these programs just paper over the underlying problems. Building many software packages requires much more time running configure scripts than they need to actually compile.

The OpenBSD ports and packages system removes all this pain.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.186.153