IWTL How to Convert an Existing C/C++ Project (with Makefiles) to Autoconf/Automake
I'm one of several folks responsible for maintaining a project that's been around for a good number of years (since the late 1990's at least). I've been given the opportunity to make improvements to it wherever I see room for it. One of the most annoying parts of it is the build process for various systems, since it just uses Makefiles (written by hand, from what I understand of the project's history) to detect a few different platforms and adjust macros accordingly. For certain environments, including Cygwin, building is a chore.
I'd prefer to migrate it to GNU's autoconf/automake/libtool suite of tools to make building the thing much easier, and to expand the platforms the project is supported on (it does nothing platform-specific, and only needs to distinguish platforms at all because it deals in a binary file format and needs to know things like endianness and 32/64-bitness).
I've never used autoconf/automake before, though, so I know I'm in for an uphill climb. The basic distribution builds a series of libraries, and some demonstration/validation apps to go along with them. Ideally, the resulting configure script would provide options like "just build the library, ignore the demo apps." There are other side projects that make use of this one, and it'd be neat to take this new knowledge and use it to give them configure scripts as well, this time with a --with-foo=/path/to/foo argument to support out-of-source builds (right now, most side projects have to be dropped into this project's source tree to build right).
I have no clue where to start, though. Autoscan and autoheader look promising, but the GNU documentation for them is rather, erm, "thick and heavy" and quite tough to wade through as a beginner to the toolchain. Are there any pointers/tips folks could give me for converting a Makefile-based project to autoconf/automake/libtool? Am I just begging for pain & suffering by trying to do this?
Posted May 1, 2011, 6:26 PM UTC
Ask r/programming. But honestly, GNU make is in many (most?) respects still the best build system that's out there. Automake, scons, etc. just add layers of complexity, and the payback can be questionable. The only non-make build system I'd consider is redo, to be honest.
Hmmm... so it might just be worth cleaning up the existing Makefiles then and leaving other systems out of it?
You might have a point there :)
I'll look into redo as well; thanks for the pointer.
Adding things like autodiscovery of headers and libraries is a very tempting, pleasant-looking path down which lies only peril and madness. Maven serves as the grim spire from which all nascent build systems should steer their ships ceaselessly away.