Gnubs pres-foss-cdac-sem


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Gnubs pres-foss-cdac-sem

  1. 1. Presentation on GNU Build System for (FOSS) From the Open Source Shelf CDAC Monthly Seminar Series Presented by Sagun Baijal Organised by CDAC, Kharghar, Navi Mumbai E-mail:
  2. 2. WELCOME
  3. 3. Overview Background Why GNU Build System Introduction to GNU Build System Using GNU Build System Conclusion References
  4. 4. Background • Typical Methods of installing a software in Unix- like systems • Installation by using a package manager • Installtion from source code • GNU standard method of installation • Packages normally come as a tarball. • Decompress the package. • Run configure script e.g. ...:~$./configure • Run make e.g. ...:~$make • Run make install e.g. ...:~$sudo make install
  5. 5. Background contd... • Issues while packaging the system for release • Naming and Versioning of the package. • Portability of system on a variety of platforms. • Configuration script configure with standrad configurations options. • Makefile.inS required by configure script. • Conformity of Makefile and directory layout as per GNU standards. • Necessary documentation files and tests. • Bundling of the package into a tarball. • Licensing of the system.
  6. 6. Why GNU Build System • Creating a configuration script and Makefiles from scratch is a tedious, time-consuming and error-prone task. • Some users may be left unsatisfied due to unavailability of some desired features. • It may be needed to upgrade the overall setup to follow the changes to the GNU Coding Standards.
  7. 7. Contd... • GNU Build System helps: • simplify the development of portable programs. • simplify the building of programs distributed as source code. • Any bux fixes and improvements can be made at one place. • Users don't require any utilities of build system at their end.
  8. 8. Introduction to GNU Build System • GNU Build System comprises: • autoconf: For generating configuration script configure. • automake: For generating makefile templates Makfile.inS • libtool: Helps creating the portable compiled libraries. • Some other auxilary tools: • Autoscan: For generating intial input file for autoconf. • Autoheader: For generating template header for configure. • aclocal: For generating aclocal.m4.
  9. 9. Contd... • Installation: • To check, if installed in their most recent versions: • ...:~$autoconf - -version • ...:~$automake - -version • ...:~$libtool - -version • If not installed, then (on any debian-like system): • ...:~$apt-cache search <tool-name> - searches for the tool-name in available package list. • ...:~$sudo apt-get install <tool-name> - installs the <tool-name>.
  10. 10. Using GNU Build System • Basic requirements: Source and documentation files of the package. • • One as initial input file for autoconf. • One for each directory in the package. • Source and Documentation files: • Files containing source code and necessary documentation to be distributed in the package. • Ex.: .c, .cpp files, README etc..
  11. 11. Contd... • What is • Initial input file for autoconf to generate configure script. Also used by automake, while creating Makefile.amS. • Contains macros needed to test the system features required or used by the package. • Using autoscan: • autoscan scans source files and creates configure.scan. • After making some adjustments, if required, configure.scan can be renamed to • Adjustments may be like adding some missing macros or changing the order of some macros etc..
  12. 12. Contd... • Common macros: • AC_PREREQ: specifies the minimum version of autoconf that can successfully compile a given • AC_INIT: initializes autoconf. • AM_INIT_AUTOMAKE: initializes automake. • AC_PROG_CC: determines a C compiler to use and sets output variable CC to its value. • AC_PROG_CXX: determines a C++ compiler to use and sets output variable CXX to its value. • AC_CONFIG_HEADER: causes to create a config.h file gathering ‘#define’s defined by other macros in • AC_CONFIG_FILES: declares the list of files to be created from their *.in templates. • AC_OUTPUT: generates and runs config.status, which in turn creates the makefiles and any other files resulting from configuration.
  13. 13. Contd... • Example AC_PREREQ(2.61) AC_INIT([hello], [0.1], []) AM_INIT_AUTOMAKE([-Wall -Werror]) AC_PROG_CC AC_CONFIG_HEADER([config.h]) AC_CONFIG_FILES([ Makefile src/Makefile ]) AC_OUTPUT
  14. 14. Contd... • What is • Initial input file for automake to generate • One for each directory in package including root directory. • Normally contains a list of variable (and rule) definitions required when make is invoked. • Common Makefile targets: • make all: Build programs, libraries, documentation, etc. • make install: Install what needs to be installed, copying the files from the package's tree to system- wide directories.
  15. 15. Contd... • make uninstall: The opposite of make install: erase the installed files. • make clean: Erase from the build tree the files built by make all. • make distclean: Additionally erase anything ./configure created. • make check: Run the test suite, if any. • make installcheck: Check the installed programs or libraries, if supported. • make dist: Recreate package-version.tar.gz from all the source files.
  16. 16. Contd... • Common variables for • bin_PROGRAMS: specifies the <program> to be built and installed on .../bin directory. • <program>_SOURCES: lists one or more source files compiled to build the <program>. • SUBDIRS: lists all sub-directories to be built. • dist_doc_DATA: lists documentation files to be distributed and installed in ../doc directory. • <program>_DEPENDENCIES: specifies dependencies, if any. • <program>_<FLAGS>: various compilation flags can be set.
  17. 17. Contd... • <program>_LDADD: specifies extra objects and libraries to be added with <program>. • <program>_LDFLAGS: specifies extra linker flags for <program>. • An example bin_PROGRAMS = hello hello_SOURCES = hello.c
  18. 18. Contd... • Some characteristics of GNU Build System: • VPATH Builds: When source tree and build tree are different, such builds are called VPATH builds. • Cross-compilation: When a program is built on one platform and run on another platform is called cross-compilation. • Renaming: GNU build system allows to automatically rename executables etc. before installation. • Dependency tracking: GNU build system allows to track dependencies automatically. • Nested packages: Autoconfiscated packages can be nested to arbitrary depth.
  19. 19. Contd... • Applying tools to create the package: • Ensure all necessary source, documentation and Makefiel.amS files have been created. • Run autoscan to create prelimanary configure.scan. • ..:~/<pkg-dir>$autoscan • If required, edit configure.scan to update package- name, version, invocation to AM_INIT_AUTOMAKE macro etc. and rename it to • Run aclocal to create aclocal.m4. This file contains macro definitions not part of standard autoconf macros. • ..:~/<pkg-dir>$aclocal
  20. 20. Contd... • Run autoheader to create This file is a template header for configure. • ..:~/<pkg-dir>$autoheader • Run autoconf to create configure from and aclocal.m4. • ..:~/<pkg-dir>$autoconf • Run automake to create Makefile.inS from Makefile.amS. • ..:~/<pkg-dir>$automake • Run configure to create Makefiles from Makefile.inS, config.h from and perform various checks about the environment. • ..:~/<pkg-dir>$./configure
  21. 21. Contd... • Now run make to build the system. • ..:~/<pkg-dir>$make • If make executes successfully, run make distcheck to create the package for distribution as a tarball. • ..:~/<pkg-dir>$make distcheck • Run make install to install the package. • ..:~/<pkg-dir>$sudo make install • Run make uninstall to uninstall the package. • ..:~/<pkg-dir>$sudo make uninstall
  22. 22. Conclusion • From User's point of view: • provides a standard procedure for installation. • procedure consists of only a small set of commands. • From Developer's point of view: • Creating portable distributions become easy. • Updations or improvements, if any, can be done at one place.
  23. 23. References     Invocation.html#autoscan-Invocation      Index.html  Software/9/   
  24. 24. Thank You E-mail: