GTK+ FAQ
<<< Previous | Development with GTK+: the begining | Next >>>

# I want to add some configure stuff, how could I do this?

To use autoconf/automake, you must first install the relevant packages. These are:

- the m4 preprocessor v1.4 or better
- autoconf v2.13 or better
- automake v1.4 or better

You'll find these packages on the GNU main ftp server (ftp://ftp.gnu.org/) or on any GNU mirror.

In order to use the powerful autoconf/automake scheme, you must create a configure.in which may look like:

    dnl Process this file with autoconf to produce a configure script.
    dnl configure.in for a GTK+ based program

    AC_INIT(myprg.c)dnl
    AM_INIT_AUTOMAKE(mypkgname,0.0.1)dnl
    AM_CONFIG_HEADER(config.h)dnl

    dnl Checks for programs.
    AC_PROG_CC dnl check for the c compiler
    dnl you should add CFLAGS="" here, 'cos it is set to -g by PROG_CC

    dnl Checks for libraries.
    AM_PATH_GTK(1.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK))dnl

    AC_OUTPUT(
    	Makefile
    )dnl

You must add a Makefile.am file:

    bin_PROGRAMS    = myprg
    myprg_SOURCES   = myprg.c foo.c bar.c
    INCLUDES        = @GTK_CFLAGS@
    LDADD           = @GTK_LIBS@
    CLEANFILES      = *~
    DISTCLEANFILES  = .deps/*.P

If your project contains more than one subdirectory, you'll have to create one Makefile.am in each directory plus a master Makefile.am which will look like:

    SUBDIRS         = mydir1 mydir2 mydir3

then, to use these, simply type the following commands:

    aclocal
    autoheader
    autoconf
    automake --add-missing --include-deps --foreign

For further information, you should look at the autoconf and the automake documentation (the shipped info files are really easy to understand, and there are plenty of web resources that deal with autoconf and automake).

<<< Previous | Home | Next >>>
I use the backquote stuff in my makefiles, but my make process failed. | Up | I try to debug my GTK+ application with gdb, but it hangs my X server when I hit some breakpoint. Any Idea?