This section describes how the Geant4 GNUMake infrastructure is implemented in Geant4 and provides a quick reference guide for the user about the most important environment variables that can be set to configure its behaviour.
This system is now deprecated, though it is still provided through the SVN repository for developers, and is installed by CMake to provide temporary backward compatibility for user applications.
As described in Section 2.1 of the
Installation Guide, the GNUmake process in Geant4
is mainly controlled by the following GNUmake script files
*.gmk scripts are placed in
architecture.gmk: defining all the architecture
specific settings and paths. System settings are stored in
$G4INSTALL/config/sys in separate files.
common.gmk: defining all general GNUmake rules for
building objects and libraries.
globlib.gmk: defining all general GNUmake rules for
building compound libraries.
binmake.gmk: defining the general GNUmake rules for
GNUmake scripts: placed inside each directory in the
G4 distribution and defining directives specific to build a library
(or a set of sub-libraries) or and executable.
To build a single library (or a set of sub-libraries) or an
executable, you must explicitly change your current directory to
the one you're interested in and invoke the "
command from there ("
make global" for building a
compound library). Here is a list of the basic commands or GNUmake
"targets" one can invoke to build libraries and/or executables:
starts the compilation process for building a kernel library or a
library associated with an example. Kernel libraries are built with
maximum granularity, i.e. if a category is a compound, this command
will build all the related sub-libraries,
not the compound one.
The top level
$G4INSTALL/source will also build in this case a
libname.map of each library to establish
the linking order automatically at the
bin step. The map
will be placed in
starts the compilation process to build a single compound kernel library per category. If issued after "make", both 'granular' and 'compound' libraries will be available (NOTE: this will consistently increase the disk space required. Compound libraries will then be selected by default at link time, unless G4LIB_USE_GRANULAR is specified).
make bin or
make (only for
starts the compilation process to build an executable. This command
will build implicitly the library associated with the example and
link the final application. It assumes all
kernel libraries are already generated and placed in the correct
$G4INSTALL path defined for them.
The linking order is controlled automatically in case libraries have been built with maximum granularity, and the link list is generated on the fly.
On Windows systems this will start the compilation process to build single compound kernel library per category and generate Dynamic Link Libraries (DLLs). Once the libraries are generated, the process will imply also the deletion of all temporary files generated during the compilation.
$G4INSTALL environment variable specifies where
the installation of the Geant4 toolkit should take place, therefore
kernel libraries will be placed in
$G4WORKDIR environment variable is set by the user and
specifies the path to the user working directory; temporary files
(object-files and data products of the installation process of
Geant4) will be placed in
$G4WORKDIR/tmp, according to
the system architecture used. Binaries will be placed in
$G4WORKDIR/bin, according to the system architecture
used. The path to
$G4WORKDIR/bin/$G4SYSTEM should be
$PATH in the user environment.
Here is a list of the most important environment variables defined
within the Geant4
GNUmake infrastructure, with a short
explanation of their use.
We recommend that those environment variables listed here and marked with (*) NOT be overriden or set (explicitly or by accident). They are already set and used internally in the default setup !
Defines the architecture and compiler currently used.
NOTE: This variable is set automatically
Configure script is adopted for the
installation. This will result in the proper settings also for
configuring the environment with the generated shell scripts
$HOME/geant4, assuming the Geant4 distribution is placed in
$LDFLAGSfor -I and -L directives. It has to be set to
$HOME/geant4, assuming the user's working directory for Geant4 is placed in
gmake includes(default is set to
$G4BIN/$G4SYSTEMrespectively. The path to
$G4WORKDIR/bin/$G4SYSTEMshould be added to
$PATHin the user environment.
$G4BINcan be overridden.
$G4TMPcan be overridden.
$G4LIBcan be overridden.
g++compiler, specifies to compile the code (libraries or examples) in optimised mode, but including symbolic information in the object code for debugging.
Linuxsystems with the
g++compiler, it allows to build libraries with profiling setup for monitoring with the
$G4VERBOSEflag set). For better performance, verbosity code can be left out by defining
$G4LIB_BUILD_SHAREDis set as well).
The most relevant flags for User Interface drivers are just listed here. A more detailed description is given also in section 2. of this User's Guide.
$QTHOMEshould specify the path where Qt libraries and headers are installed
The most relevant flags for visualization graphics drivers are just listed here. A description of these variables is given also in section 2. of this User's Guide.
$OGLHOMEset (path to OpenGL installation).
$OGLHOMEset (path to OpenGL installation).
$QTHOMEset to specify the path where Qt libraries and headers are installed.
$OIHOMEset (paths to the
X11installed in the system.
gdmlfor allowing import/export of detector description setups (geometrical volumes, solids, materials, etc.). By default, the flag is not set; if set, the path to the installation of XercesC package must be specified through the variable
gdmlmodule. The flag is automatically set if
$G4LIB_BUILD_GDMLis set in the environment.
USolidsprimitives in place of the original Geant4 solids.
zlibmodule for the compression of output files (mainly in use currently for the HepRep graphics driver). By default, the flag is not set and the built-in system library for compression is adopted instead. Setting this flag will also implicitely set the flag below. On Windows systems, if OpenGL or OpenInventor visualization drivers are built, this module is automatically built.
zlibmodule, either system built-in or Geant4 specific.
g3tog4module for conversions of simple legacy geometries descriptions to Geant4. By default, the flag is not set and the module's library is not built. Setting this flag will also implicitely set the flag below.
g3tog4module, assuming the related library has been already installed.
$G4ANALYSIS_AIDA_CONFIG_LIBS) to define config options for AIDA ("
aida-config --cflags" and "
aida-config --libs"). See installation instructions of the specific analysis tools for details.
The Geant4 GNUmake infrastructure allows to extend the link list of libraries with external (or user defined) packages which may be required for some user's applications to generate the final executable.
GNUmakefile of your application, before including
binmake.gmk, specify the extra library in
EXTRALIBS either using the
syntax or by specifying the full pathname, e.g.:
EXTRALIBS := -L<your-path>/lib -l<myExtraLib>
EXTRALIBS := <your-path>/lib/lib<myExtraLib>.a
You may also specify
EXTRA_LINK_DEPENDENCIES, which is
added to the dependency of the target executable, and you may also
specify a rule for making it, e.g.:
EXTRA_LINK_DEPENDENCIES := <your-path>/lib/lib<myExtraLib>.a <your-path>/lib/lib<myExtraLib>.a: cd <your-path>/lib; $(MAKE)
Note that you almost certainly need to augment
for the header files of the external library, e.g.:
See Example 94.
Example 94. An example of a customised GNUmakefile for an application or example using an external module not bound to Geant4.
# -------------------------------------------------------------------- # GNUmakefile for the application "sim" depending on module "Xplotter" # -------------------------------------------------------------------- name := sim G4TARGET := $(name) G4EXLIB := true CPPFLAGS += -I$(HOME)/Xplotter/include EXTRALIBS += -L$(HOME)/Xplotter/lib -lXplotter EXTRA_LINK_DEPENDENCIES := $(HOME)/Xplotter/lib/libXplotter.a .PHONY: all all: lib bin include $(G4INSTALL)/config/binmake.gmk $(HOME)/Xplotter/lib/libXplotter.a: cd $(HOME)/Xplotter; $(MAKE)
In addition to the above, specify, in
a list of directories containing source files in its
subdirectory. Thus, your
GNUmakefile might contain:
EXTRALIBS += $(G4WORKDIR)/tmp/$(G4SYSTEM)/<myApp>/lib<myApp>.a \ -L<your-path>/lib -l<myExtraLib> EXTRALIBSSOURCEDIRS += <your-path>/<myApp> <your-path>/<MyExtraModule> EXTRA_LINK_DEPENDENCIES := $(G4WORKDIR)/tmp/$(G4SYSTEM)/<myApp>/lib<myApp>.a MYSOURCES := $(wildcard <your-path>/<myApp>/src/*cc) $(G4WORKDIR)/tmp/$(G4SYSTEM)/<myApp>/lib<myApp>.a: $(MYSOURCES) cd <your-path>/<myApp>; $(MAKE)
See Example 95.
Example 95. An example of a customised GNUmakefile for an application or example using external modules bound to Geant4.
# ----------------------------------------------------------------- # GNUmakefile for the application "phys" depending on module "reco" # ----------------------------------------------------------------- name := phys G4TARGET := $(name) G4EXLIB := true EXTRALIBS += $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(name)/libphys.a \ -L$(HOME)/reco/lib -lreco EXTRALIBSSOURCEDIRS += $(HOME)/phys $(HOME)/reco EXTRA_LINK_DEPENDENCIES := $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(name)/libphys.a .PHONY: all all: lib bin include $(G4INSTALL)/config/binmake.gmk MYSOURCES := $(wildcard $(HOME)/phys/src/*cc) $(G4WORKDIR)/tmp/$(G4SYSTEM)/$(name)/libphys.a: $(MYSOURCES) cd $(HOME)/phys; $(MAKE)