DragonFly On-Line Manual Pages

Search: Section:  


()                                                                          ()

CONFIGURING PACKAGES TO WORK WITH VDK -------------------------------------

Compiling a program succesfully against the VDK libraries can require a large
number of command line options to your compiler and linker that are hard to
guess correctly.  The additional libraries required may, for example, depend
on the manner which VDK was configured

Several tools are included in this package to make process easier.

First, there is the shell script 'gtk-config' (installed in $exec_prefix/bin):

Invoking vdk-config-2 -------------------

vdk-config-2 takes the following flags:

  --version
     Prints out the version of VDK installed

  --help
     Prints out a short help

  --cflags
     Prints '-I' flags pointing to the installed header files

  --libs
     Prints out the linker flags necessary to link a program against GTK

  --libs-only-L
     Prints out the -L-R part of --libs

  --libs-only-l
     Prints out the -l part of --libs

  --prefix[=PREFIX]
     If PREFIX is specified, overrides the configured value of $prefix.
     (And of exec-prefix, unless --exec-prefix is also specified)
     Otherwise, prints out the configured value of $prefix

  --exec-prefix[=PREFIX]
     If PREFIX is specified, overrides the configured value of $exec_prefix.
     Otherwise, prints out the configured value of $exec_prefix

Example of using vdk-config-2 ---------------------------

Typically, vdk-config-2 will be used within a configure script, as described
below. It, however, can also be used directly from the command line to compile
a simple program. For example:

  cc -o simple `vdk-config-2 --cflags` simple.c `vdk-config-2 --libs`

This command line might expand to (for example):

  cc -o simple -I/usr/local/lib/glib/include -I/usr/local/include
-I/usr/X11R6/include simple.c -L/usr/local/lib -L/usr/X11R6/lib     -lvdk
-lvdkcompo -lgtk -lgdk -lglib -lXi -lXext -lX11 -lm

Not only is the form using vdk-config-2 easier to type, it will work on any
system, no matter how VDK was configured.

AM_PATH_VDK -----------

For packages configured using GNU automake, VDK also provides a macro to
automate the process of running VDK.

 AM_PATH_VDK_2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])

This macro:

 * Determines the location of VDK using vdk-config-2, which is either
   found in the user's path, or from the environment variable
  VDK_CONFIG

 * Tests the installed libraries to make sure that there version
   is later than MINIMUM-VERSION. (A default version will be used
   if not specified)

 * If the required version was found, sets the VDK_CFLAGS variable to
   the output of `vdk-config-2 --cflags` and the VDK_LIBS variable to
   the output of `vdk-config-2 --libs`, and calls AC_SUBST() for these
   variables so they can be used in generated makefiles, and then
   executes ACTION-IF-FOUND.

 * If the required version was not found, sets VDK_CFLAGS and VDK_LIBS
   to empty strings, and executes ACTION-IF-NOT-FOUND.

This macro is in file 'vdk.m4' which is installed in $datadir/aclocal.  Note
that if automake was installed with a different --prefix than VDK, you will
either have to manually move vdk.m4 to automake's $datadir/aclocal, or give
aclocal the -I option when running it.

Configuring a package that uses AM_PATH_VDK
-------------------------------------------

Simply make sure that vdk-config-2 is in your path, and run the configure
script.

Notes:

* The directory where the VDK libraries are installed needs
  to be found by your system's dynamic linker.

  This is generally done by

    editing /etc/ld.so.conf and running ldconfig

  Or by:

    setting the environment variable LD_LIBRARY_PATH,

  or, as a last resort,

    Giving a -R or -rpath flag (depending on your linker) when
    running configure, for instance:

      LDFLAGS=-R/usr/home/vdk/lib ./configure

* You can also specify a vdk-config-2 not in your path by
  setting the VDK_CONFIG environment variable to the
  name of the executable

* If you move the VDK package from its installed location,
  you will need either need to modify vdk-config-2 script
  manually to point to the new location or rebuild VDK.

Advanced note:

* configure flags

  --with-vdk-prefix=PREFIX
  --with-vdk-exec-prefix=PREFIX

  are provided to override the prefix and exec-prefix that were stored
  in the vdk-config-2 shell script by VDK's configure. You are generally
  better off configuring VDK with the right path to begin with.

Example of a package using AM_PATH_VDK_2
----------------------------------------------------------

The following shows how to build a simple package using automake and the
AM_PATH_VDK macro. The program used here is the testinput.c

You should first read the introductory portions of the automake Manual, if you
are not already familiar with it.

Two files are needed, 'configure.in', which is used to build the configure
script:

==configure.in=== dnl Process this file with autoconf to produce a configure
script.  AC_INIT(testinput.c)

AM_INIT_AUTOMAKE(testinput.c, 1.0.0)

AC_PROG_CC AM_PROG_CC_STDC AC_PROG_INSTALL

AM_PATH_VDK_2(2.0.0,
          [LIBS="$LIBS $GTK_LIBS"
           CFLAGS="$CFLAGS $VDK_CFLAGS"],
       AC_MSG_ERROR(Cannot find VDK: Is vdk-config-2 in path?))

AC_OUTPUT(Makefile) =================

The only command in this which is not standard for automake is the
AM_PATH_VDK_2() macro.

That command does the following:

 If a VDK version greater than 2.0.0 is found, adds $VDK_LIBS to
 $LIBS and $VDK_CFLAGS to $CFLAGS. Otherwise, dies with the error
 message "Cannot find VDK: Is vdk-config-2-2 in path?"

And the 'Makefile.am', which will be used to build the Makefile.

== Makefile.am == bin_PROGRAMS = testinput testinput_SOURCES = testinput.c
=================

This Makefile.am, says that we are building a single executable, from a single
sourcefile 'testinput.c'. Since every program we are building uses VDK we
simply added the VDK options to $LIBS and $CFLAGS, but in other circumstances,
we might want to specify them on a per-program basis: for instance by adding
the lines:

  testinput_LDADD = $(VDK_LIBS)
  INCLUDES = $(VDK_CFLAGS)

to the Makefile.am.

Now execute the following commands:

  automake --add-missing
  aclocal
  autoconf

You now have a package that can be built in the normal fashion

  ./configure
  make
  make install

                                        VDK Team

[Note: this file is stolen and adapted to VDK from gtk/docs/gtk-config.txt
written for gtk-config script written by Owen Taylor]

                                                                            ()

Search: Section: