In order to build a client program, you need to specify pretty many compiler
options. Usually, such lengthy commands are stored in a special file Makefile. Then the
compiler can be invoked via short calls of the make utility, which greatly saves your keyboard
and fingers. Moreover, make examines the time stamps of the source code and included header files,
so it rebuilds automatically your clients as soon as it sees something got changed.
Unfortunately, the syntax of the Makefile itself is not for the fearful beginners. Therefore, we offer rather elaborated Makefile building blocks, which enable the most common client building schemes. We start the explanation with a simplest case, requiring only a single-line Makefile:
.cc
or .C suffix. The executable files are kept in the same directory as the sources. Then the following
ultra-short Makefile will suffice:
include Polymake_Installation_Top_Directory/Makefile
include statement, depending on the type of computer you are working with.
Or, provided a regular naming scheme for the platform-specific directories, you can ask make to choose
it automatically, e.g. this way:
Arch := $(shell uname -m) include Polymake_Installation_Top_Directory/$(Arch)/Makefile
SourceDir = Relative_or_Absolute_Path include ...
src, .., and ../src are checked automatically, so if
you choose one of these names, you don't need the SourceDir assignment.
Makefile.inc, but
this time in the source directory. It should contain following lines:
client_name$(suffix) : additional_module_name$O ... ExtraModules := additional_module_name ...
.cc, .o, or other suffixes.
$(suffix) and $O must be appended verbatim to each client (module) name.
These variables contain an extra suffix if any debugging compile mode is chosen; see various Debug=...
settings below.
Makefile.inc:
NoPrimaryModule := client_name ...
Makefile.inc:
LibModules := module_name ...
ExtraModules.
Makefile.inc:
CXXFLAGS := compiler options LDFLAGS := linker options except -l LIBS := linker options specifying libraries: -L and -l
LibModules is treated automatically, you don't need to add any options for this.
make feature of pattern-specific variables, in
Makefile.inc:
client_name module_name$O ... : ExtraCXXFLAGS = compiler options client_name module_name$O ... : ExtraLDFLAGS = linker options except -l client_name module_name$O ... : ExtraLIBS = linker options specifying libraries: -L and -l
Having prepared the Makefile this way, you can ask make to carry out
various tasks:
-d.
-p. Profile=detailed disables
function inlining, which makes the profile much more fine-granulated, but the total performance worse;
however, the rest compiler optimization is still on.
POLY_TIMING.
The client may include code fragments protected by this symbol, creating a stopwatch object
at the beginning of the computation and printing the elapsed time at the end. The binary files will have
a suffix -T.
-dO.
stl_alloc.h for the effect of defining
of __USE_MALLOC.)
You should use this option if the client program seems to have memory leaks or other memory-related
misbehavior. This increase the probability of finding the problem source when using such well-known tools
as purify (whoever can afford it) or valgrind.
The binary files will have a suffix -dP.
CXXFLAGS and LDFLAGS can contain additional
compiler and linker options, as explained above.
CXXDEBUG controls the generation of symbolic information for the debugger;
the default setting is -g, which is OK for gdb.
CXXOPT specifies the optimization level; the default setting is -O3, unless it was
changed during the polymake installation.