Automake and Autoconf discover the state of the target environment


Automake/Autoconf

Open source software is designed to be distributed in source code form so that it can be compiled for the target platform. When target platforms were diverse, this made perfect sense, because there was no way for a binary to work on a wide range of targets. For example, one key part of the target system was the C library. Most open source software is written in C; when compiled, the binary attempts to use the C library on the target system. If the C library used for compilation wasn’t compatible with the library on the target system, the software wouldn’t run. To make sure the software could be compiled on a wide range of systems, open source software developers found themselves doing the same sort of work, such as detecting the existence of a function or the length of a buffer in order to compile properly. For a project to be widely adopted, not only did it need to work, but users also needed to be able to compile it easily. The Automake and Autoconf projects solve the problem of discovering the state of the target environment and creating make files that can build the project. Projects using Automake and Autoconf can be compiled on a wide range of targets with much less effort on the part of the software developer, meaning more time can be dedicated to improving the state of the software itself rather than working through build-related problems.

Packaging Systems

As Linux became more mainstream, distributions were developed. A distribution is a kernel and a group of programs for a root file system, and one of the things on the root file system is the C library. The increasing use of distributions means a user can compile open source software with the expectation that it will run on a computer with a certain target distribution. Distributions added another layer with the concept of packages. A package is a layer of indirection on top of an open source project; it has the information about how to compile the software it contains, thereby producing a binary package. In addition to the binaries, the package contains dependency information such as the version of the C library that’s required and, sometimes, the ability to run arbitrary scripts to properly install the package. Distributions typically built a group of packages as a set; you install a subset of those packages on your system. If you install additional packages, then as long as they come from the same set used to create the distribution, the dependencies are satisfied or can be satisfied by using other packages in the set. Several packaging systems are available. RPM (Red Hat Package Manager, now RPM Package Manager) and deb (the packaging system used by the Debian project first and then Ubuntu) are two of the more popular packages for desktop systems. Some embedded distributions use these packing systems to create a distribution for embedded targets. In some cases, it makes sense to use a packaging system; in this article, I cover what’s available for embedded developers and when using a packing system makes sense.

Patch

You hear a lot about patches when working with Linux. You may even make one or two yourself. A patch is nothing other than a file containing a unified diff, which is enough information that it can be used to non-interactively edit a file. This information is frequently referred to as a change set. The file to which the changes are applied is called the target file. Change sets can specify that lines can be changed, removed from, or added to the target. Although patches are typically created for text files, a patch can be created for a binary program as well. A patch is just a data file. To update the target files, another program must be used, and that program is patch. Created by the Perl guy Larry Wall, patch does the work of reading the patch file, locating the file to be edited, and applying the changes. Patch is clever in that it can apply changes even if the file to be patched is a little different than the one used to create the patch. You can create patches using the diff program, like so:

diff -Naur old-something new-something > patch-file

However, many source code control systems generate a patch based on the current contents of your directory versus what’s stored in the source code control repository. No matter how you create your patch, applying it works the same:

patch < patch-file

If the patch program can’t make the changes requested, it produces error messages and creates reject files so you can see where things went wrong.

Make

Make is a core underpinning of open source software. It works by scanning a list of rules and building a dependency graph. Each rule contains a target, which is usually a file and a list of dependencies. A dependency can be either another target or the name of a file. Make then scans the file system to determine what files aren’t present and figures out what targets to run in what order to create the missing files. Make has been around since 1977 and has been rewritten several times. The version used on Linux systems is GNU Make. Make uses a combination of a terse syntax in conjunction with many preset defaults, such that the way a make file works is nearly magic. Consider this:

mybinary: file1.c file2.c

This is sufficient to give make the proper instructions to compile the file mybinary.c into the executable mybinary. The defaults tell make how to compile and link a C file from the files in the make rule. Using make for embedded development isn’t much different from using make for desktop development. One big difference is that when you’re doing embedded development, you need to tell make to invoke a cross-compiler or compile under emulation. In the previous example, it’s as simple as this:

LD=arm-linux-ld
   CC=arm-linux-gcc
   mybinary: file1.c file2.c

Although this is the simplest approach, it can probably be done more elegantly so that changing the compiler requires fewer changes to the make file. I dedicate time to creating make files so you can use a different compiler with minimal impact. Using make along with your favorite editor is all you need to do embedded development. IDE tools like KDevelop and Eclipse scan the project to create a make file that is then executed to perform a build. You may decide to use an IDE, but having a firm understanding of what’s happening under the covers is important when you’re working with other open source projects or creating automated builds.

Legal Disclaimer

Our website is not responsible for the information contained by this article. Articleinput.com is a free articles resource thus practically any visitor can submit an article. However if you notice any copyrighted material, please contact us and we will remove the article(s) in discussion right away.

Note: This article was sent to us by: Randolph Meyers at 01212010

Related Articles

1. Unauthorized Execution of Programs or Commands
A perpetrator can exploit a vulnerability in a victim system that enables the perpetrator to run one or more rogue commands on that system. A clever perpetrator can the...

2. Free Software Licenses
The term Open Source was coined in an attempt to resolve the confusion surrounding the word free in "free software." The Open Source Initiative (OSI) was created in order...

3. History of Free Unix Software
This history is simplified and biased toward the most important elements in a Linux system. In the earliest days of computing, software was seen as little more ...

4. Denial of Service Attacks
Denial-of-service (DoS) attacks are reported to incident response teams more than any other type of attack. Misconceptions about denial-of-service attacks abound, howev...

5. How to Downgrade PSP to version 1.5 using PSP battery
Lots of users downgrade their PSP to version 1.5 in order to upgrade to higher version such 3.51,etc.,because with a refresh PSP with a version 3.03 or above,you can run ...

6. Software To Increase Online Store Sales
Motivate your potential customer to purchase your product online! Make your customers loyal, and prefer your store over the competition! Make them an individual offer bas...

7. So You Think You Know CRM Software
A year ago if someone asked me if I knew my way around the CRM Software Industry I would have confidently said yes, however, as it turns out the old saying the more you l...

8. Using Age Verification Software in Your Business
Article Summary - There are all sorts of reasons you might need to know the age of a patron at your business, such as if he or she is trying to buy cigarettes or a...