![]() | The Makefile.am Howto |
| Prev | Next |
Table of Contents
bin_PROGRAMS = kdialog kdialog_SOURCES = kdialog.cpp widgets.cpp ... kdialog_LDADD = $(LIB_KIO) kdialog_LDFLAGS = $(all_libraties) $(KDE_RPATH) AM_CPPFLAGS = $(all_includes) METASOURCES = AUTO
bin means you want to create something that will install into the bin directory of KDE. *_PROGRAMS means you want to compile a program. Use _SCRIPTS for scripts, etc. Then you can see the name of the program, which is what is used in the lines below to define what has to be done to create that program.
There you define which libraries the program links to. You can only use -lfoo, ../path/to/thelib.la (relative paths only), or the $(LIB_*) macros set by the kde build system. If a lib A depends on a lib B, you don't need to specify B. But if you do (e.g. because A's dependencies might change), make sure you specify A before B. So usually local .la libs are first, then $(LIB_*), then -lfoo if any.
Finally you define the flags to be passed to the linker, in program_LDFLAGS. This can be -L flags (usually set by a configure check into a variable). $(all_libraries) contains all the -L flags necessary to find Qt and KDE, you must have it there. For programs you should use $(KDE_RPATH), it helps getting programs to find their libs without having to set LD_LIBRARY_PATH.
additional compilation flags. This must contain $(all_includes). This is also where other compile-time flags like -DWITHOUTBUGS and -I$(srcdir)/subdir go. IMPORTANT: insert -I directives before $(all_includes). This ensures that your own headers will be used, not some older installed version.
Note that $(srcdir) and . (which is the build directory) are always included automatically. You might find that many Makefile.am files in KDE still use INCLUDES though, that's the old name for it, but AM_CPPFLAGS is the recommended way nowadays.
There's also KDE_CXXFLAGS. Its role is to appended to the other flags, so it can undo one of the flags set by the build framework. This is the case for exceptions, which are disabled by default, so if you want to use exceptions you need to write
KDE_CXXFLAGS = $(USE_EXCEPTIONS)
METASOURCES = AUTOis the magic line that makes the KDE build system take care of the moc files automatically. It is the recommended way if all your .cpp/.cc files include their .moc file (this is the best way since it gives faster compilation), or if you are compiling a single binary/library.
In case you have multiple binaries/libraries in the same directory, you might need to use the longer form of
libsomething_la_METASOURCES = myfile.moc myotherfile.moc mybinary_METASOURCES = someotherfile.moc
| Prev | Home | Next |
| Makefile.am Howto | Up | Makefile.am for shared libraries |