Chapter 16. Packaging and Distributing Code

by David Sweet

In This Chapter

By now you have probably become familiar with the standard form in which KDE applications and libraries are distributed. The source code is bound in a single directory in a gzipped tar file, and the program is made and installed with the commands ./configure; make; make install. In this chapter, you learn how to create packages like this for your own applications.

The advantages to using this standard packaging method include

Note

You can find out about Autoconf, Automake and Perl at the following URLs:


   1 
   2 http://sourceware.cygnus.com/autoconf/
   3 http://sourceware.cygnus.com/automake/
   4 http://www.perl.org
   5 

After you've created a working package for your application, you'll want to distribute it and get the word out to potential users. This chapter will show you how.

16.1. The Structure of a Package

A package contains several files in addition to your source code, such as makefiles, scripts, and sources for the makefiles and scripts. A typical layout is shown in Figure 16.1.

This layout is taken from the package kexample.tar.gz. In this chapter, you will examine it and develop it into a package for KSimpleApp, the application written in Chapter 2, "A Simple KDE Application."

The top-level directory of a package contains some administrative scripts, including the script configure, and a makefile. The script configure runs several tests to learn about the system before the software is compiled. These tests include checking for the appropriate versions of KDE and Qt; checking for the locations of KDE, Qt, and X; checking for the presence of various utility programs; and checking for various system-dependent behaviors of programs and library functions. The file Makefile is used by the make utility to build and install the software, to remove files not needed for distribution, and to regenerate automatically generated files when they are needed. The script configure is generated automatically by the Autoconf from a file called configure.in and Makefile is generated by configure from the file Makefile.in. You will see how to create these files later in the section "Configuring the Top-Level Directory."


Figure 16.1. The layout of a typical KDE source code package.


There are two important subdirectories. One is given the name of your application in all lowercase letters (the subdirectory for KSimpleApp, for example, is ksimpleapp), and the other is called po. The first subdirectory contains all the application's source code, and po holds translations of the string literals that are passed to the i18n() function.