85ea790079004d00a24c590194e155b8cbe6d2c8
[senf.git] / senfscons / Mainpage.dox
1 // $Id$
2 //
3 // Copyright (C) 2007
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 namespace senfscons {
24
25 /** \mainpage The Senf Build Environment
26
27     The Senf Build Environment is based on the <a href="http://www.scons.org">SCons</a> software
28     construction tool. SCons is a <a href="http://www.python.org">python</a> based replacement for
29     \c make. SENFScons consists of several SCons builders as well as some global configuration and
30     build utilities. SENFScons tightly integrates the <a
31     href="http://www.boost.org/libs/test/doc/index.html">Boost.Test</a> unit testing framework. It
32     also incorporates a very flexible infrastructure to build software documentation using <a
33     href="http://www.stack.nl/~dimitri/doxygen/">Doxygen</a>. This infrastructure uses quite a bit
34     of pre- and postprocessing (which is integrated with the provided Doxygen builder) to fix some
35     doxygen problems and generate a (IMHO) more readable layout.
36     
37     \autotoc
38
39     \section senfutil_overview Building Projects using SENF
40
41     When building projects using senf, SENFSCons has a very simple helper module \ref senfutil to
42     make the building of libraries utilizing senf simpler:
43     \code
44     import sys
45     sys.path.extend(('senf/senfscons','/usr/lib/senf/senfscons'))
46     import os.path, glob, senfutil
47
48     env = Environment()
49
50     senfutil.SetupForSENF( env )
51
52     env.Append(
53
54         LIBS            = [ ],
55         CXXFLAGS        = [ '-Wall', '-Woverloaded-virtual' ],
56         LINKFLAGS       = [ ],
57
58         CXXFLAGS_debug  = [ ],
59         LINKFLAGS_debug = [ ],
60         LOGLEVELS_debug = [ 'senf::log::Debug||VERBOSE' ],
61
62         CXXFLAGS_final  = [ '-O3' ],
63         LINKFLAGS_final = [ ],
64         LOGLEVELS_final = [ ],
65
66         SENF_BUILDOPTS  = [ ],
67
68     )
69
70     env.Default(
71         env.Program( target = 'udpforward',
72                      source = glob.glob('*.cc') )
73     )
74
75     env.Clean(DEFAULT_TARGETS, [ 'udpforward.log', 'udpforward.pid' ])
76     \endcode
77
78     This example builds a simple binary from a number of source files (all '.cc' files). It links
79     against the SENF library and automatically sets all the correct compiler options using
80     <tt>senfutil.SetupForSENF( env )</tt>.
81
82     This script automatically uses a SENF installation either symlinked or imported into the current
83     project in directory 'senf' or, if this directory does not exist, a globaly installed SENF. A
84     locally installed SENF is automatically recompiled if needed. Parallel building is also
85     supported.
86
87     This script automatically supports the \c final and \c LOGLEVELS command line parameters. The
88     LOGLEVELS parameter uses a much more readable syntax than SENF_LOG_CONF:
89     <pre>
90     $ scons -j2 final=1 \
91           LOGLEVELS='senf::log::Debug||IMPORTANT myapp::Transactions|mytrans::Area|VERBOSE'
92     </pre>
93
94     \section senfscons_intro Introduction to the SENFSCons build system
95
96     Here we give an overview on how SENF itself is built. The SENFSCons system aims to be quite
97     flexible at separates SENF specific tasks from generic tasks to facilitate reuse.
98
99     \subsection senfscons_layout The Project Layout
100
101     The SENFSCons infrastructure will always use a consistent directory layout. The top-level
102     directory will contain one subdirectory for every module. The main target will often be
103     considered to be just another module using the facilities provided by library modules.
104
105     The top-level project directory must contain the SENFSCons module in 'senfscons'.
106
107     The top-level \c SConstruct file will set up the global project configuration (which libraries
108     are used etc) and will then automatically load all module \c SConscript files.
109
110     Documentation is generated per module. This simplifies reusing modules in other projects. The
111     framework however semi-automatically creates the necessary cross-reference information to
112     cross-link the different module documentations. The unit-tests as well are run on a per-module
113     basis.
114
115     \subsection senfscons_buildconf Standard Build Configuration
116
117     When the \c SConsctruct and \c SConscript files are build using the default SENFSCons helpers,
118     by default all libraries and binaries are built. Some additional targets are
119
120     <dl><dt><tt>scons all_tests</tt></dt><dd>Build all unit tests</dd>
121
122     <dt><tt>scons all_docs</tt></dt><dd>Build documentation of all modules</dd>
123
124     <dt><tt>scons all</tt></dt><dd>Build all targets including binaries, libraries, documentation,
125     tests and possible further targets </dd>
126
127     <dt><tt>scons -u doc</tt></dt><dd>Run from within a module directory will build the
128     documentation of that module</dd>
129
130     <dt><tt>scons -u test</tt></dt><dd>Run from within a module directory will build and run the
131     unit test of that module</dd></dl>
132
133     To clean any of the targets use the SCons \c -c parameter.
134
135     The build environment can be configured \e locally using \ref sconfig in the project root
136     directory.
137
138     \see
139         \ref sconstruct \n
140         \ref sconscript \n
141         \ref sconfig  \n
142         \ref builder
143  */
144
145 /** \page sconstruct The Top-Level 'SConstruct' File
146
147     The top-level \c SConstruct file sets up the build, configures used libraries and parameters and
148     invokes the module \c SConscript files. To simplify the configuration, the SENFScons python
149     package is provided. This package has helper utilities to simplify standard tasks.
150
151     In \c senfscons/SConstruct.template you may find an example SConstruct file. Copy this to the
152     project root (under the name \c SConstruct) to start a new project. You can then modify and
153     configure it to your wishes.
154
155     The general structure of the \c SConstruct file is
156     \li make the \c senfscons directory accessible
157     \li tell the SENFScons infrastructure, which frameworks you intend to use and let SENFScons
158         built a construction environment for you
159     \li configure the construction environment
160     \li load module sconscript file
161     \li specify global build targets
162
163     The first part, <i>making the \c senfscons directory accessible</i> will always stay the
164     same. See the template file for how this is done.
165
166     <i>Simplifying the use of more complex frameworks</i> is one of the most important things why
167     SENFScons exists. If you only use very simple libraries, the configuration is quite
168     simple. However for more complex frameworks the configuration can get quite complicated. This is
169     simplified using the SENFScons framework statements. They all reside in the \c SENFSCons package
170     and have a prefix of \c Use. See \ref use.
171
172     After all frameworks are configured, you can use SEFNScons.MakeEnvironment() to create a
173     correctly configured construction environment.
174
175     To <i>configure the construction environment</i> you can set Variables in the construction
176     environment. See the SCons manpage for a list of supported variables. Some additional variables
177     are available with the new builders introduced with SENFSCons. Those are documented with the
178     builder module documentation.
179
180     <i>Loading the module \c SConscript files</i> will normally always be performed the same way
181     using \c glob.glob() to automatically include any subdirectory module.
182
183     You may then <i>specify global build targets</i>. You can use standard SCons targets or use all
184     the target helpers provided with SENFSCons. Two standard helpers should always be included:
185     SENFSCons.StandardTargets() and SENFSCons.GlobalTargets(). You can find more target helpers at
186     \ref target
187
188     The SConstruct file is an ordinary python file. It is loaded by SCons prior to building the
189     software. Just remember, you can use all of python and all of SCons here. SENFScons just
190     provides some additional helpers to make things simpler and more concise.
191
192     \see
193         \ref use \n
194         \ref target
195  */
196
197 /** \page sconscript The Module 'SConscript' Files
198
199     Every module (that is subdirectory) is built by that modules \c SConscript file. In \c
200     SConscript.template you can find a template of such a file.
201
202     Every \c SConscript file starts by importing the construction environment. The \c SConscript
203     file is an ordinary \c SConscript file as used by SCons. You may use any of the SCons facilities
204     to define targets. However, you will mostly use the \ref target.
205
206     Every \c SConscript file should call \c SENFSCons.StandardTargets() to initialize the standard
207     targets of every module.
208
209     \see
210         \ref target
211  */
212
213 /** \page sconfig The 'SConfig' File
214
215     To configure the build environment to the local environment, a \c SConfig file may be created in
216     the projects root directory. The supported parameters are
217
218     <dl>
219         <dt>\c CXX</dt>
220             <dd>C++ compiler to use</dd>
221         <dt>\c EXTRA_DEFINES</dt>
222             <dd>preprocessor symbols to be defined locally</dd>
223         <dt>\c EXTRA_LIBS</dt>
224             <dd>additional libraries needed for a local build</dd>
225     </dl>
226
227     Additionally, the \ref use define additional configuration variables which may be set here.
228  */
229
230 }
231
232 \f
233 // Local Variables:
234 // mode: c++
235 // fill-column: 100
236 // c-file-style: "senf"
237 // indent-tabs-mode: nil
238 // ispell-local-dictionary: "american"
239 // mode: flyspell
240 // mode: auto-fill
241 // End: