[904] | 1 | <!-- ******************************************************** --> |
---|
| 2 | <!-- --> |
---|
| 3 | <!-- [History] --> |
---|
| 4 | <!-- Changed by: Katsuya Amako, 16-Nov-1998 --> |
---|
| 5 | <!-- Changed by: Dennis Wright, 28-Nov-2001 --> |
---|
| 6 | <!-- Proof read by: Joe Chuma, 16-Jun-1999 --> |
---|
| 7 | <!-- Converted to DocBook: Katsuya Amako, Aug-2006 --> |
---|
| 8 | <!-- --> |
---|
| 9 | <!-- ******************************************************** --> |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | <!-- ******************* Section (Level#1) ****************** --> |
---|
| 13 | <sect1 id="sect.HowToMakeExec"> |
---|
| 14 | <title> |
---|
| 15 | How to Make an Executable Program |
---|
| 16 | </title> |
---|
| 17 | |
---|
| 18 | <!-- ******************* Section (Level#2) ****************** --> |
---|
| 19 | <sect2 id="sect.HowToMakeExec.UNIX"> |
---|
| 20 | <title> |
---|
| 21 | Building ExampleN01 in a UNIX Environment |
---|
| 22 | </title> |
---|
| 23 | |
---|
| 24 | <para> |
---|
| 25 | The code for the user examples in Geant4 is placed in the directory |
---|
| 26 | <literal>$G4INSTALL/examples</literal>, where <literal>$G4INSTALL</literal> is the |
---|
| 27 | environment variable set to the place where the Geant4 distribution |
---|
| 28 | is installed (set by default to <literal>$HOME/geant4</literal>). In the |
---|
| 29 | following sections, a quick overview on how the GNUmake mechanism |
---|
| 30 | works in Geant4 will be given, and we will show how to build a |
---|
| 31 | concrete example, "ExampleN01", which is part of the Geant4 |
---|
| 32 | distribution. |
---|
| 33 | </para> |
---|
| 34 | |
---|
| 35 | <!-- ******************* Section (Level#3) ****************** --> |
---|
| 36 | <sect3 id="sect.HowToMakeExec.UNIX.HowGNUmakeWorks"> |
---|
| 37 | <title> |
---|
| 38 | How GNUmake works in Geant4 |
---|
| 39 | </title> |
---|
| 40 | |
---|
| 41 | <para> |
---|
| 42 | The GNUmake process in Geant4 is mainly controlled by the following |
---|
| 43 | GNUmake script files (<literal>*.gmk</literal> scripts are placed in |
---|
| 44 | <literal>$G4INSTALL/config</literal>): |
---|
| 45 | |
---|
| 46 | <variablelist> |
---|
| 47 | <varlistentry> |
---|
| 48 | <term><literal>architecture.gmk</literal></term> |
---|
| 49 | <listitem> |
---|
| 50 | invoking and defining all the architecture specific settings |
---|
| 51 | and paths which are stored in <literal>$G4INSTALL/config/sys</literal>. |
---|
| 52 | </listitem> |
---|
| 53 | </varlistentry> |
---|
| 54 | <varlistentry> |
---|
| 55 | <term><literal>common.gmk</literal></term> |
---|
| 56 | <listitem> |
---|
| 57 | defining all general GNUmake rules for building objects and libraries |
---|
| 58 | </listitem> |
---|
| 59 | </varlistentry> |
---|
| 60 | <varlistentry> |
---|
| 61 | <term><literal>globlib.gmk</literal></term> |
---|
| 62 | <listitem> |
---|
| 63 | defining all general GNUmake rules for building compound libraries |
---|
| 64 | </listitem> |
---|
| 65 | </varlistentry> |
---|
| 66 | <varlistentry> |
---|
| 67 | <term><literal>binmake.gmk</literal></term> |
---|
| 68 | <listitem> |
---|
| 69 | defining the general GNUmake rules for building executables |
---|
| 70 | </listitem> |
---|
| 71 | </varlistentry> |
---|
| 72 | <varlistentry> |
---|
| 73 | <term><literal>GNUmakefile</literal></term> |
---|
| 74 | <listitem> |
---|
| 75 | placed inside each directory in the Geant4 distribution and defining |
---|
| 76 | directives specific to build a library, a set of sub-libraries, or |
---|
| 77 | an executable. |
---|
| 78 | </listitem> |
---|
| 79 | </varlistentry> |
---|
| 80 | </variablelist> |
---|
| 81 | </para> |
---|
| 82 | |
---|
| 83 | <para> |
---|
| 84 | Kernel libraries are placed by default in |
---|
| 85 | <literal>$G4INSTALL/lib/$G4SYSTEM</literal>, where <literal>$G4SYSTEM</literal> |
---|
| 86 | specifies the system architecture and compiler in use. Executable |
---|
| 87 | binaries are placed in <literal>$G4WORKDIR/bin/$G4SYSTEM</literal>, and |
---|
| 88 | temporary files (object-files and data products of the compilation |
---|
| 89 | process) in <literal>$G4WORKDIR/tmp/$G4SYSTEM</literal>. <literal>$G4WORKDIR</literal> |
---|
| 90 | (set by default to <literal>$G4INSTALL</literal>) should be set by the user |
---|
| 91 | to specify the place his/her own workdir for Geant4 in the user |
---|
| 92 | area. |
---|
| 93 | </para> |
---|
| 94 | |
---|
| 95 | <para> |
---|
| 96 | For more information on how to build Geant4 kernel libraries and |
---|
| 97 | set up the correct environment for Geant4, refer to the |
---|
| 98 | "Installation Guide". |
---|
| 99 | </para> |
---|
| 100 | |
---|
| 101 | </sect3> |
---|
| 102 | |
---|
| 103 | <!-- ******************* Section (Level#3) ****************** --> |
---|
| 104 | <sect3 id="sect.HowToMakeExec.UNIX.BuildExec"> |
---|
| 105 | <title> |
---|
| 106 | Building the executable</title> |
---|
| 107 | |
---|
| 108 | <para> |
---|
| 109 | The compilation process to build an executable, such as an example |
---|
| 110 | from <literal>$G4INSTALL/examples</literal>, is started by invoking the |
---|
[1211] | 111 | "make" command from the (sub)directory in which you are |
---|
[904] | 112 | interested. To build, for instance, exampleN01 in your |
---|
| 113 | <literal>$G4WORKDIR</literal> area, you should copy the module |
---|
| 114 | <literal>$G4INSTALL/examples</literal> to your <literal>$G4WORKDIR</literal> |
---|
| 115 | and do the following actions: |
---|
| 116 | |
---|
| 117 | <informalexample> |
---|
| 118 | <programlisting> |
---|
| 119 | > cd $G4WORKDIR/examples/novice/N01 |
---|
| 120 | > gmake |
---|
| 121 | </programlisting> |
---|
| 122 | </informalexample> |
---|
| 123 | </para> |
---|
| 124 | |
---|
| 125 | <para> |
---|
| 126 | This will create, in <literal>$G4WORKDIR/bin/$G4SYSTEM</literal>, the |
---|
| 127 | "exampleN01" executable, which you can invoke and run. You should |
---|
| 128 | actually add <literal>$G4WORKDIR/bin/$G4SYSTEM</literal> to |
---|
| 129 | <literal>$PATH</literal> in your environment. |
---|
| 130 | </para> |
---|
| 131 | |
---|
| 132 | </sect3> |
---|
| 133 | </sect2> |
---|
| 134 | |
---|
| 135 | |
---|
| 136 | <!-- ******************* Section (Level#2) ****************** --> |
---|
| 137 | <sect2 id="sect.HowToMakeExec.Windows"> |
---|
| 138 | <title> |
---|
| 139 | Building ExampleN01 in a Windows Environment |
---|
| 140 | </title> |
---|
| 141 | |
---|
| 142 | <para> |
---|
| 143 | The procedure to build a Geant4 executable on a system based on a |
---|
| 144 | Windows system is similar to what should be done on a UNIX based |
---|
| 145 | system, assuming that your system is equipped with GNUmake, |
---|
| 146 | MS-Visual C++ compiler and the required software to run Geant4 (see |
---|
| 147 | "Installation Guide"). |
---|
| 148 | </para> |
---|
| 149 | |
---|
| 150 | |
---|
| 151 | <!-- ******************* Section (Level#3) ****************** --> |
---|
| 152 | <sect3 id="sect.HowToMakeExec.Windows.BuildExec"> |
---|
| 153 | <title> |
---|
| 154 | Building the executable |
---|
| 155 | </title> |
---|
| 156 | |
---|
| 157 | <para> |
---|
| 158 | See paragraph <xref linkend="sect.HowToMakeExec.UNIX" />. |
---|
| 159 | </para> |
---|
| 160 | |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | </sect3> |
---|
| 164 | </sect2> |
---|
[1211] | 165 | </sect1> |
---|