Makefile generatation with Autotools

Add to Favourites
Post to:

Makefile generation from Autotools Waqqas JabbarPrerequisites C, C++ gcc and its options make and Makefile configure and its options pkg-configObjectives Use autotools to generate Makefiles, for Dynamic and Static libraries Executable Use libtool to generate librariesAutotools Collection of utilities automake autoconf libtoolize aclocal autoheader autoscan autoupdate autoreconf Can be used separately or togetherInputs to autotools configure.ac Makefile.ac config.h.in Source codeOutputs of autotools config.h Added in project Conditional compilation #ifdef, #elif, #endif Makefile(s) Input to makeconfig.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 configureautoscan Input: Source code Output: configure.scan Template for configure.acautoheader 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 valuesautoconf Input: configure.ac Output: configure Shell scriptconfigure Input: config.h.in, Makefile.in Output: config.h, Makefile(s)Makefile.in Syntax of MakefileMakefile.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.confMakefile.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_CHECKconfigure.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.amconfigure.ac No script AC_CHECK_LIB AC_ARG_WITH(mysql, [ --with-mysql= 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 --withmyssql=usr])) AC_SUBST(MYSQL_PREFIX) MYSQL_LIBS="-L${MYSQL_PREFIX}/lib/mysql -lmysqlclient" MYSQL_CFLAGS="-I${MYSQL_PREFIX}/include" 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_OUTPUTconfigure.ac Adding option in configure script AC_ARG_ENABLE(option-foo,[ --enableopttionfoo help for option foo], [CFLAGS= "$CFLAGS -DOPTION_FOO_DEFINE"], []) Disable shared libraries AC_DISABLE_SHAREDReferences 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/buil ding_libraries.shtml http://bec-systems. Summary You can generate distributions in tar.gz or rpmThank You

Description
How to generate makefiles using autotools

Comments

Want to learn?

Sign up and browse through relevant courses.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
1 Follower

Your Facebook Friends on WizIQ

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect