win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key cheap Win 7 key win 7 professional Windows 7 key windows-7-ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key store Windows 7 Professional Product Key Windows-7-Ultimate-Product-Key windows-7-home-premium buy Windows 7 key Office-2013-key office-professional-plus-2013 Office-2010-key Office-2016-key windows 8 key windows-8-key-sale windows 8.1 key windows 8.1 product key windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key win 7 key Win 7 key product key Win 7 ultimate key Win 7 key sale Windows 7 professional windows 7 Pro key Windows 7 key windows 7 ultimate Windows 7 ultimate key Windows 7 product key Windows 7 key sale Windows 7 iso windows 7 home premium windows 7 home Office 2013 key Office 2013 Professional Office 2010 key office 2010 product key Office 2016 key office 2016 product key office 2016 pro key windows 8 key windows 8 key sale Windows 8 pro windows 8.1 key windows 8.1 product key windows 8.1 professional windows 10 key windows 10 product key Windows 10 product key Windows 10 Pro Product Key windows 7 home Windows 7 professional windows 7 pro windows 7 key Windows 7 professional windows 10 product key windows 10 key windows 8 key Windows 8.1 professional windows 8.1 pro office 2013 key office-2010 serial key office 2010 key windows 10 key windows 7 home premium windows 7 ultimate windows 8.1 key windows 8 professional windows 7 ultimate windows 7 key windows 7 home windows 7 activation key win 10 professional office 2010 key Windows 7 Product Key Windows 7 Key Windows 7 iso Windows 7 ultimate

A Very Basic Autotools Project

So recently I wanted to learn enough about Autotools so that I could convert a C++ project which I was working on into an Autotools project.  After searching and searching the internet, I finally came across enough information to make a basic, very vanilla project.

After creating that basic project I decided that I also wanted to add support for the Boost libraries.  So I figured that I would post the files for the basic project first here and then I would modify it to support boost and to post that project here as well.

The important Files

I had a hard time figuring this out, but an autotools project consists of a lot of files.  Most of these files are autogenerated and are not really necessary for you to know what they do, especially if all you want to do is create a simple project…etc.  So you really only need to worry about the following files:

  • configure.ac
  • Makefile.am
  • src/Makefile.am
  • your source files – put them under the src and include directories

What a very simple project looks like

  • configure.ac
  • Makefile.am
  • src/Makefile.am
  • src/main.cpp
  • include/my_include.h

How it works

So, how does autotools work? Well, if you go to the documentation on its homepage, you will have to read the entire documentation for autoconf, automake, aclocal, m4, libtool and a bunch of other components of autotools and only then will you know how it works.  Or, you can read my explanation here:

  1. Create configure.ac file
  2. Create Makefile.ac file
  3. Copy source files in
  4. Run “autoreconf -fvi”

Now your project is ready for use via the normal commands that you are used to using such as “./configure” and “make”… Let us start with creating our own project that contains one source file – “main.cpp” and one include file “my_include.h”

Project Format

./myProject/configure.ac
./myProject/Makefile.ac
./myProject/src/main.cpp
./myProject/src/my_include.h

configure.ac

dnl Comments are lines that begin with the letters "dnl"
dnl Comments that begin with # are also an option, and those
dnl comments will appear in the resulting configure script

dnl Specify required version of autoconf
AC_PREREQ([2.6])

dnl Set some parameters for our project
dnl Project Name - Version - Contact Email Address
AC_INIT([myProject], [1.0.0], [johnstratoudakis@gmail.com])

dnl Specify that we are using C++
AC_PROG_CXX

dnl Detect host operating system
dnl If we don't want to support an operating system
dnl we use "AC_MSG_ERROR" to cause our configure script
dnl to stop executing
AC_CANONICAL_HOST
case $host_os in
 darwin* )
 echo "OS X Platform"
 ;;
 linux* )
 echo "Linux Platform"
 ;;
 cygwin*)
 echo "Cygwin Platform"
 ;;
 *)
 echo "Unknown Platform"
 AC_MSG_ERROR([Your platform is not supported])
 ;;
esac

dnl Set some parameters for automake
dnl Note: These parameters are for automake, not make
dnl and the foreign parameter means that it is not using
dnl the standard autotools project format which includes
dnl several extra files and directories (files like README
dnl COPYING and similar)
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

dnl Tells autoconf which Makefiles need to be generated and
dnl it will search for files named Makefile.am in these locations
AC_CONFIG_FILES(Makefile src/Makefile)

dnl Tells autoconf to start creating the output. To be more specific
dnl it tells autoconf to generate and run config.status.
AC_OUTPUT

All you need to know is that the Makefile and src/Makefile files will be used for building your project. That means if you create a sub-directory in your source code, add that Makefile reference into this file. Now on to the actual Makefile.am files themselves

Makefile.am and src/Makefile.am

Your project needs to contain a Makefile.am at the root of each directory containing source files.  Now this is known as “recursive make”, which is bad.  I am not going to get into the reasons why at this time, but I will try to find an example which does not use recursive make in the future.

The Makefile.am file in the project root directory is simple, it only contains one line which is used to reference the Makefile in the src sub-directory:

# SUBDIRS specifies that automake should continue searching for
# more Makefile.am files in the directories listed below
SUBDIRS = src

The Makefile.am file in the src directory is a little longer

# bin_PROGRAMS specifies the name of an output binary
# which is to be created
bin_PROGRAMS = myProject

# _SOURCES specifies the required source files
myProject_SOURCES = main.cpp

# CPPFLAGS are parameters that will be passed to the
# compiler, in this case the inclusion of the include
# directory
myProject_CPPFLAGS = -I$(top_srcdir)/include

Now all you need to do to build your project is to execute the following:

autoreconf -fvi
./configure
make

And that’s it! Download the source here:

myProject.tgz

So recently I wanted to learn enough about Autotools so that I could convert a C++ project which I was working on into an Autotools project.  After searching and searching the internet, I finally came across enough information to make a basic, very vanilla project.

After creating that basic project I decided that I also wanted to add support for the Boost libraries.  So I figured that I would post the files for the basic project first here and then I would modify it to support boost and to post that project here as well.

The important Files

I had a hard time figuring this out, but an autotools project consists of a lot of files.  Most of these files are autogenerated and are not really necessary for you to know what they do, especially if all you want to do is create a simple project…etc.  So you really only need to worry about the following files:

  • configure.ac
  • Makefile.am
  • src/Makefile.am
  • your source files – put them under the src and include directories

What a very simple project looks like

  • configure.ac
  • Makefile.am
  • src/Makefile.am
  • src/main.cpp
  • include/my_include.h

How it works

So, how does autotools work? Well, if you go to the documentation on its homepage, you will have to read the entire documentation for autoconf, automake, aclocal, m4, libtool and a bunch of other components of autotools and only then will you know how it works.  Or, you can read my explanation here:

  1. Create configure.ac file
  2. Create Makefile.ac file
  3. Copy source files in
  4. Run “autoreconf -fvi”

Now your project is ready for use via the normal commands that you are used to using such as “./configure” and “make”… Let us start with creating our own project that contains one source file – “main.cpp” and one include file “my_include.h”

Project Format

./myProject/configure.ac
./myProject/Makefile.ac
./myProject/src/main.cpp
./myProject/src/my_include.h

configure.ac

dnl Comments are lines that begin with the letters "dnl"
dnl Comments that begin with # are also an option, and those
dnl comments will appear in the resulting configure script

dnl Specify required version of autoconf
AC_PREREQ([2.6])

dnl Set some parameters for our project
dnl Project Name - Version - Contact Email Address
AC_INIT([myProject], [1.0.0], [johnstratoudakis@gmail.com])

dnl Specify that we are using C++
AC_PROG_CXX

dnl Detect host operating system
dnl If we don't want to support an operating system
dnl we use "AC_MSG_ERROR" to cause our configure script
dnl to stop executing
AC_CANONICAL_HOST
case $host_os in
 darwin* )
 echo "OS X Platform"
 ;;
 linux* )
 echo "Linux Platform"
 ;;
 cygwin*)
 echo "Cygwin Platform"
 ;;
 *)
 echo "Unknown Platform"
 AC_MSG_ERROR([Your platform is not supported])
 ;;
esac

dnl Set some parameters for automake
dnl Note: These parameters are for automake, not make
dnl and the foreign parameter means that it is not using
dnl the standard autotools project format which includes
dnl several extra files and directories (files like README
dnl COPYING and similar)
AM_INIT_AUTOMAKE([-Wall -Werror foreign])

dnl Tells autoconf which Makefiles need to be generated and
dnl it will search for files named Makefile.am in these locations
AC_CONFIG_FILES(Makefile src/Makefile)

dnl Tells autoconf to start creating the output. To be more specific
dnl it tells autoconf to generate and run config.status.
AC_OUTPUT

All you need to know is that the Makefile and src/Makefile files will be used for building your project. That means if you create a sub-directory in your source code, add that Makefile reference into this file. Now on to the actual Makefile.am files themselves

Makefile.am and src/Makefile.am

Your project needs to contain a Makefile.am at the root of each directory containing source files.  Now this is known as “recursive make”, which is bad.  I am not going to get into the reasons why at this time, but I will try to find an example which does not use recursive make in the future.

The Makefile.am file in the project root directory is simple, it only contains one line which is used to reference the Makefile in the src sub-directory:

# SUBDIRS specifies that automake should continue searching for
# more Makefile.am files in the directories listed below
SUBDIRS = src

The Makefile.am file in the src directory is a little longer

# bin_PROGRAMS specifies the name of an output binary
# which is to be created
bin_PROGRAMS = myProject

# _SOURCES specifies the required source files
myProject_SOURCES = main.cpp

# CPPFLAGS are parameters that will be passed to the
# compiler, in this case the inclusion of the include
# directory
myProject_CPPFLAGS = -I$(top_srcdir)/include

Now all you need to do to build your project is to execute the following:

autoreconf -fvi
./configure
make

And that’s it! Download the source here:

myProject.tgz

Leave a Comment