Last time I was little bit too hard to autotools. Okay they are not easy but they work. I also let last time people to figure how to get a long with autotools. Now I show how I do it.
First put some good music on and relax. Starting new project and trying to get it compile is very unpleasant experience. Then read blog about autotools and then also see example that I’ve been using. Now you should have files: ‘configure.ac’, ‘Makefile.am’, ‘SDL_DisplayBitmap.c’, ‘LICENSE.TXT’ and ‘image.bmp’ in same directory/folder also you should have rpm libSDL_image-devel installed. Then we zypper needed autotools in.
zypper install libtool automake autoconf
after that we need to make directory contain needed scripts and M4-macros. You don’t need to copy them manually just make like this in console:
aclocal --force libtoolize -c automake --copy --add-missing autoconf --force
So we run ‘aclocal’ to copy those M4-macros after that we ‘libtoolize’ our directory and then ‘automake’ creates needed ‘Makefile.in’ files from ‘Makefile.am’. Last ‘autoconf’ creates configure-script from configure.ac. If everything went fine you ca continue:
./configure make ./SDL_DisplayBitmap
Okay now it should work as expected. If you are interested you can try also
and you should have ‘SDL_DisplayBitmap-1.0.tar.gz’ and ‘SDL_DisplayBitmap-1.0.tar.bz2’ to distribute you application.
Let’s dig further
I’ll explain what these sentences mean in ‘configure.ac’:
Just tell what Autoconf is needed at least 2.57 and what is M4-macro directory (in this case it’s ‘m4’)
AC_INIT([SDL_DisplayBitmap], [1.0], [http://lizards.opensuse.org])
Let’s have application named SDL_DisplayBitmap which version is 1.0 and URL to see something more is http://lizards.opensuse.org
Initialize automake. We want ‘tar.bz2’ package also made.
AC_LANG_C AC_PROG_CC AM_PROG_LIBTOOL
Make sure we have C++ and C-compiler and Libtools.
C_OPTIONS="-ansi -Wall -Werror -std=c99 -fno-strict-aliasing"
I use these C-Flags in my applications. You should use yours.
Make them available in Makefile.in/.am
Check SDL_image from pkg-config and store it in SDL-prefix (SDL_LIBS and SDL_CFLAGS) variable.
Configure these files from configure here. In our case only use formulate Makefile.in file.
Now it’s time to listen Scorpions Still loving you if don’t already listening it.
INCLUDES = $(SDL_CFLAGS) $(C_OPTIONS)
This actually old school way of doing it but it compatible downwards. We but our C_OPTIONS from configure.ac and SDL needed build flags in build.
EXTRA_DIST = LICENSE.TXT image.bmp
We also pack these files in distribution tar-ball.
noinst_PROGRAMS = SDL_DisplayBitmap
This tell we want to have binary named: ‘SDL_DisplayBitmap’ that ain’t installed anywhere. If you but bin_PROGRAMS application will be installed to ‘/usr/local/bin’ or ‘prefix/bin’ you mentioned in ‘./configure –prefix=/prefix’ (sbin_PROGRAMS will install it to ‘/usr/local/sbin’).
SDL_DisplayBitmap_SOURCES = SDL_DisplayBitmap.c SDL_DisplayBitmap_LDFLAGS = $(SDL_LIBS)
Actually tell what sources belongs to SDL_DisplayBitmap and what libs are need to build this.
Yes that was so easy and nice. Next time is time to make RPM from our example application.
Both comments and pings are currently closed.