SlideShare a Scribd company logo
Makefile generation from Autotools Waqqas Jabbar
Prerequisites C, C++  gcc and its options make and Makefile configure and its options pkg-config
Objectives Use autotools to generate Makefiles, for Dynamic and Static libraries Executable Use libtool to generate libraries
Autotools Collection of utilities automake autoconf libtoolize aclocal autoheader autoscan autoupdate autoreconf Can be used separately or together
Inputs to autotools configure.ac Makefile.ac config.h.in Source code
Outputs of autotools config.h Added in project Conditional compilation #ifdef, #elif, #endif Makefile(s) Input to make
? config.h Makefile Makefile.in Source code configure.ac autoscan autoheader automake config.h.in Makefile.am autoconf configure.scan configure configure
config.h Makefile Makefile.in Source code configure.ac autoscan autoheader automake config.h.in Makefile.am autoconf configure.scan configure configure
autoscan Input: Source code Output: configure.scan Template for configure.ac
autoheader Input: configure.ac, Source code Output: config.h.in What defines are to be generated in config.h #undef VAR -> #define VAR 1 ( by configure)
automake Input: Makefile.am Output: Makefile.in Convert automake variables to their values
autoconf Input: configure.ac Output: configure Shell script
configure Input: config.h.in, Makefile.in Output: config.h, Makefile(s)
Makefile.in Syntax of Makefile
Makefile.am Executables Installation binaries bin_PROGRAMS = foo1 Non-Installation binaries noinst_PROGRAMS = foo2 foo1_SOURCES = foo1.c foo1.h INCLUDES=-I $HOME/usr/include LDADD=-lpthread AM_CFLAGS=-DMY_DEFINE foo1extradir=$(datadir)/foo1 foo1extra_DATA= foo1.conf
Makefile.am Libraries Installation Libraries lib_LTLIBRARIES=libtest.la library_includedir= The directory where header files will be installed library_include_HEADERS= Header files exposed by the library Non-installation libraries noinst_LTLIBRARIES= libtest_la_SOURCES =  libtest_la_LDFLAGS =  INCLUDES = -I. libtest_la_LIBADD= (other libraries to add)
Makefile.am Predefined variables $(top_srcdir) : Main directory of source-code $(includedir) : Path specified in configure for installing header files SUBDIRS =
configure.ac Set of M4 Macros Initialization AC_PREREQ AC_INIT AC_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE Checks for programs AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL AM_PROG_LIBTOOL AM_SANITY_CHECK
configure.ac Checks for libraries pkg-config PKG_CHECK_MODULES(SNDFILE_DEPS, sndfile >= 1.0.17) AC_SUBST(SNDFILE_DEPS_CFLAGS) AC_SUBST(SNDFILE_DEPS_LIBS) AC_SUBST passes variable from configure.ac to Makefile.am
configure.ac No script AC_CHECK_LIB AC_ARG_WITH(mysql, [ --with-mysql=<path> prefix of MySQL installation. e.g. /usr/local or /usr],  [MYSQL_PREFIX=$with_mysql],  AC_MSG_ERROR([You must call configure with the --with-mysql option.  This tells configure where to find the MySql C library and headers. e.g. --with-mysql=/usr/local or --with-mysql=/usr])) AC_SUBST(MYSQL_PREFIX) MYSQL_LIBS=&quot;-L${MYSQL_PREFIX}/lib/mysql -lmysqlclient&quot; MYSQL_CFLAGS=&quot;-I${MYSQL_PREFIX}/include&quot; AC_SUBST(MYSQL_LIBS) AC_SUBST(MYSQL_CFLAGS)
configure.ac Checks for header files AC_HEADER_STDC AC_CHECK_HEADERS([string.h]) Checks for typedefs, structures, and compiler characteristics Checks for library functions AC_CHECK_FUNCS([bzero]) Give Makefile to generate AC_CONFIG_FILES([Makefile]) AC_OUTPUT
configure.ac Adding option in configure script AC_ARG_ENABLE(option-foo,[  --enable-option-foo  help for option foo], [CFLAGS= &quot;$CFLAGS -DOPTION_FOO_DEFINE&quot;], []) Disable shared libraries AC_DISABLE_SHARED
References http://www.elitecoders.de/mags/cscene/CS2/CS2-10.html http://www.openismus.com/documents/linux/automake/automake.shtml http://www.openismus.com/documents/linux/using_libraries/using_libraries.shtml http://www.openismus.com/documents/linux/building_libraries/building_libraries.shtml http://bec-systems.com/web/content/view/95/9/ http://sources.redhat.com/autobook/autobook/autobook_toc.html#SEC_Contents http://www.gnu.org/manual/manual.html Examples http://www.openismus.com/documents/linux/building_libraries/examplelib-0.3.0.tar.gz http://www.openismus.com/documents/linux/using_libraries/examplelib_example-0.3.0.tar.gz
Summary You can generate distributions in tar.gz or rpm
Thank You

More Related Content

What's hot (19)

PDF
Operating System Practice : Meeting 8- bekerja dengan bash shell-b-slide
Syaiful Ahdan
 
KEY
Crafting Beautiful CLI Applications in Ruby
Nikhil Mungel
 
PDF
Scaling up development of a modular code base
Robert Munteanu
 
PDF
Installing AtoM with Ansible
Artefactual Systems - AtoM
 
PDF
Create your own composer package
Lattapon Yodsuwan
 
PDF
Using Capifony for Symfony apps deployment (updated)
Žilvinas Kuusas
 
PPTX
Deployment Patterns in the Ruby on Rails World
Nikhil Mungel
 
PDF
Виталий Редько "React + Redux: performance & scalability"
Fwdays
 
PPTX
Makefile for python projects
Mpho Mphego
 
PDF
Scaling up development of a modular code base
Robert Munteanu
 
PDF
Puppet Camp Ghent 2013
Server Density
 
PDF
Build Systems with autoconf, automake and libtool [updated]
Benny Siegert
 
PDF
以 Laravel 經驗開發 Hyperf 應用
Shengyou Fan
 
PDF
Dependency management with Composer
Jason Grimes
 
PDF
Tp install anything
Alessandro Franceschi
 
PDF
Automation and Ansible
jtyr
 
ZIP
Voiture tech talk
Hoppinger
 
PDF
Php matusri xhprof custompanel
Masaki YOSHIDA
 
PPTX
Docker for Development
allingeek
 
Operating System Practice : Meeting 8- bekerja dengan bash shell-b-slide
Syaiful Ahdan
 
Crafting Beautiful CLI Applications in Ruby
Nikhil Mungel
 
Scaling up development of a modular code base
Robert Munteanu
 
Installing AtoM with Ansible
Artefactual Systems - AtoM
 
Create your own composer package
Lattapon Yodsuwan
 
Using Capifony for Symfony apps deployment (updated)
Žilvinas Kuusas
 
Deployment Patterns in the Ruby on Rails World
Nikhil Mungel
 
Виталий Редько "React + Redux: performance & scalability"
Fwdays
 
Makefile for python projects
Mpho Mphego
 
Scaling up development of a modular code base
Robert Munteanu
 
Puppet Camp Ghent 2013
Server Density
 
Build Systems with autoconf, automake and libtool [updated]
Benny Siegert
 
以 Laravel 經驗開發 Hyperf 應用
Shengyou Fan
 
Dependency management with Composer
Jason Grimes
 
Tp install anything
Alessandro Franceschi
 
Automation and Ansible
jtyr
 
Voiture tech talk
Hoppinger
 
Php matusri xhprof custompanel
Masaki YOSHIDA
 
Docker for Development
allingeek
 

Similar to Makefile Generation From Autotools (20)

PPT
Autoconf&Automake
niurui
 
PDF
Gnubs pres-foss-cdac-sem
Sagun Baijal
 
PDF
Gnubs-pres-foss-cdac-sem
Sagun Baijal
 
PDF
Autotools
Thierry Gayet
 
PPT
2005_Structures and functions of Makefile
NakCheon Jung
 
PPTX
Autotools pratical training
Thierry Gayet
 
PPTX
Gnu build system
家榮 吳
 
ODP
Autotools
Vibha Singh
 
ODP
Introduction To Makefile
Waqqas Jabbar
 
PDF
LOSS_C11- Programming Linux 20221006.pdf
Thninh2
 
TXT
C make cache
javad lordoff
 
PDF
Building C and C++ libraries with Perl
Alberto Simões
 
ODP
Basic Make
Alec Clews
 
PPT
Linux Kernel Development
Priyank Kapadia
 
PDF
XPDDS19: A Journey through Unikraft's Build System
The Linux Foundation
 
PDF
Compiler design notes phases of compiler
ovidlivi91
 
PDF
textconfig
Kumaragouda Goudar
 
PDF
Autotools
easychen
 
PDF
Makefile
Ionela
 
PPT
Linux kernel modules
Hao-Ran Liu
 
Autoconf&Automake
niurui
 
Gnubs pres-foss-cdac-sem
Sagun Baijal
 
Gnubs-pres-foss-cdac-sem
Sagun Baijal
 
Autotools
Thierry Gayet
 
2005_Structures and functions of Makefile
NakCheon Jung
 
Autotools pratical training
Thierry Gayet
 
Gnu build system
家榮 吳
 
Autotools
Vibha Singh
 
Introduction To Makefile
Waqqas Jabbar
 
LOSS_C11- Programming Linux 20221006.pdf
Thninh2
 
C make cache
javad lordoff
 
Building C and C++ libraries with Perl
Alberto Simões
 
Basic Make
Alec Clews
 
Linux Kernel Development
Priyank Kapadia
 
XPDDS19: A Journey through Unikraft's Build System
The Linux Foundation
 
Compiler design notes phases of compiler
ovidlivi91
 
textconfig
Kumaragouda Goudar
 
Autotools
easychen
 
Makefile
Ionela
 
Linux kernel modules
Hao-Ran Liu
 
Ad

More from Waqqas Jabbar (13)

PPTX
Introduction to react native @ TIC NUST
Waqqas Jabbar
 
PPTX
Jump into React-Native (Class 6)
Waqqas Jabbar
 
PPTX
Jump into React-Native (Class 5)
Waqqas Jabbar
 
PPTX
Jump into React-Native (Class 4)
Waqqas Jabbar
 
PPTX
Jump into React Native (Class 3)
Waqqas Jabbar
 
PPTX
Jump into React-Native (Class 2/6)
Waqqas Jabbar
 
PPTX
Jump into React-Native (Class 1)
Waqqas Jabbar
 
PPTX
Introduction to React Native
Waqqas Jabbar
 
PPTX
Introduction to React Native
Waqqas Jabbar
 
PDF
Redux Saga - Under the hood
Waqqas Jabbar
 
PPTX
Crud application using react native, redux and redux sagas
Waqqas Jabbar
 
ODP
Introduction To SVN
Waqqas Jabbar
 
ODP
Introduction To SVN
Waqqas Jabbar
 
Introduction to react native @ TIC NUST
Waqqas Jabbar
 
Jump into React-Native (Class 6)
Waqqas Jabbar
 
Jump into React-Native (Class 5)
Waqqas Jabbar
 
Jump into React-Native (Class 4)
Waqqas Jabbar
 
Jump into React Native (Class 3)
Waqqas Jabbar
 
Jump into React-Native (Class 2/6)
Waqqas Jabbar
 
Jump into React-Native (Class 1)
Waqqas Jabbar
 
Introduction to React Native
Waqqas Jabbar
 
Introduction to React Native
Waqqas Jabbar
 
Redux Saga - Under the hood
Waqqas Jabbar
 
Crud application using react native, redux and redux sagas
Waqqas Jabbar
 
Introduction To SVN
Waqqas Jabbar
 
Introduction To SVN
Waqqas Jabbar
 
Ad

Makefile Generation From Autotools

  • 1. Makefile generation from Autotools Waqqas Jabbar
  • 2. Prerequisites C, C++ gcc and its options make and Makefile configure and its options pkg-config
  • 3. Objectives Use autotools to generate Makefiles, for Dynamic and Static libraries Executable Use libtool to generate libraries
  • 4. Autotools Collection of utilities automake autoconf libtoolize aclocal autoheader autoscan autoupdate autoreconf Can be used separately or together
  • 5. Inputs to autotools configure.ac Makefile.ac config.h.in Source code
  • 6. Outputs of autotools config.h Added in project Conditional compilation #ifdef, #elif, #endif Makefile(s) Input to make
  • 7. ? config.h Makefile Makefile.in Source code configure.ac autoscan autoheader automake config.h.in Makefile.am autoconf configure.scan configure configure
  • 8. config.h Makefile Makefile.in Source code configure.ac autoscan autoheader automake config.h.in Makefile.am autoconf configure.scan configure configure
  • 9. autoscan Input: Source code Output: configure.scan Template for configure.ac
  • 10. autoheader Input: configure.ac, Source code Output: config.h.in What defines are to be generated in config.h #undef VAR -> #define VAR 1 ( by configure)
  • 11. automake Input: Makefile.am Output: Makefile.in Convert automake variables to their values
  • 12. autoconf Input: configure.ac Output: configure Shell script
  • 13. configure Input: config.h.in, Makefile.in Output: config.h, Makefile(s)
  • 15. Makefile.am Executables Installation binaries bin_PROGRAMS = foo1 Non-Installation binaries noinst_PROGRAMS = foo2 foo1_SOURCES = foo1.c foo1.h INCLUDES=-I $HOME/usr/include LDADD=-lpthread AM_CFLAGS=-DMY_DEFINE foo1extradir=$(datadir)/foo1 foo1extra_DATA= foo1.conf
  • 16. Makefile.am Libraries Installation Libraries lib_LTLIBRARIES=libtest.la library_includedir= The directory where header files will be installed library_include_HEADERS= Header files exposed by the library Non-installation libraries noinst_LTLIBRARIES= libtest_la_SOURCES = libtest_la_LDFLAGS = INCLUDES = -I. libtest_la_LIBADD= (other libraries to add)
  • 17. Makefile.am Predefined variables $(top_srcdir) : Main directory of source-code $(includedir) : Path specified in configure for installing header files SUBDIRS =
  • 18. configure.ac Set of M4 Macros Initialization AC_PREREQ AC_INIT AC_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE Checks for programs AC_PROG_CC AC_PROG_CXX AC_PROG_INSTALL AM_PROG_LIBTOOL AM_SANITY_CHECK
  • 19. configure.ac Checks for libraries pkg-config PKG_CHECK_MODULES(SNDFILE_DEPS, sndfile >= 1.0.17) AC_SUBST(SNDFILE_DEPS_CFLAGS) AC_SUBST(SNDFILE_DEPS_LIBS) AC_SUBST passes variable from configure.ac to Makefile.am
  • 20. configure.ac No script AC_CHECK_LIB AC_ARG_WITH(mysql, [ --with-mysql=<path> prefix of MySQL installation. e.g. /usr/local or /usr], [MYSQL_PREFIX=$with_mysql], AC_MSG_ERROR([You must call configure with the --with-mysql option. This tells configure where to find the MySql C library and headers. e.g. --with-mysql=/usr/local or --with-mysql=/usr])) AC_SUBST(MYSQL_PREFIX) MYSQL_LIBS=&quot;-L${MYSQL_PREFIX}/lib/mysql -lmysqlclient&quot; MYSQL_CFLAGS=&quot;-I${MYSQL_PREFIX}/include&quot; AC_SUBST(MYSQL_LIBS) AC_SUBST(MYSQL_CFLAGS)
  • 21. configure.ac Checks for header files AC_HEADER_STDC AC_CHECK_HEADERS([string.h]) Checks for typedefs, structures, and compiler characteristics Checks for library functions AC_CHECK_FUNCS([bzero]) Give Makefile to generate AC_CONFIG_FILES([Makefile]) AC_OUTPUT
  • 22. configure.ac Adding option in configure script AC_ARG_ENABLE(option-foo,[ --enable-option-foo help for option foo], [CFLAGS= &quot;$CFLAGS -DOPTION_FOO_DEFINE&quot;], []) Disable shared libraries AC_DISABLE_SHARED
  • 23. References http://www.elitecoders.de/mags/cscene/CS2/CS2-10.html http://www.openismus.com/documents/linux/automake/automake.shtml http://www.openismus.com/documents/linux/using_libraries/using_libraries.shtml http://www.openismus.com/documents/linux/building_libraries/building_libraries.shtml http://bec-systems.com/web/content/view/95/9/ http://sources.redhat.com/autobook/autobook/autobook_toc.html#SEC_Contents http://www.gnu.org/manual/manual.html Examples http://www.openismus.com/documents/linux/building_libraries/examplelib-0.3.0.tar.gz http://www.openismus.com/documents/linux/using_libraries/examplelib_example-0.3.0.tar.gz
  • 24. Summary You can generate distributions in tar.gz or rpm