Click here to load reader
Upload
avneet-kaur
View
501
Download
2
Embed Size (px)
DESCRIPTION
Slide 2: Since it is tedious to recompile pieces of a program when something changes, people often use the make utility instead. Make needs a make file that encodes both the dependencies between files and the commands needed to generate files. When you run the make utility, it examines the modification times of files and determines what needs to be regenerated. Files that are older than the files they depend on must be regenerated. Slide 3: Targets With the needed variables, we can deal with the targets, which are files that must be generated. For each target, there are typically 1 or 2 lines in a make file. Those lines specify: its dependencies (easy to determine from a dependency chart) and possibly a command to generate the target (easy to determine from knowledge of separate compilation). Slide 4 : It matches the libraries on the user's computer, with those required by the program, just before compiling it from its source code. Using configure scripts is an automated method of generating makefiles before compilation to tailor the software to the system on which the executable is to be compiled and run. The final executable software is most commonly obtained by executing the following commands in a shell that is currently pointing to the directory containing the source code: ./configure make make install Slide 5 : The configuration scripts that Autoconf produces are by convention called configure. When run, configure creates several files, replacing configuration parameters in them with appropriate values. To create a configure script with Autoconf, you need to write an Autoconf input file configure.ac (or configure.in) and run autoconf on it. Slide 6 : Using autoscan to Create configure.ac The autoscan program can help you create and/or maintain a configure.ac file for a software package. It searches the source files for common portability problems and creates a file configure.scan which is a preliminary configure.ac for that package, and checks a possibly existing configure.ac for completeness. When using autoscan to create a configure.ac, you should manually examine configure.scan before renaming it to configure.ac; it probably needs some adjustments. Slide 7 : The AC_INIT macro initializes autoconf with information about your project, including the project name, version number, bug-reporting address, tarball name and the project homepage. The AM_INIT_AUTOMAKE line adds several standard checks and initializes automake. AC_PROG_CXX checks for a C++ compiler. If your project uses C, you can check for a C compiler withAC_PROG_CC. AC_CONFIG_FILES lists the files to be generated by configure. By default, each file is generated from a template file of the same name but with an .in extension appended. AC_OUTPUT finishes configure processing, and generates the output files. Slide 14 : Using autoreconf to Update configure Scripts
Citation preview
GNU Autotools
Avneet Kaur http://avneetkhasla.wordpress.com/
Make
Makefile
target: prerequisite-list TAB construction-commands
project: main.o project.o g++ main.o project.o -o project main.o: main.cpp g++ -c main.cpp project.o: project.cpp g++ -c project.cpp
$ make
Syntax
Example
Compilation
Executable script designed to aid in developing a program to be run on a wide number of different computers.
Configure Script
configure → created from “configure.ac” (using Autoconf)
configure.ac → created automatically (using Autoscan) or manually
Creating ‘configure’
Autoscan
AC_INIT([Hello], [0.1], [[email protected]], [hello], [http://hello.example.com/])
AM_INIT_AUTOMAKE([1.10 no-define])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
configure.ac should include
Autoheader
C sources and headers
config.h.in
Aclocal
configure.ac
aclocal.m4
Automake
Makefile.in
Makefile.am
configure.ac
Makefile.am ?
$ touch NEWS README AUTHORS ChangeLog
OR
AM_INIT_AUTOMAKE call in configure.ac instead:AM_INIT_AUTOMAKE([1.10 no-define foreign])
GNU-style projects ?
Autoconf
configure.ac, Makefile.in, configure.h.in
configure config.h Makefile
aclocal.m4
Autoreconf
AutoconfAutoheaderAclocalAutomakeLibtoolizeAutopoint
Ultimate Summary
Create sources, Makefile.am”
autoscan
Rename “configure.scan” to “configure.ac”
autoheader
Add AM_INIT_AUTOMAKE to “configure.ac”
aclocal
automake add missing copy
autoconf
./configure make
make install
Thank You!