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

# I want to add some configure stuff, how could I do this? [GTK 2.x]

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

- the m4 preprocessor v1.4 or better
- autoconf v2.54 or better
- automake v1.7 or better suggested

You'll find these packages on the main GNU 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)
    AM_INIT_AUTOMAKE(mypkgname, 0.0.1)
    AM_CONFIG_HEADER(config.h)

    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_2_0(2.2.0,,AC_MSG_ERROR(mypkgname 0.1 needs GTK+ 2.2.0))

    AC_OUTPUT(
    	Makefile
    )

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. [GTK 2.x] | Up | I try to debug my GTK+ application with gdb, but it hangs my X server when I hit some breakpoint. Any Idea? [GTK 2.x]