Packaging and Submitting Code to KDE | ||
| Prev | Next | |
'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.
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 = kexampleto
SUBDIRS = kmyapp
kmyapp here refers to the subdirectory of the same name.
SUBDIRS = kmyapp kmysupportclassAlso 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
./configureThis should create:
Makefile
kmyapp/Makfile
config.h
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.
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.1or 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 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
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