Home Home > 2013 > 11 > 12 > openSUSE and GCC part 6: Introduction to autotools
Sign up | Login

openSUSE and GCC part 6: Introduction to autotools

November 12th, 2013 by

Autotools, autotools and once again autotools. Years ago I started with autotools I thought, ‘Hey someone has really get into linking and compiling’. I was sold for a while and tried to learn it inside out. Then I understood that I will never be good at autotools (So I started to go to gym instead). M4 macro language it is not my thing.
It’s just something that should be put on one way Mars shuttle and send to gray ones to figure out. I think mr. Spock’s brains functioned with M4 but mine won’t. If there is some M4 specialist. Send me e-mail or post comment about it and tell why M4 is best macro language on earth. If nobody stands up for poor M4-macro language I’ll keep unloving it. I can start liking it because I was so wrong with Rexx.

Autotools

Autotools are designed to work with GNU GCC (GNU Compiler Collection) and visa versa. You can use Autotools with any C-compiler or with any language but it works best when compiling GNU C or C++ applications. Autotools are actually four tools aclocal, libtool, autoconf and automake.

GNU aclocal

It’s easier to tell what aclocal is not than what it is. Aclocal checks your needed M4 macros and copies or symlinks them to your project. I hope you never need to tackle with this or write your own M4 macro for find you great library (use pkg-config I say it once more use pkg-config) or new something that other M4 macros sucks to do. I don’t have anything else to say about this.

GNU libtool

If you like to make Share Objects (.so), Windows DLL or something your operating system supports libtool is your friend. You’ll need this anyways wanted or not.

GNU autoconf

This one is also strange tool. I compiles from M4 macros an ‘configure’-named bash script. So you have ‘configure.ac’ M4 based script that is formulated to ‘configure’-named bash script and autoconf does that.

GNU automake

Last time we talked about Makefiles and how to use them with compiling. Autotools is make based. You can probably use other build tools but I never have seen them in use. Automake seeks for ‘Makefile.am’ files and turns macros and stuff inside them to ‘Makefile.in’ that is usable with ‘configure’-script from autoconf. Actually its not that simple but with this you can live you life happilly ever after.
Because everyone wants to know everything these days read more here.

And this was complicated you moron!

Yes I can admit it! I’m not very clever guy. When I was young I though hell there ain’t nobody that I better than me. Now I can admin there is and I’m just a ordinary guy from Finland. So you think you are more clever than me okay let’s test it. I’ll just throw you a bone and you tackle with by yourself and search machine (I won’t use that G-word there is so many other ones also). Example is the same that have been use in other posts and all the needed info is here so you should be able to figure this out by yourself and ask from mr. NSA the rest. Here are configure.ac and Makefile.am but how to utilize them? Good question.. hmm.. use zypper to install automake.. maybe.. maybe?

configure.ac

AC_PREREQ([2.57])
AC_CONFIG_MACRO_DIR([m4])
AC_INIT([SDL_DisplayBitmap], [1.0], [http://lizards.opensuse.org])
AM_INIT_AUTOMAKE([foreign dist-bzip2])

EXTRA_DIST = LICENSE.TXT image.bmp

AC_LANG_C
AC_PROG_CC
AM_PROG_LIBTOOL

C_OPTIONS="-ansi -Wall -Werror -std=c99 -fno-strict-aliasing"

AC_SUBST(C_OPTIONS)

PKG_CHECK_MODULES(SDL, SDL_image)

AC_OUTPUT([Makefile])

Makefile.am

INCLUDES = $(SDL_CFLAGS) $(C_OPTIONS)

EXTRA_DIST = LICENSE.TXT image.bmp

noinst_PROGRAMS = SDL_DisplayBitmap

SDL_DisplayBitmap_SOURCES = SDL_DisplayBitmap.c
SDL_DisplayBitmap_LDFLAGS = $(SDL_LIBS)

Now you have everything and go for the bad thing. Next time I’ll tell how I do it..

Both comments and pings are currently closed.

2 Responses to “openSUSE and GCC part 6: Introduction to autotools”

  1. Ugh… I think I’ll stay with qmake.

  2. Qmake is actually very neat system if you have QT available. I recommend CMake but I think I should also cover QMake because it’s easy way to build cross-platform apps.