zmk.Program(5) | File Formats Manual (prm) | zmk.Program(5) |
Program
— template
for compiling C/C++/ObjC programs
include z.mk # programName is any valid identifier. programName.Sources = hello.c $(eval $(call ZMK.Expand,Program,programName))
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
This module provides the following targets.
This target represents the program executable.
This phony target depends on $(programName)$(exe)
This phony target removes $(programName)$(exe) as well as constituent object files and dependency files.
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.
This phony target removes $(programName)$(exe) as installed by the install target.
This module provides the following variables.
List of source files to compile.
There is no default value. This variable must be set before expanding the template.
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.
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.
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.
The name of the program after installation.
The default value is $(programName)
The UNIX mode $(programName)$(exe) is installed with.
The default value is 0755.
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.
Options for the C, C++ and the Objective C compiler, respectively.
Options for the preprocessor.
Program
uses
InstallUninstall
to handle installation and removal.
The exe
variable is automatically set to
.exe where appropriate.
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
The Program
template first appeared in zmk
0.1
Zygmunt Krynicki <me@zygoon.pl>
May 3, 2020 | zmk 0.5.1 |