next up previous contents
Next: The conduit factory Up: The general conduit framework Previous: A conduit is a   Contents

Makefile.am and KDE build process

Before we delve into programming details, let us look a bit at the compilation framework.

If you develop your conduit inside the kdepim/kpilot/conduits directory of KDE's CVS tree, all you need to do is to provide a Makefile.am in your conduit directory (e.g. kdepim/kpilot/conduits/malconduit), and add the name of your directory (malconduit in this example) to the variable SUBDIRS in kdepim/kpilot/conduits/Makefile.am:

SUBDIRS = knotes expense null vcalconduit \
          popmail timeconduit malconduit


The Makefile.am in your conduit's directory will look similar to the following one (taken from the malconduit). Since this is a tutorial on KPilot conduits, and not on automake/conf, make and Makefiles, I will not explain it in detail. However, it should be easy to adapt it to your conduit's needs:

### Makefile for the AvantGo conduit
###
### The mal conduit is Copyright (C) 2002 by Reinhold Kainhofer


INCLUDES= $(PISOCK_INCLUDE)  $(MAL_INCLUDE) \
  -I$(top_srcdir)/kpilot/lib $(all_includes)
METASOURCES = AUTO

servicedir = $(kde_servicesdir)
service_DATA = mal_conduit.desktop

kde_module_LTLIBRARIES = libmalconduit.la

libmalconduit_la_SOURCES = \
        mal-factory.cc \
        mal-setup.cc \
        mal-conduit.cc \
        mal-setup_dialog.ui
libmalconduit_la_LDFLAGS = $(KDE_RPATH) -L../../lib
libmalconduit_la_LIBADD = -lkpilot $(MAL_LIB)

Here is a short table of the variables used in Makefile.am:

service_DATA name of the desktop file of your conduit
  (tells KDE which library it needs to load)
kde_module_LTLIBRARIES tell make which libraries to compile
libraryname_SOURCES a list of all source files to be compiled into
  libraryname (where a . is replaced by a _)
libraryname_LDFLAGS linker flags when linking your conduit
libraryname_LIBADD additional libraries the conduit links to
  (-lkpilot is the KPilot base library and
  needs to be linked to every conduit)



Both MAL_INCLUDE and MAL_LIB are special variables pointing to the headers and the library of libmal, and are set by configure.in.in (see below).



If you have special library requirements (e.g. the malconduit needs libmal to work), you need to add special configure checks to the autoconf file kdepim/kpilot/conduits/configure.in.in (for an example, you should look at the checks the malconduit added to the file in CVS) and include the directory only if the appropriate libraries and header files are installed. One way to achieve this is to add the following line after your configure checks, which set the variable HAVE_MAL to 1. This automake command in configure.in.in defines "include_malconduit" for use in Makefile.am, if HAVE_MAL==1:

AM_CONDITIONAL(include_malconduit, test "$HAVE_MAL" = "1")

You can then use "include_malconduit" in the KPilot conduit directory's makefile kdepim/kpilot/conduits/Makefile.am:

MALSUBDIR=
if include_malconduit
    MALSUBDIR = malconduit
endif

SUBDIRS = knotes expense null vcalconduit popmail timeconduit $(MALSUBDIR)


next up previous contents
Next: The conduit factory Up: The general conduit framework Previous: A conduit is a   Contents
Reinhold Kainhofer 2003-01-13