This post has a simple bash script to create a basic Hello World autotools project with a single command. The justification for this autotools script is I’ve not seen a consolidated script that keeps it simple in one place. The script creates a boiler plate autotools hello world project. Here is what it does:
Creation of configure.ac with project name, version, and email
Creation of root Makefile.am which just points to the src/Makefile.am
Creation of src/Makefile.am which will make a binary and has a single source file main.c
Creation of a autogen.sh which will run autoreconf --install
Creation of a .gitignore so we know what autotools files should be under version control
Creation of a main.c which just prints “hello world” to stdout.
After we have created the files above all we need to do is run a ./autogen.sh and our project will be ready to run the infamous ./configure, make and make install.
To create the project we can run our script by adding the project name. For this example let’s call the project autotools_helloworld. This will create a binary called autotools_helloworld withour source in main.c. and create an autotools hello world project. Below is an example usage of the script to create the project, generate the autotools scripts, configure, make and run the program.
Here is the script which I named atprj. This is short for “Autotools Project”.