This section describes general areas of investigation that can facilitate porting a UNIX-based application to the Linux platform.
Porting an application to run on another platform involves a source platform and a target platform. At the most basic level, the following question should be considered before doing any coding: What is being changed as part of the port to the target platform? A true port involves changing only the hardware and operating system.
In theory, well-written programs that do not rely on platform-specific dependencies, adhere to industry standards, such as POSIX, and conform to standard language definitions without employing nonstandard language extensions, can easily be ported to a new operating system with a minimum of extra work besides recompiling and debugging. When the source platform is a reasonably recent UNIX-based operating system, the changes may be confined to becoming more compliant with industry standards or with a newer version of the same standard. If the application is already running on a Linux system, you have the option to recompile it and run it natively. Many applications recompile and run without change.
Moreover, compiling an application with different standards-conforming compilers can drive out subtle weaknesses in the source code due to differences in the implementations of the language standards. The result is that the application becomes more robust.
Problems that arise in a porting exercise can be classified into internal and external portability issues. An internal portability issue deals with implicit assumptions that are intrinsic to the programming language. For example, C programs assume a particular byte order within integers, a set of relative sizes of integers, and a particular layout of fields within structures. Internal portability pertains to the relationship of the program code to the hardware. This class of porting problems is under a programmer's control.
On the other hand, external portability issues pertain to
the choice of external interfaces that a program uses, the semantics of these
interfaces that are assumed by the program, and the arguments and return
values that are passed to and from the program. They deal with
libraries and system calls that the program depends upon, code that is invoked
by, but external to, the program. External portability can be under a
programmer's control if the program uses standardized external
interfaces.