Getting to know the CDT Autotools Plug-in
by the editorial team
This tip article has been edited and republished from its original location.
by Jeff Johnston
|
The Autotools plug-in is a Red Hat initiative to allow existing open source C/C++ projects to be maintained using the Eclipse CDT (C/C++ Development Tooling). The plug-in is previewed in the Red Hat Developer Suite (RHDS) 3 product. It extends the Eclipse CDT and adds features needed by C/C++ projects that use Autotools and have a configuration step. Such projects perform tests at configuration time that ultimately determine how to construct the This article reviews various features of the plug-in and how they are used. Some familiarity with the CDT is assumed. Dynamic examples are provided that show how to perform various tasks. To begin, check out a known Autotools project that is reasonably complex. For example, the newlib C library can be checked out from CVS as follows (using anoncvs for the password): cvs -z 9 -d :pserver:sources.redhat.com:/cvs/src login cvs -z 9 -d :pserver:sources.redhat.com:/cvs/src co newlib Newlib is an embedded-platform C library that can be configured to run on many platforms. This examples builds it natively on an i686 Linux platform under Eclipse. Therefore, only a native toolset needs to be installed: After checking out As seen in Figure 1, configuration settings for the project are now settable. A build directory can now be specified, which defaults to the Once the configuration settings are done, build the project. Run After the build is complete, an additional console is available that contains the results of the configuration step, as shown in Figure 3. These results are useful for analyzing any configuration decisions that may affect the build. For example, it shows when the configuration step chooses the wrong compiler due to the execution path. The console can be displayed by clicking on the Console icon in the console window. Clicking on the down arrow beside it shows the other consoles that are available. As part of the Autotools plug-in, a default Gnu C/C++ error parser is designated. This parser gets invoked on the results of the GNU make invocation and is used to determine errors and warnings, as shown in Figure 4. For example, it finds any Note: The CDT Project Menu build action is set up for basic projects that have simple To build the various targets that are available, use the new menu item Build Special Targets in the Project menu, as shown in Figure 5. This menu item is only activated for an Autotools project. Clicking the item brings up the Build Special Targets dialog that represents the top-level To browse the source code, pick a C source file through the Navigator view. Click through the tree to find the file, then double-click it. This opens the file in the editor window and creates an outline view in the Outline window. To see the source for the included header files, the Autotools plug-in has special logic to parse the When a header file also includes another header file, Autotools treats such a nested header file the same as it did for the first-level header file. It uses the include path and define symbols from the originating C/C++ source file. These attributes get chained together to handle any number of nested levels. It is dependent on the originating source file. If a header file is needed in the context of a different source file, the new source file must be opened and then the header file must be reached by double-clicking in the Outline view again. At present, there is no way to see a header file in multiple contexts. Opening a header file directly from the Navigator does not have a source-context and the Project static include path and project directories might have to be searched. If the header file exists in multiple places for such a search, a dialog pops-up that displays the possible choices. An interesting feature of the CDT is that even with indexing off, the CDT analyzes the source code when it displays an outline in the Outline view. This analysis is not extensive but incorporates knowledge of external defined symbol flags as well as macros defined within that file, shown in Figure 6. In the example with This project example demonstrates other interesting features of Autotools. In the default mode, when rebuilding, the configuration step is fast-tracked using the top-level config.status, meaning the project is not manually configured each time. Changing the configuration for a single build is done through the Project Properties menu under configuration settings, shown in Figure 8. When the changes are confirmed using the Apply or Ok buttons, the Autotools plug-in compares the new configuration to the old one. If any change has been made, a subsequent build causes full configuration to occur. For helping in coding C Library functions, hover help has been added. The hover help is generated from the To aid in analyzing Autotool projects, online help has been added for various gnu tools. These include
About the author |
Figure 1: Converting to an Autotools project demonstration (GIF animation 3.1M, opens in new window) |
Copyright (C) by 2006 Red Hat Inc. This article is licensed under a Creative Commons Attribution 2.5 License (CC BY-SA): http://creativecommons.org/licenses/by-sa/2.5/.





