Next: , Up: Programs   [Contents][Index]

7.1.1 Defining program sources

In a directory containing source that gets built into a program (as opposed to a library or a script), the PROGRAMS primary is used. Programs can be installed in bindir, sbindir, libexecdir, pkglibexecdir, or not at all (noinst_). They can also be built only for ‘make check’, in which case the prefix is ‘check_’.

For instance:

bin_PROGRAMS = hello

In this simple case, the resulting Makefile.in will contain code to generate a program named hello.

Several assisting variables are associated with each program.

The variable hello_SOURCES is used to specify which source files get built into the ‘hello’ executable:

hello_SOURCES = hello.c version.c getopt.c getopt1.c getopt.h system.h

This causes each mentioned .c file to be compiled into the corresponding .o. Then all are linked to produce hello.

If hello_SOURCES is not specified, then it defaults to the single file hello.c (see Default sources).

If multiple programs in the same directory share a source file, it must be listed in the _SOURCES definition for each program.

Header files listed in a _SOURCES definition will be included in the distribution, but otherwise ignored. In case it isn’t obvious, you should not include the header file generated by configure in a _SOURCES variable; this file should not be distributed. Lex (.l) and Yacc (.y) files can also be listed; see Yacc and Lex.

Next: , Up: Programs   [Contents][Index]