I have a fairly large program written in C. It spans several files, and has a bit of retooling in order to attempt to compensate for platform issues. Specifically, I have header files for different OSes, architectures, and compilers that define macros that it uses to handle things. As an example, the -v
flag prints version info, including the name of the compiler that built it, and the operating system and architecture it was built on. As an example of why it's important, the program can create a C code file and, if you like, compile it - a task for which it simply makes a system call to whatever compiler it was built with.
It also has support for the GNU Readline library (or the BSD Editline library - same thing) if it is found on your system, as well as an equivalent without all the nice Readline features that is pure ANSI if you don't have it.
The bottom line is, I can't take out any of the platform-dependent bits, as several functions depend rather heavily on what OS/architecture/compiler you have. I also want to provide good functionality to those who have it. And I want people to download and install it with a standard ./configure
, make
and make install
interface.
Currently I'm using a sorry handmade shell script for configure
that creates the Makefile from scratch, and determines which header files to include based on your OS/architecture/compiler. I'd like a more efficient approach, and I'd like to use a more standard build system using GNU Autotools. That way I know that what I do will work on someone else's computer without having to go around testing it on their computers.
My question, for those of you who've slogged through all of that (thank you!), is: 1) How do I go about switching from a homebrew build system to GNU Autotools? 2) What good tutorials are there for getting started with GNU Autotools? 3) How can I make this a relatively painless process?
First thing, you can run autoscan in the project's root directory. It will scan the project tree and generate configure.scan, while trying to detect non-portable features. Then you rename it to configure.ac, edit it accordingly and write Makefile.am files.
I suggest you look up this process (especially autoscan) in the GNU autotools manual for the details. It will reduce your effort, but at least you won't start from scratch with creating those files.
This link is what I googled for after reading this post. It answered my questions about how to create the ./configure file.
The GNU Build System
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With