Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.sao.ru/cats/~satr/GGAD/z70.html
Дата изменения: Wed Jul 12 23:54:36 2000
Дата индексирования: Mon Oct 1 23:59:20 2012
Кодировка:

Поисковые слова: molecular cloud
Makefile.am

Makefile.am

automake processes Makefile.am to produce a standards-compliant Makefile.in. automake does a lot of work for you: it keeps up with dependencies between source files, for example. It creates all the standard targets, such as install and clean. It also creates more complex targets: simply typing make dist creates a standard .tar.gz file if your Makefile.am is correct.

The Makefile.am in the top source directory is generally very simple; here is an example:


SUBDIRS = macros po intl src pixmaps doc

## We dist autogen.sh since this is an example program
## Real-world programs do not need to distribute autogen.sh
EXTRA_DIST = \
        gnome-hello.desktop \
    autogen.sh

Applicationsdir = $(datadir)/gnome/apps/Applications
Applications_DATA = gnome-hello.desktop


The SUBDIRS line instructs automake to recursively look for Makefile.am files in the given subdirectories. (the section called .desktop Entries describes the remainder of the file, ignore it for now.) The Makefile.am in the src directory is a little more interesting:


INCLUDES = -I$(top_srcdir) -I$(includedir) $(GNOME_INCLUDEDIR) \
         -DG_LOG_DOMAIN=\"GnomeHello\" -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \
    -I../intl -I$(top_srcdir)/intl

bin_PROGRAMS = gnome-hello

gnome_hello_SOURCES =         \
        app.c           \
        hello.c         \
        menus.c     \
    app.h       \
    hello.h     \
    menus.h

gnome_hello_LDADD = $(GNOMEUI_LIBS) $(GNOME_LIBDIR) $(INTLLIBS)


automake understands a number of "magic variables" and can use them to create Makefile.in. In the small example above, the following variables are used:

Several elements of the INCLUDES line should be used in all Gnome programs. G_LOG_DOMAIN should always be defined; error messages from checks and assertions will report this value, so you can determine where the error occurred (in your code, or in a library). GNOMELOCALEDIR is used to locate translation files. The intl directory is added to the header search path so the application can find the intl headers.

There are many more complex things one can do in Makefile.am; in particular, you can add @-bounded variables to be substituted by configure, you can conditionally include portions of the Makefile based on configure checks, and you can build libraries. The automake manual gives more details.

Table 1 summarizes the most interesting targets generated by automake. Of course the default target is all, which compiles the program. The GNU Coding Standards (http://www.gnu.org/prep/standards_toc.html) have more information about these targets and GNU makefiles in general.

Table 1. Standard make targets

Target Description
dist Builds a tarball (.tar.gz) for distribution
distcheck Builds a tarball, then tries to compile it
clean Deletes the results of compilation (object files and executables), but may not delete some generated files that come with the distribution.
install Creates installation directories if needed, and copies the software into them.
uninstall Reverses the install (deletes installed files).
distclean Reverse the effects of the configure script and the all target; that is, revert a tarball to its pristine state.
mostlyclean Nearly the same as clean, but leaves some object files that most likely don't need to be rebuilt.
maintainer-clean More thorough than clean; may delete some files that require special tools to rebuild, such as machine-generated source code.
TAGS Creates a tag table, for use with Emacs.
check Runs a test suite if you have one