[FE training-materials-updates] labs/autotools-basics: new lab

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu May 21 14:39:54 CEST 2015


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=53872e715f76e7cd146d2bf0822afc29aebdc7de

>---------------------------------------------------------------

commit 53872e715f76e7cd146d2bf0822afc29aebdc7de
Author: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>
Date:   Thu May 21 14:39:25 2015 +0200

    labs/autotools-basics: new lab
    
    Signed-off-by: Thomas Petazzoni <thomas.petazzoni at free-electrons.com>


>---------------------------------------------------------------

53872e715f76e7cd146d2bf0822afc29aebdc7de
 labs/autotools-basics/autotools-basics.tex   | 66 +++++++++++++++++++++++++++-
 slides/autotools-basics/autotools-basics.tex |  4 +-
 2 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/labs/autotools-basics/autotools-basics.tex b/labs/autotools-basics/autotools-basics.tex
index c68e66d..204df16 100644
--- a/labs/autotools-basics/autotools-basics.tex
+++ b/labs/autotools-basics/autotools-basics.tex
@@ -2,6 +2,70 @@
 {Autotools basics}
 {Objectives:
   \begin{itemize}
-  \item TBD
+  \item Your first {\tt configure.ac}
+  \item Adding and building a program
+  \item Going further: \code{autoscan} and \code{make dist}
   \end{itemize}
 }
+
+\section{Create your first {\tt configure.ac}}
+
+In \code{$HOME/autotools-labs/basics/}, create a new folder
+\code{project} for your first {\em autotools} project.
+
+In order to keep a good understanding of real source files as opposed
+to generated files, we'll put our project under version control, using
+{\em Git}. Run \code{git init} to initialize a new repository.
+
+Create the absolutely minimal \code{configure.ac} using just
+\code{AC_INIT} and \code{AC_OUTPUT}. Use \code{git add configure.ac}
+to add this file to the Git repository, and
+\code{git commit -s -m ``Initial configure.ac''} to commit this first
+\code{configure.ac}.
+
+Use \code{autoreconf -i}, look at which files where generated. Thanks
+to \code{git status}, you can see which of those files are not under
+version control.
+
+Test your shiny new \code{configure} script. How much does it do? Look
+at the new files that have been generated.
+
+Now, prepare your project to support C source code, by adding
+\code{AC_PROG_CC} to your \code{configure.ac}. Run
+\code{autoreconf -i} again, and restart \code{./configure}. It should
+do a lot more tests now!
+
+\section{Adding and building a program}
+
+Create a very simple hello world C program in a file called
+\code{hello.c}:
+
+\begin{verbatim}
+#include <stdio.h>
+
+int main(void) {
+   printf("Hello World\n");
+   return 0;
+}
+\end{verbatim}
+
+In order to build this file, you'll have to adjust your
+\code{configure.ac} to initialize \code{automake} and create a
+\code{Makefile.am} file with the necessary code to build one program.
+
+Run \code{autoreconf -i}, and once it {\em autoreconfs} properly,
+build your project!
+
+You can also install it, after re-configuring it with
+\code{--prefix=$HOME/sys}.
+
+As you can see, doing your first {\em autotools} project is not very
+complicated.
+
+\section{Going further}
+
+Run \code{autoscan}, read the generated \code{configure.scan} and
+compare it to your \code{configure.ac}. What are the differences?
+
+Run \code{make dist}, and look at the tarball that is generated. Your
+project is ready to be released!
diff --git a/slides/autotools-basics/autotools-basics.tex b/slides/autotools-basics/autotools-basics.tex
index 6e1b37c..e4e2d44 100644
--- a/slides/autotools-basics/autotools-basics.tex
+++ b/slides/autotools-basics/autotools-basics.tex
@@ -484,6 +484,8 @@ test_SOURCES = test.c common.c common.h
 {Your first {\em autotools} project}
 {
   \begin{itemize}
-  \item TODO
+  \item Your first {\tt configure.ac}
+  \item Adding and building a program
+  \item Going further: \code{autoscan} and \code{make dist}
   \end{itemize}
 }



More information about the training-materials-updates mailing list