Proceedings of the FREENIX Track: 2002 USENIX Annual Technical Conference
Total Page:16
File Type:pdf, Size:1020Kb
USENIX Association Proceedings of the FREENIX Track: 2002 USENIX Annual Technical Conference Monterey, California, USA June 10-15, 2002 THE ADVANCED COMPUTING SYSTEMS ASSOCIATION © 2002 by The USENIX Association All Rights Reserved For more information about the USENIX Association: Phone: 1 510 528 8649 FAX: 1 510 548 5738 Email: [email protected] WWW: http://www.usenix.org Rights to individual papers remain with the author or the author's employer. Permission is granted for noncommercial reproduction of the work for educational or research purposes. This copyright notice must be included in the reproduced paper. USENIX acknowledges all trademarks herein. Overhauling Amd for the '00s: A Case Study of GNU Autotools Erez Zadok Stony Brook University [email protected] Abstract Asking users to manually configure a package prior to compilation by editing a header file to turn on The GNU automatic software configuration tools, Au- or off package features or to specify services avail- toconf, Automake, and Libtool, were designed to help able from the platform on which the package will the portability of software to multiple platforms. Such be run. This process required intimate knowledge autotools also help improve the readability of code and of the system on which the package (e.g., C-News) speed up the development cycle of software packages. was to be built. In this paper we quantify how helpful such autotools are Trying to achieve portability using CPP macros to the open-source software development process. We and nested #ifdef statements. Such code results study several large packages that use these autotools and in complex, system-specific, deeply-nested CPP measure the complexity of their code. We show that total macros which are hard to maintain. code size is not an accurate measure of code complex- ity for portability; two better metrics are the distribution Using Imake [2], a system designed specifically of CPP conditionals in that code and the number of new for building X11 applications. Imake defines special-purpose Autoconf macros that are written for the frozen configurations for various systems. How- package. ever, such static configurations cannot account for We studied one package in detail—Am-utils, the local changes made by administrators. Berkeley Automounter. As maintainers and developers Using Metaconfig [11], developed primarily for of this package, we tracked its evolution over ten years. building Perl. This system executes simple tests This package was ported to dozens of different platforms similar to Autoconf, but users are often asked to and in 1997 was converted to use GNU autotools. We confirm the results of these tests or to set the re- show how this conversion (autotooling) resulted in a dra- sults to the proper values. Metaconfig requires too matic reduction in code size by over 33%. In addition, much user interaction to select or confirm detected the conversion helped speed code development of the features and it cannot be extended as easily as Au- Am-utils package by allowing new features and ports to toconf. be integrated easily: for the first year after the conversion to GNU autotools, the Am-utils package grew by over GNU Autoconf [5] solves the above problems by pro- 70% in size, adding many new features, and all without viding canned tests that can dynamically detect various increasing the average code complexity. features of the system on which the tests are run. By actually testing a feature before using it, Autoconf and its sister tools Automake [6] and Libtool [7] can build 1 Introduction packages portably without user intervention. These au- tomated software configuration tools (autotools [10]) can Large software packages, especially open-source (OSS) run on numerous systems. Autotools work identically re- ones, must be highly portable so as to maximize their use gardless of the OS version, any local changes that admin- on as many systems as possible. Past techniques for en- istrators installed on the system, which system software suring that software can build cleanly and run identically packages were installed or not, and which system patches on many systems include the following: were installed. The rest of this paper is organized as follows. Section 4. Shared libraries: Many packages need to build and 2 explains the motivation for automated software config- use shared or static libraries. Such packages of- uration tools. In section 3 we explain how GNU Auto- ten support shared libraries only on a few systems conf and associated tools work, explore their limitations, (e.g., Tcl before it was autotooled), because of dif- and describe how we used these tools. Section 4 eval- fering shared library implementations. Frequent use uates several large OSS packages and details the use of of non-shared (static) libraries results in duplicated autotools in the Am-utils package. We conclude in Sec- code that wastes disk space and memory. tion 5. 5. Human errors: Manually-configured software is more prone to human errors. For example, the 2 Motivation first port of Amd to Solaris on the IA32 platforms copied the static configuration file from the SPARC When software packages grow large and are required to platform, incorrectly setting the endianness to big- work on multiple platforms, they become more difficult endian instead of little-endian. to maintain without automation. We spent several years 6. Novice and overworked administrators: With a maintaining Amd and Am-utils, as well as fixing, port- rapidly growing user base and the growth of the In- ing, and developing other packages. During that time ternet, the average expertise of system administra- we noticed how difficult it was to maintain and port such tors has decreased. Overworked administrators can- packages and that led us to convert Amd to use autotools. not afford to maintain and configure many packages As a result of the conversion, we noticed that Am-utils manually. became easier to maintain and port. We therefore set out to quantify this improvement in the portability and main- Converting OSS packages to use GNU autotools— tainabilty of the Am-utils package, and those investiga- Autoconf [5], Automake [6], and Libtool [7]—addresses tions led to writing this paper. the aforementioned problems in five ways: There are six reasons why porting such packages to new platforms, adding new features, or fixing bugs be- 1. Standard tests: Autoconf has a large set of stan- comes a difficult task more suitable for automatic con- dard portable tests that were developed from practi- figuration: cal experiences of the maintainers of several GNU packages. Autoconf tests for features by actually 1. Operating system variability: There are more exercising those features (e.g., compiling and run- Unix systems available today, with more minor re- ning programs that use those features). Packages leases, and with more patches. Flexible software that use Autoconf tests are automatically portable packaging allows administrators to install selective to all of the platforms on which these tests work. parts of the system, increasing variability. An auto- 2. Consistent names: Autoconf produces uniform mated build process can track small changes auto- macro names that are based on features. For ex- matically, and can even account for local changes. ample, code which uses Autoconf can test if the 2. Code inclusion and exclusion: To handle system supports a reliable memcmp function us- platform-specific features, large portions of code ing #ifdef HAS MEMCMP, rather than depend- are often surrounded by #ifdef directives. ing on system-specific macros (e.g., #ifndef Platform-specific code is mixed with more generic SUNOS4). Autoconf provides a single macro per code. Often, system-specific source files are com- feature, reducing the need for complex or nested piled on every system, because there is no automatic macro expressions. This improves code readability way to compile them conditionally. and maintainability. 3. Multi-level nested macros: To detect certain 3. Shared libraries: By using Libtool and Automake features reliably, older code uses deeply nested along with Autoconf, a package can build shared or #ifdef directives. This results in complex macro static libraries easily, removing a lot of custom code expressions designed to determine features as re- from sources and makefiles. liably as possible. The main problem with such 4. Human factors: Building packages that use auto- macros is that they provide second-hand or anec- tools is easy. Administrators are becoming increas- dotal knowledge of the system. For example, to test ingly familiar with the process and the standard set if a compiler supports “void *”, some code depends of features autotools provide (i.e., run ./config- on the name of the compiler (GNUC) rather than ure and then make). Administrators do not need directly testing for that feature’s existence. to configure the software package manually prior to compilation and they are likely to make fewer mis- #include "confdefs.h" takes. This standardization speeds up installation char bzero(); /* forward definition */ and configuration of software. int main() bzero(); 5. Extensibility: Finally, software maintainers can ex- return 0; tend Autoconf by writing more tests for specific ¡ needs. For example, we wrote specific tests for the Am-utils package that detect its interaction with If the program compiles and links successfully, certain kernels. This allowed us to separate the the configure script defines a CPP macro named common code from the more difficult-to-maintain HAVE BZERO in an automatically-generated configura- platform-specific code. tion file named config.h. This macro is based on the existence of the feature and can be used reliably in the sources for the package. Note that it is not necessary to Our experiences with maintaining the Amd package run this program to determine if bzero exists. In fact, clearly show the benefits of autotools. When we con- the above program will fail to run properly because the verted the Amd package [9, 12] to use autotools, the code bzero function was not given proper parameters.