SlideShare a Scribd company logo
Autoconf & Automake [email_address]
Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
History ( I)   The Diversity of Unix Systems   System III SunOS …… Although similar, there are still various differences between different systems. Different sets of header files  Different lists of functions in the system libraries ……
History ( II) #ifdef Cannot know which system which version had which features POSIX standards  Portable Operating System Interface Only eliminate some of these differences Need more organized approach to handle the differences between Unix variants
Building A Program Makefile configure Makefile.am Makefile Program Makefile.in configure.in Configuration Build Make automake autoconf ./ configure
What is Autoconf (I) ‘ configure’ script Shell script Tests system features Prepare source tree in order to build the program on a particular system Before:  had to be updated for each new Unix variant Now:  build a package on any kind of system with a simple ‘configure’ script
What is Autoconf   (II) ‘ configure.in’ List the features that the program needs Autoconf Generate ‘configure’ script Run by developers
What is Automake Run by developers ‘ Makefile.am’ Which source files are used to build the program A simpler syntax ‘ Makefile.in’ There was a great deal of duplication  ‘ Makefile’ The rules for how to build the program itself  With a reasonably complex set of GNU standards
Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
Configure Parameters - h  (-- help)  - V  (-- version) --includedir=dir Specifies where C header files should be installed --libdir=dir Specifies where object code library should be installed --srcdir=dir   Tells where the source files may be found Not necessary
Files generated by configure  ( I)   ‘ config.cache’ Cache the results of system tests that have been performed to speed up subsequent tests A plain text file  Can be hand-modified or removed if desired ‘ config.log’ Outputs a message describing each test it performs and the result of each test
Files generated by configure ( II) ‘ config.status’ Used to recreate the current configuration (all generated files will be regenerated) Re-run  configure  with  --recheck  option
Files generated by configure ( III) ‘ config.h’  Optionally placed in  #define  preprocessor directives /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* # undef NO_MINUS_C_MINUS_O */ /* Define if you have strchr (always for CVS).  */ #define HAVE_STRCHR 1 Source files may include the ‘config.h’ file and act accordingly:  # if HAVE_CONFIG_H  # include <config.h> # endif /* HAVE_CONFIG_H */
Make make all   Builds all derived files sufficient to declare the package built make check  Runs any self-tests that the package may have make install Installs the package in a predetermined location  make clean Removes all derived files
Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
A Minimal Project Input files  (I) ‘ configuire.in’ A template of macro invocations and shell code fragments that are used by  autoconf   to produce a ‘configure’ script  autoconf   copies the contents of ‘configure.in’ to ‘configure’, expanding macros as they occur in the input. Other text is copied verbatim.  autoconf configure.in configure.scan autoscan Modified
A Minimal Project Input files  (I) eg:   dnl Process this file with autoconf to produce a configure script.  AC_INIT(main.c)  AM_INIT_AUTOMAKE(foonly, 1.0)  AC_PROG_CC  AM_PROG_LEX  AC_PROG_YACC  AC_OUTPUT(Makefile)  autoconf configure.in
A Minimal Project Input files (II) High-level, bare-bones specification of a project's build requirements:  What needs to be built ? Where does it go ? When it is installed ?  eg: bin_PROGRAMS = hello    hello_SOURCES = main.c foo.c foo.h nly.c  Makefile.am automake
A Minimal Project Output files (I) Macro invocations in ‘configure.in’ may are not known to   autoconf ‘ aclocal.m4’ Collect all of the macro definitions for  autoconf   aclocal.m4 aclocal configure autoconf
A Minimal Project Output files (II) $ automake --add-missing  automake: configure.in: installing ./install-sh  automake: configure.in: installing ./mkinstalldirs  automake: configure.in: installing ./missing  automake: Makefile.am: installing ./INSTALL  automake: Makefile.am: required file ./NEWS not found  automake: Makefile.am: required file ./README not found  automake: Makefile.am: installing ./COPYING  automake: Makefile.am: required file ./AUTHORS not found  automake: Makefile.am: required file ./ChangeLog not found  Makefile.in automake $ touch NEWS README AUTHORS ChangeLog $ automake --add-missing
A Minimal Project  Distrbution Developer: Package up your tree in a tar file Give the tar file to other users to install on their own systems User: Unpack the  tar  file ./ configure   make all
Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
Review A template of macro invocations and shell code fragments that are used by  autoconf  to produce a ‘configure’ script  Writing ‘configure.in’     What is ‘configure.in’ autoconf configure.in configure.scan autoscan Modified
What constructs are portable and what constructs aren't portable?  How do I decide what to check for? What shouldn't I check for?  What shouldn't I put in `configure.in'?  In what order should I run my checks?  Writing ‘configure.in’   Frequent Question
Boilerplate Programs Libraries Headers Typedefs and structures  Functions Output Writing ‘configure.in’     Standard Ordering
Include standard boilerplate code AC_INIT (File)   Must be first Check if  File  exists in srcdir Generated by  autoscan eg: AC_INIT(src/cvs.h) AM_INIT_AUTOMAKE (Package, Version) Necessary to use  automake eg: AM_INIT_AUTOMAKE(cvs, 1.11.2) Writing ‘configure.in’     Boilerplate
Check for programs that are either needed by the configure process, the build process, or by one of the programs being built AC_CHECK_PROG (variable, progs-to-check-for [, value-if-not-found [, path]]) Writing ‘configure.in’     Programs
Checks for libraries come before checks for other objects visible to C (or C++, or anything else) Writing ‘configure.in’     Libraries   Headers Checks for existence of headers Typedefs and structures Checks for typedefs and structures inside the headers
Checks for functions based on: Libraries  for correctly linking Headers  for finding prototypes  Typedefs   for using types which are not built in  AC_CHECK_FUNC (function, [action-if-found [, action-if-not-found]])   Writing ‘configure.in’   Functions
Writing ‘configure.in’   Output   AC_OUTPUT ([file... [, extra-cmds [, init-cmds]]])  file...  separate with space file.in file eg: AC_OUTPUT([Makefile \   cvs.spec \   contrib/log \   src/Makefile \   src/cvsbug \   src/version.h \   ],   [chmod +x \   contrib/log \   src/cvsbug])
Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
Automake’s goal Basic functional areas:  Build  Check  Clean  Install and uninstall  Distribution  Makefile.am Makefile.in automake
Primaries Concept: A special root variable name associated with each type of object that Automake understands  SCRIPTS:   scripts (interpreted executable programs) Add various prefixes to a primary to represent an actual object bin_SCRIPTS = magic-script  bin_SCRIPTS  represents an actual script object which is installed in /bin directory magic-script  is an object file, represents a variable of  bin_SCRIPTS  , will be a  Target  in Makefile finally
Easy Primaries DATA   Easiest primary  List files which are installed verbatim HEADERS List header files Allows for extra error checking SCRIPTS  Executable scripts (interpreted programs) MANS   List man pages TEXINFOS   List Texinfo documentations JAVA, LISP, PYTHON......
Programs & Libraries Primaries  (I) PROGRAMS  eg:   bin_PROGRAMS = doit   LIBRARIES  eg:   lib_LIBRARIES = libzlib.a
Programs & Libraries Primaries  (II) When more than one source file, use  SOURCES eg: 1 ) bin_PROGRAMS = doit    doit_SOURCES = doit.c main.c  2 ) lib_LIBRARIES = libzlib.a   libzlib_a_SOURCES = adler32.c compress.c \   crc32.c deflate.c deflate.h  gzio.c infblock.c\   infblock.h infcodes.c infcodes.h inffast.c inffast.h 名称规范化
Common Macros _DEPENDENCIES Extra dependencies Based on the value of the program's  _LDADD  macro.  _LDADD Extra objects which are passed to the linker Only used by programs and shared libraries _LIBADD   Like  _LDADD , but used for static libraries and not programs.
Multiple Directories  SUBDIRS  eg:   SUBDIRS = . m4 tests  Testing  TESTS  XFAIL_TESTS prefix   `check'   eg:   check_PROGRAMS = test-program test_program_SOURCES = ......
2003/12/29 References Autobook http://192.168.1.182/ linux /tech/ autobook / autobook .html Autoconf  手册 http://www. cngnu .org/technology/145747f636f6e666.html
Thank you!

More Related Content

PPTX
Gnu build system
PPT
嵌入式Linux課程-GNU Toolchain
PPTX
BuildStuff.LT 2018 InSpec Workshop
PDF
Introduction to GNU Make Programming Language
KEY
Crafting Beautiful CLI Applications in Ruby
ODP
Introduction To Makefile
PPT
Introduction to Makefile
PPTX
Deploying Symfony2 app with Ansible
Gnu build system
嵌入式Linux課程-GNU Toolchain
BuildStuff.LT 2018 InSpec Workshop
Introduction to GNU Make Programming Language
Crafting Beautiful CLI Applications in Ruby
Introduction To Makefile
Introduction to Makefile
Deploying Symfony2 app with Ansible

What's hot (20)

PDF
Puppet control-repo 
to the next level
PDF
Building robust and friendly command line applications in go
PDF
Shell scripting
PDF
Installing AtoM with Ansible
PDF
Operating System Practice : Meeting 7- working with bash shell-a-slide
PDF
Programming in Linux Environment
PDF
(1) cpp introducing the_cpp_programming_language
PDF
Operating System Practice : Meeting 8- bekerja dengan bash shell-b-slide
PDF
Dependency management with Composer
PDF
CoreOS : 설치부터 컨테이너 배포까지
PDF
Server Side? Swift
PDF
Intro to Linux Shell Scripting
PDF
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
PPT
Shell scripting - By Vu Duy Tu from eXo Platform SEA
PPT
Ruby Projects and Libraries
PDF
Composer for Busy Developers - php|tek13
PDF
Software development practices in python
PDF
Genode Programming
PPTX
Introduction to Makefile
Puppet control-repo 
to the next level
Building robust and friendly command line applications in go
Shell scripting
Installing AtoM with Ansible
Operating System Practice : Meeting 7- working with bash shell-a-slide
Programming in Linux Environment
(1) cpp introducing the_cpp_programming_language
Operating System Practice : Meeting 8- bekerja dengan bash shell-b-slide
Dependency management with Composer
CoreOS : 설치부터 컨테이너 배포까지
Server Side? Swift
Intro to Linux Shell Scripting
Embedded Systems: Lecture 12: Introduction to Git & GitHub (Part 3)
Shell scripting - By Vu Duy Tu from eXo Platform SEA
Ruby Projects and Libraries
Composer for Busy Developers - php|tek13
Software development practices in python
Genode Programming
Introduction to Makefile
Ad

Similar to Autoconf&Automake (20)

PDF
LOSS_C11- Programming Linux 20221006.pdf
ODP
Makefile Generation From Autotools
PDF
Gnubs pres-foss-cdac-sem
PDF
Gnubs-pres-foss-cdac-sem
ODP
Autotools
ODP
Software Build processes and Git
PPTX
DevOpsDays InSpec Workshop
PDF
Autotools
PDF
CMake Tutorial
PPTX
Feature and platform testing with CMake
PPT
Apache Ant
PPTX
Docker Starter Pack
PPT
Purdue CS354 Operating Systems 2008
PPT
cppProgramStructure.ppt
PPT
Introduction To Ant1
PDF
Embedded C - Lecture 1
PDF
Deployment automation
PDF
Dependencies Managers in C/C++. Using stdcpp 2014
PDF
Usage Note of SWIG for PHP
PDF
Autotools
LOSS_C11- Programming Linux 20221006.pdf
Makefile Generation From Autotools
Gnubs pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
Autotools
Software Build processes and Git
DevOpsDays InSpec Workshop
Autotools
CMake Tutorial
Feature and platform testing with CMake
Apache Ant
Docker Starter Pack
Purdue CS354 Operating Systems 2008
cppProgramStructure.ppt
Introduction To Ant1
Embedded C - Lecture 1
Deployment automation
Dependencies Managers in C/C++. Using stdcpp 2014
Usage Note of SWIG for PHP
Autotools
Ad

Recently uploaded (20)

PPTX
ICG2025_ICG 6th steering committee 30-8-24.pptx
PDF
WRN_Investor_Presentation_August 2025.pdf
PPT
Data mining for business intelligence ch04 sharda
PDF
How to Get Business Funding for Small Business Fast
PPTX
Amazon (Business Studies) management studies
DOCX
Business Management - unit 1 and 2
PDF
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
PPTX
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
PDF
Nidhal Samdaie CV - International Business Consultant
PDF
Chapter 5_Foreign Exchange Market in .pdf
PPT
340036916-American-Literature-Literary-Period-Overview.ppt
DOCX
unit 1 COST ACCOUNTING AND COST SHEET
PDF
A Brief Introduction About Julia Allison
PDF
Power and position in leadershipDOC-20250808-WA0011..pdf
PDF
Training And Development of Employee .pdf
PPT
Chapter four Project-Preparation material
PDF
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
PDF
DOC-20250806-WA0002._20250806_112011_0000.pdf
PDF
COST SHEET- Tender and Quotation unit 2.pdf
PPTX
New Microsoft PowerPoint Presentation - Copy.pptx
ICG2025_ICG 6th steering committee 30-8-24.pptx
WRN_Investor_Presentation_August 2025.pdf
Data mining for business intelligence ch04 sharda
How to Get Business Funding for Small Business Fast
Amazon (Business Studies) management studies
Business Management - unit 1 and 2
Solara Labs: Empowering Health through Innovative Nutraceutical Solutions
The Marketing Journey - Tracey Phillips - Marketing Matters 7-2025.pptx
Nidhal Samdaie CV - International Business Consultant
Chapter 5_Foreign Exchange Market in .pdf
340036916-American-Literature-Literary-Period-Overview.ppt
unit 1 COST ACCOUNTING AND COST SHEET
A Brief Introduction About Julia Allison
Power and position in leadershipDOC-20250808-WA0011..pdf
Training And Development of Employee .pdf
Chapter four Project-Preparation material
kom-180-proposal-for-a-directive-amending-directive-2014-45-eu-and-directive-...
DOC-20250806-WA0002._20250806_112011_0000.pdf
COST SHEET- Tender and Quotation unit 2.pdf
New Microsoft PowerPoint Presentation - Copy.pptx

Autoconf&Automake

  • 1. Autoconf & Automake [email_address]
  • 2. Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
  • 3. History ( I) The Diversity of Unix Systems System III SunOS …… Although similar, there are still various differences between different systems. Different sets of header files Different lists of functions in the system libraries ……
  • 4. History ( II) #ifdef Cannot know which system which version had which features POSIX standards Portable Operating System Interface Only eliminate some of these differences Need more organized approach to handle the differences between Unix variants
  • 5. Building A Program Makefile configure Makefile.am Makefile Program Makefile.in configure.in Configuration Build Make automake autoconf ./ configure
  • 6. What is Autoconf (I) ‘ configure’ script Shell script Tests system features Prepare source tree in order to build the program on a particular system Before: had to be updated for each new Unix variant Now: build a package on any kind of system with a simple ‘configure’ script
  • 7. What is Autoconf (II) ‘ configure.in’ List the features that the program needs Autoconf Generate ‘configure’ script Run by developers
  • 8. What is Automake Run by developers ‘ Makefile.am’ Which source files are used to build the program A simpler syntax ‘ Makefile.in’ There was a great deal of duplication ‘ Makefile’ The rules for how to build the program itself With a reasonably complex set of GNU standards
  • 9. Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
  • 10. Configure Parameters - h (-- help) - V (-- version) --includedir=dir Specifies where C header files should be installed --libdir=dir Specifies where object code library should be installed --srcdir=dir Tells where the source files may be found Not necessary
  • 11. Files generated by configure ( I) ‘ config.cache’ Cache the results of system tests that have been performed to speed up subsequent tests A plain text file Can be hand-modified or removed if desired ‘ config.log’ Outputs a message describing each test it performs and the result of each test
  • 12. Files generated by configure ( II) ‘ config.status’ Used to recreate the current configuration (all generated files will be regenerated) Re-run configure with --recheck option
  • 13. Files generated by configure ( III) ‘ config.h’ Optionally placed in #define preprocessor directives /* Define to 1 if your C compiler doesn't accept -c and -o together. */ /* # undef NO_MINUS_C_MINUS_O */ /* Define if you have strchr (always for CVS). */ #define HAVE_STRCHR 1 Source files may include the ‘config.h’ file and act accordingly: # if HAVE_CONFIG_H # include <config.h> # endif /* HAVE_CONFIG_H */
  • 14. Make make all Builds all derived files sufficient to declare the package built make check Runs any self-tests that the package may have make install Installs the package in a predetermined location make clean Removes all derived files
  • 15. Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
  • 16. A Minimal Project Input files (I) ‘ configuire.in’ A template of macro invocations and shell code fragments that are used by autoconf to produce a ‘configure’ script autoconf copies the contents of ‘configure.in’ to ‘configure’, expanding macros as they occur in the input. Other text is copied verbatim. autoconf configure.in configure.scan autoscan Modified
  • 17. A Minimal Project Input files (I) eg: dnl Process this file with autoconf to produce a configure script. AC_INIT(main.c) AM_INIT_AUTOMAKE(foonly, 1.0) AC_PROG_CC AM_PROG_LEX AC_PROG_YACC AC_OUTPUT(Makefile) autoconf configure.in
  • 18. A Minimal Project Input files (II) High-level, bare-bones specification of a project's build requirements: What needs to be built ? Where does it go ? When it is installed ? eg: bin_PROGRAMS = hello hello_SOURCES = main.c foo.c foo.h nly.c Makefile.am automake
  • 19. A Minimal Project Output files (I) Macro invocations in ‘configure.in’ may are not known to autoconf ‘ aclocal.m4’ Collect all of the macro definitions for autoconf aclocal.m4 aclocal configure autoconf
  • 20. A Minimal Project Output files (II) $ automake --add-missing automake: configure.in: installing ./install-sh automake: configure.in: installing ./mkinstalldirs automake: configure.in: installing ./missing automake: Makefile.am: installing ./INSTALL automake: Makefile.am: required file ./NEWS not found automake: Makefile.am: required file ./README not found automake: Makefile.am: installing ./COPYING automake: Makefile.am: required file ./AUTHORS not found automake: Makefile.am: required file ./ChangeLog not found Makefile.in automake $ touch NEWS README AUTHORS ChangeLog $ automake --add-missing
  • 21. A Minimal Project Distrbution Developer: Package up your tree in a tar file Give the tar file to other users to install on their own systems User: Unpack the tar file ./ configure make all
  • 22. Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
  • 23. Review A template of macro invocations and shell code fragments that are used by autoconf to produce a ‘configure’ script Writing ‘configure.in’ What is ‘configure.in’ autoconf configure.in configure.scan autoscan Modified
  • 24. What constructs are portable and what constructs aren't portable? How do I decide what to check for? What shouldn't I check for? What shouldn't I put in `configure.in'? In what order should I run my checks? Writing ‘configure.in’ Frequent Question
  • 25. Boilerplate Programs Libraries Headers Typedefs and structures Functions Output Writing ‘configure.in’ Standard Ordering
  • 26. Include standard boilerplate code AC_INIT (File) Must be first Check if File exists in srcdir Generated by autoscan eg: AC_INIT(src/cvs.h) AM_INIT_AUTOMAKE (Package, Version) Necessary to use automake eg: AM_INIT_AUTOMAKE(cvs, 1.11.2) Writing ‘configure.in’ Boilerplate
  • 27. Check for programs that are either needed by the configure process, the build process, or by one of the programs being built AC_CHECK_PROG (variable, progs-to-check-for [, value-if-not-found [, path]]) Writing ‘configure.in’ Programs
  • 28. Checks for libraries come before checks for other objects visible to C (or C++, or anything else) Writing ‘configure.in’ Libraries Headers Checks for existence of headers Typedefs and structures Checks for typedefs and structures inside the headers
  • 29. Checks for functions based on: Libraries for correctly linking Headers for finding prototypes Typedefs for using types which are not built in AC_CHECK_FUNC (function, [action-if-found [, action-if-not-found]]) Writing ‘configure.in’ Functions
  • 30. Writing ‘configure.in’ Output AC_OUTPUT ([file... [, extra-cmds [, init-cmds]]]) file... separate with space file.in file eg: AC_OUTPUT([Makefile \ cvs.spec \ contrib/log \ src/Makefile \ src/cvsbug \ src/version.h \ ], [chmod +x \ contrib/log \ src/cvsbug])
  • 31. Agenda History How to run configure&make A Minimal Project Writing ‘configure.in’ Writing ‘Makefile.am’ References
  • 32. Automake’s goal Basic functional areas: Build Check Clean Install and uninstall Distribution Makefile.am Makefile.in automake
  • 33. Primaries Concept: A special root variable name associated with each type of object that Automake understands SCRIPTS: scripts (interpreted executable programs) Add various prefixes to a primary to represent an actual object bin_SCRIPTS = magic-script bin_SCRIPTS represents an actual script object which is installed in /bin directory magic-script is an object file, represents a variable of bin_SCRIPTS , will be a Target in Makefile finally
  • 34. Easy Primaries DATA Easiest primary List files which are installed verbatim HEADERS List header files Allows for extra error checking SCRIPTS Executable scripts (interpreted programs) MANS List man pages TEXINFOS List Texinfo documentations JAVA, LISP, PYTHON......
  • 35. Programs & Libraries Primaries (I) PROGRAMS eg: bin_PROGRAMS = doit LIBRARIES eg: lib_LIBRARIES = libzlib.a
  • 36. Programs & Libraries Primaries (II) When more than one source file, use SOURCES eg: 1 ) bin_PROGRAMS = doit doit_SOURCES = doit.c main.c 2 ) lib_LIBRARIES = libzlib.a libzlib_a_SOURCES = adler32.c compress.c \ crc32.c deflate.c deflate.h gzio.c infblock.c\ infblock.h infcodes.c infcodes.h inffast.c inffast.h 名称规范化
  • 37. Common Macros _DEPENDENCIES Extra dependencies Based on the value of the program's _LDADD macro. _LDADD Extra objects which are passed to the linker Only used by programs and shared libraries _LIBADD Like _LDADD , but used for static libraries and not programs.
  • 38. Multiple Directories SUBDIRS eg: SUBDIRS = . m4 tests Testing TESTS XFAIL_TESTS prefix `check' eg: check_PROGRAMS = test-program test_program_SOURCES = ......
  • 39. 2003/12/29 References Autobook http://192.168.1.182/ linux /tech/ autobook / autobook .html Autoconf 手册 http://www. cngnu .org/technology/145747f636f6e666.html