0% found this document useful (0 votes)
62 views13 pages

Understanding Configuration and Build Systems: Nrcfoss 1

This document discusses configuration and build systems. It begins with an overview of the basic compilation process from source files to object files to executable. It then discusses the goals of modularity, portability, and challenges of large numbers of dependencies and platform differences. It introduces make as a way to automate determining what needs recompilation based on modification times. Finally, it introduces the GNU Autotools including Autoconf, Automake and Libtool as a way to further automate writing portable makefiles and managing the build process.

Uploaded by

Eric Hernandez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views13 pages

Understanding Configuration and Build Systems: Nrcfoss 1

This document discusses configuration and build systems. It begins with an overview of the basic compilation process from source files to object files to executable. It then discusses the goals of modularity, portability, and challenges of large numbers of dependencies and platform differences. It introduces make as a way to automate determining what needs recompilation based on modification times. Finally, it introduces the GNU Autotools including Autoconf, Automake and Libtool as a way to further automate writing portable makefiles and managing the build process.

Uploaded by

Eric Hernandez
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Understanding Configuration and Build Systems

NRCFOSS

Overview of the compilation process


If the program consists of a number of source files, building is at least a two-stage process: Each source file is compiled into a corresponding object file Finally, all the objects are linked together and with any external libraries to create an executable This simple model fails to generalise: sources may need some configuring to tailor them to specific platforms. We will return to this problem.
NRCFOSS 2

Goals and challenges


Goals:
Modularity Portability

Challenges: It is impossible for the developer to keep track of:


Large numbers of source files with complicated dependencies Peculiarities of diverse target platforms

How to reconcile these conflicting requirements?

NRCFOSS

The Answer: Automate!


Fundamental principle of program development I: Cultivate laziness! or Let the machine do the hard work!

Enter make. Make


automatically determines which parts of a program need recompilation, issues commands to recompile them requires a `makefile' as input, specifying relationships among sources and commands for compilation uses makefile database and file modification times to determine sources that need recompilation

NRCFOSS

Some common options of make


make [option] ... target ... make -f file - makefile make -n - no action make -C dir - change directory make -d - debug make -e - environment make -i - ignore errors make -k - continue make -I dir - include directory make -t - touch make -p - print rule database make -q - question mode NRCFOSS

A simple makefile example


We will follow the GNU Make syntax throughout. example: main.o foo.o bar.o gcc -o example main.o foo.o bar.o main.o: main.c example.h gcc -c main.c foo.o: foo.c example.h gcc -c foo.c bar.o: bar.c example.h gcc -c bar.c clean:-rm *.o example
NRCFOSS 6

When make alone is not enough


Different makefiles may be required for each target platform, and Complicated makefile syntax is tedious and errorprone But, Many programs are built similarly, and Makefiles have a reasonably strict grammatical structure Therefore, we may invoke Fundamental Principle I and ask, `Why not automate writing makefiles?'
NRCFOSS 7

The GNU Autotools


Fundamental principle of program development II: Cultivate laziness in the user! or Make the author do the hard work! or Let the author worry how to make the machine do the hard work! Autoconf, Automake and Libtool were designed to solve precisely this problem. Autoconf - configuration (portability). Automake - dependency tracking, boilerplate, standard targets Libtool - creating, linking and loading shared and static libraries.
NRCFOSS

GNU Autotools
A potted history of the autotools. Cygnus and GCC configure Imake Metaconfig GNU Autoconf

Result of running autotools: a configure script, a set of makefiles and config.h


NRCFOSS 9

Demonstration of Autotools
Autoconf configures through a set of feature tests Macro expansion is the basic technique Portable Bourne shell scripts implement tests

NRCFOSS

10

How the autotools work together


Author:
Create two input files, configure.ac and Makefile.am specifying feature tests and makefile rules. Create m4 macros and config.h template using aclocal and autoheader. Create Makefile.in's using automake. Create configure and config.h using autoconf.

User: Run configure, make, make install.


NRCFOSS 11

Other helper tools


m4 - the macro processor aclocal - provides a bunch of automake macros Autoscan - generates basic configure.ac Autoheader - template for config.h Autogen - mechanism to generate repetitive text
NRCFOSS 12

Thank you!

NRCFOSS

13

You might also like