Provided by: zmk-doc_0.5.1-2_all bug

NAME

     Program — template for compiling C/C++/ObjC programs

SYNOPSIS

     include z.mk
     # programName is any valid identifier.
     programName.Sources = hello.c
     $(eval $(call ZMK.Expand,Program,programName))

DESCRIPTION

     The template Program once expanded with a program name to creates rules for compiling,
     cleaning, installing and removing a single program written in C, C++ or Objective C.

     Source files are compiled to object files prefixed with $(programName)-, so that a single
     source file can be compiled separately with distinct preprocessor, compiler and linker
     options.

     When cross-compiling for Windows or DOS, the $(exe) variable expands to .exe

TARGETS

     This module provides the following targets.

   $(programName)$(exe)
     This target represents the program executable.

   all
     This phony target depends on $(programName)$(exe)

   clean
     This phony target removes $(programName)$(exe) as well as constituent object files and
     dependency files.

   install
     This phony target copies $(programName) to $(programName.InstallDir), with the name
     $(programName.InstallName) and mode $(programName.InstallMode).  The target directory is
     automatically created if required.

     The variables Configure.ProgramPrefix, Configure.ProgramSuffix and
     Configure.ProgramTransformName automatically impact the installed names of all the programs.

   uninstall
     This phony target removes $(programName)$(exe) as installed by the install target.

VARIABLES

     This module provides the following variables.

   $(programName).Sources
     List of source files to compile.

     There is no default value. This variable must be set before expanding the template.

   $(programName).Objects
     List of object files to link.

     The default value is all the elements of $(programName).Sources with the added prefix
     $(programName)- and with the extension replaced by .o.

   $(programName).Linker
     Linker required to link object files together.

     The default value depends on the type of source files used, ensuring that C++ sources are
     linked with the C++ linker.

   $(programName).InstallDir
     The directory $(programName)$(exe) is installed to.

     The default value is $(bindir) but $(sbindir) or $(libexecdir) are commonly used as well.
     The special value noinst disables the rules related to installation and uninstallation.

   $(programName).InstallName
     The name of the program after installation.

     The default value is $(programName)

   $(programName).InstallMode
     The UNIX mode $(programName)$(exe) is installed with.

     The default value is 0755.

   DESTDIR
     Path added to all installation targets.

     This variable is normally set externally, to install a compiled program into a staging area
     during construction of a compiled binary package.

   CFLAGS, CXXFLAGS, OBJCFLAGS
     Options for the C, C++ and the Objective C compiler, respectively.

   CPPFLAGS
     Options for the preprocessor.

IMPLEMENTATION NOTES

     Program uses InstallUninstall to handle installation and removal.  The exe variable is
     automatically set to .exe where appropriate.

EXAMPLES

     With the following true_false.c file:

                 #include <stdlib.h>

                 int main(void) {
                         return EXIT_CODE;
                 }

     The following Makefile builds the classic programs true and false.

                 include z.mk

                 true.Sources = true_false.c
                 $(eval $(call ZMK.Expand,Program,true))
                 true$(exe): CPPFLAGS += -DEXIT_CODE=EXIT_SUCCESS

                 false.Sources = true_false.c
                 $(eval $(call ZMK.Expand,Program,false))
                 false$(exe): CPPFLAGS += -DEXIT_CODE=EXIT_FAILURE

HISTORY

     The Program template first appeared in zmk 0.1

AUTHORS

     Zygmunt Krynicki <me@zygoon.pl>