Packaging and Submitting Code to KDE

Prev Next

Chapter 5. Packaging and Submitting Code to KDE

Packaging

'Packaging' means putting your (in this case source) code into some format that is

  • easy for others to configure and install, and

  • easy to transfer,

  • can be indexed so that it is easy to find.

These three concepts are expanded upon in the next three subsections.

GNU Configure

The standard KDE application (or other code) source code package includes the GNU configure script which determines some information about the user's system and provides it to your source code as #define statements in a header file called config.h.

To get started with this, get the kdesdk from CVS using a method described above. Then prepare kexample, an example package, for your application

   cd kdesdk
   cd kexample
   make -f Makefile.cvs
   cd ..; cp -r kexample ~/KDE/kmyapp-0.0.1
(That last directory is just an example. Replace kmyapp with your application's (or widget's) name, and replace 0.0.1 with its version number.)

Now, we'll put your source code into the example package. Let's say your source code was in the directory ~/KDE/KMyApp:

   cd ~/KDE/kmyapp-0.0.1
   mkdir kmyapp
   cp ~/KDE/KMyApp/*.cpp kmyapp
   cp ~/KDE/KMyApp/*.h kmyapp
   (There may be other files to copy, but leave your old Makefile behind!)
Now, edit kmyapp-0.0.1/Makefile.am and change the line
   SUBDIRS = kexample
to
   SUBDIRS = kmyapp

Note

kmyapp here refers to the subdirectory of the same name.

You could include more subdirectories to be compiled. For example:
   SUBDIRS = kmyapp kmysupportclass
Also edit the last line of configure.in to read
AC_OUTPUT(Makefile \
          kmyapp/Makefile \
          po/Makefile)
The po directory contains translations of strings that you used in your code (this is about i18n(), which is not covered in this HOWTO). We'll get to that directory it a minute.

Now we want to set up the Makefile for the kmyapp subdirectory. Edit kmyapp/Makefile.am according to the instructions given in the comments. They should be clear enough. Now cd ~/KDE/kmyapp and type

   ./configure
This should create:
  • Makefile

  • kmyapp/Makfile

  • config.h

You can now include config.h in your source code with #include "../config.h" and have your code compile differently on different systems based on the #defines. Eh? Well, different systems have slightly differnent ideas about implementing standards and such, and your code may need take this into account to be portable, i.e. to work on various Unices. Take a look inside config.h for descriptions of the #defines.

Shared Libraries!

If you are packaging a widget or other class you should be compiling a shared library. Luckily, this is easy to do within the kexample packge. You only need to change the Makefile.am that resides in your code's sudirectory. Unluckily, no example for a shared-library Makefile.am is included. So, I've included one in the next section.

Note

If you distribute a widget, you should also distribute a small program which tests and demonstrates use of the widget. Put that program in the same package in another subdirectory and have it compile along with the widget.

Next, make a compressed archive. You can do it this way

   cd ~/KDE/kmyapp
   make dist
   OR
   tar -cvf kmyapp-0.1.1.tgz kmyapp-0.1.1
or however you like. Just be sure that the archive expands to one directory containing all of the files. This is neater and easier for the user to deal with.

Example Makfile.am for a Shared Library

# Example Makefile.am for a shared library.  It makes a library
#  called "example" as libexample.so.2.1.2
# This Makefile.am was taken from the kdelibs distribution and modified
#  to serve as an example.
#
# David Sweet
#

INCLUDES=  $(all_includes)

lib_LTLIBRARIES  = libexample.la

# Note:  If you specify a:b:c as the version in the next line,
#  the library that is made has version (a-c).c.b.  In this
#  example, the version is 2.1.2.
libexample_la_LDFLAGS = -version-info 3:2:1 $(all_libraries)

include_HEADERS = header1.h header2.h\
                  header3.h

# Which headers shouldn't be installed when a   make install  is done?
noinst_HEADERS = version.h

libexample_la_SOURCES = code1.cpp code2.cpp
                        code3.cpp

#  AUTO is great.  This takes care of all of your  moc'ing
#   dependencies.
#  (You still need to include, for example, header1.moc in code1.cpp.)
libexample_la_METASOURCES = AUTO

LSM file

Next, you need and LSM file. You can keep a copy in kmyapp-0.1.1 for distribution. Here's a sample .lsm:


Begin3
title:          KLab
Version:        0.1.0
Entered-date:   3/1/99
Description:    GUI and more for RLab
Keywords:       kde rlab math plot plotting
author:         David Sweet <dsweet@chaos.umd.edu>
Maintained-by:  David Sweet <dsweet@chaos.umd.edu>
Home-page:      http://www.andamooka.org/~dsweet/KDE/KLab
Primary-site:   ftp://ftp.kde.org/pub/kde/unstable/apps/scientific
Alternate-site: http://www.andamooka.org/~dsweet/KDE/KLab/
Original-site:  ftp://upload.kde.org/pub/kde/Incoming
Platform:       unix
Copying-policy: GPL
End

You can copy and paste this text into a file called "kmyapp.lsm" and make the appropriate changes. Note that the file will automatically be placed in the directory indicated by Primary-site (I think).

PrevHomeNext
Documentation Up  Submitting