• Argument pass to automake

    Building automake steps


    1. Generate aclocal.m4 with aclocal \

    the file contain all AUTOMAKE’s Macro which is needed in building process
    aclocal also scan configure.ac to put needed macro to aclocal.m4 file

2. Autoconf use aclocal.m4 with it’s macro to generate configure program

autoheader generate header in ( AC_CONFIG_HEADERS parameter conifgure.ac) automake –add-missing . it is used for create makefile.in.

3. ./configure to create Makefile follow what configure.ac list up

simpler step :

  1. call autoreconf -iv ( create depencency and Makefile.in )
  2. ./configure ( create Makefile )
  3. make ( run as normal Makefile = make all)

Argument pass to automake


In configure.ac create variable with AM_CONDITIONAL\

#configure.ac
AM_CONDITIONAL([MY_FLAG_SET], [test "%MY_FLAG" = "Y"])

#Makefile.am where need check argument MY_FLAGS
if MY_FLAGS_SET
AM_CFLAGS += -DMY_FLAGS_SET
else
AM_CFLAGS += -DNO_FLAGS_SET
endif

Advance argument passing argument


We can use flag & alert with AC_ARG_ENABLE instead pass argument directly

AC_ARG_ENABLE([debug],
[  --enable-debug    Turn on debugging],
[case "${enableval}" in
  yes) debug=true ;;
  no)  debug=false ;;
  *) AC_MSG_ERROR([bad value ${enableval} for --enable-debug]) ;;
esac],[debug=false])
AM_CONDITIONAL([DEBUG], [test x$debug = xtrue])

After update configure.ac and Makefile.am. we follow seqence cmd :

  1. autoreconf -iv
  2. ./configure MY_FLAGS_SET=Y
  3. make

Building a program


Follow below template form

Linking the program


LDADD , prog_LDADD this variable is used to specify additional object files or libraries to link with

example with static lib

EXAMPLE

GNU Libtool

Libtool abstracts shared and static libraries into a unified concept . with .la prefix and object file .lo in buiding process

With .la prefix . it’s easier on multiple platform ( Windows, Linux, Cygwin,… ) instead of .dll ( only windows) . .so (only Linux)

example with libtool EXAMPLE

_LIBADD, _LDFLAGS, and _LIBTOOLFLAGS

The library_LIBADD variable should be used to list extra libtool objects (.lo files) or libtool libraries (.la) to add to library.

The library_LDFLAGS variable is the place to list additional libtool linking flags, such as -version-info, -static, and a lot more OPTIONS

The library_LIBTOOLFLAGS . many options are special libtool’s options at OPTIONS

library_LDFLAGS usually is used.

NOTE


Automake always uses two of these variables when compiling C sources files. When compiling an object file for the mumble target, the first variable will be prog_CPPFLAGS if it is defined, or AM_CPPFLAGS otherwise. The second variable is always CPPFLAGS .

The foreign option tells Automake that this package will not follow the GNU Standards. GNU packages should always distribute additional files such as ChangeLog, AUTHORS, etc. We do not want automake to complain about these missing files in our small example.

AC_SUBST can export shell variable . it’s useful when we pass argument to ./configure process . Not only flag ‘y’ or ‘n’ ex

AC_SUBST(LONG_FLAGS, ["$MY_FLAGS"]) vs AM_CONDITIONAL([LONG_FLAGS, [test "$MY_FLAGS = "y"])

Libtool Convenience Libraries ,Unlike installed libtool libraries they do not need an -rpath flag at link time