BUILD
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Fri, 04 May 2007 15:04:07 +0200
changeset 524 082ffdd8fbd7
parent 179 0519ba9a919f
child 634 7dbf8f0dc819
permissions -rw-r--r--
move code around
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     1
If you want to build ns3, you need to install scons (see
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     2
http://www.scons.org). scons takes care of building
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     3
the whole source tree using your system compiler. scons
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     4
0.91.1 and 0.91.96 have been tested and are known to 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     5
work on linux FC5, Mac os X and MinGW.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     6
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     7
To start a build, you can just type 'scons' which
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     8
will generate a debug shared build by default, located
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
     9
in the directory 'build-dir/dbg-shared/bin' and
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    10
'build-dir/dbg-shared/lib'.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    11
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    12
All builds are built with debugging symbols. Debugging
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    13
builds enable asserts while optimized builds disable them.
88
619ef053b9f1 add comment on rpath
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 87
diff changeset
    14
On platforms which support it, rpath is used which means that
619ef053b9f1 add comment on rpath
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 87
diff changeset
    15
the executable binaries generated link explicitely against
619ef053b9f1 add comment on rpath
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 87
diff changeset
    16
the right libraries. This saves you the pain of having to
619ef053b9f1 add comment on rpath
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 87
diff changeset
    17
setup environment variables to point to the right libraries.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    18
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    19
1) Options
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    20
----------
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    21
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    22
- verbose: if you have installed scons 0.91.96 or higher, 
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    23
  the default build output is terse. To get a more verbose 
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    24
  output, you need to set the 'verbose' variable to 'y'.
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    25
Example: scons verbose=y
115
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    26
- cflags: flags for the C compiler.
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    27
Example: scons cflags="-O3 -ffast-math"
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    28
- cxxflags: flags for the C++ compiler.
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    29
Example: scons cxxflags="-O3 -ffast-math"
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    30
- ldflags: flags for the linker:
5435512761ef allow the user to provide project-wide compilation and link flags
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 101
diff changeset
    31
Example: scons ldflags="-L/foo -L/bar"
168
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    32
- high-precision-as-double: set to 'y' to make sure that the
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    33
  high-precision arithmetics performed by the Time class on
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    34
  behalf of the user will use doubles. By default, the code
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    35
  uses 128 integers.
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    36
Example: scons high-precision-as-double=y
140
7ad2664c9515 add documentation for the inheritenv option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    37
- inheritenv: set to 'y' if you want to make your compiler
7ad2664c9515 add documentation for the inheritenv option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    38
  execute within the same environment (env vars) as your own
7ad2664c9515 add documentation for the inheritenv option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    39
  shell. This is typically used to make colorgcc work.
7ad2664c9515 add documentation for the inheritenv option
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    40
Example: scons inheritenv=y
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    41
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    42
2) Targets
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
----------
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    44
57
9385fba1589e add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 17
diff changeset
    45
- doc: build the doxygen documentation.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    46
Example: scons doc
57
9385fba1589e add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 17
diff changeset
    47
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
- dbg-shared: a debug build using shared libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    49
  The files are built in 'build-dir/dbg-shared/'.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    50
Example: scons dbg-shared
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
- dbg-static: a debug build using static libraries
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
  The files are built in 'build-dir/dbg-static/'.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    54
Example: scons dbg-static
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    55
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
- opt-shared: an optimized build using shared libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
  The files are built in 'build-dir/opt-shared/'.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    58
Example: scons opt-shared
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    60
- opt-static: an optimized build using static libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
  The files are built in 'build-dir/opt-static/'.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    62
Example: scons opt-static
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    63
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
- dbg: an alias for dbg-shared
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    65
Example: scons dbg
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
- opt: an alias for opt-shared
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    68
Example: scons opt
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
- all: alias for dbg-shared, dbg-static, opt-shared 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
  and opt-static
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    72
Example: scons all
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
116
d4ee28e845f3 add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 115
diff changeset
    74
- gcov: code coverage analysis. Build a debugging version of
118
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    75
  the code for code coverage analysis in 'build-dir/gcov'. Once
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    76
  the code has been built, you can run various applications to
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    77
  exercise the code paths. To generate an html report from
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    78
  the gcov data, use the lcov-report target
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    79
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    80
- lcov-report: generate html report of gcov data. The output
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    81
  is stored in 'build-dir/lcov-report/'.
116
d4ee28e845f3 add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 115
diff changeset
    82
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    83
- dist: generate a release tarball and zipfile from the 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    84
  source tree. The tarball and zipfile name are generated
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    85
  according to the version number stored in the SConstruct
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    86
  file.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
Example in SConstruct:
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
ns3 = Ns3 ()
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
ns3.name = 'foo'
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
ns3.version = '0.0.10'
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    91
Example command: scons dist
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    92
Example output files:
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
foo-0.0.10.tar.gz
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
foo-0.0.10.zip
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    95
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    96
- distcheck: generate a release tarball and zipfile and 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
  attempt to run the 'all' target for the release tarball.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    98
Example: scons distcheck
101
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
    99
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   100
3) How the build system works
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   101
-----------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   102
125
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   103
The current build system defines what are called "ns3 modules": each module
101
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   104
is a set of source files, normal header files and installable header
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   105
files. Each module also depends on a set of other modules. We build
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   106
modules automatically in the correct order. That is, we always start
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   107
from the module which does not depend on any other module (core) and
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   108
proceed with the other modules and make sure that when a module is
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   109
built, all the modules it depends upon have already been built.
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   110
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   111
To build a module, we:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   112
1) generate the .o files
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   113
2) link the .o files together 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   114
3) install the installable headers in the common directory
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   115
top_build_dir/include/ns3.
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   116
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   117
This means that if you want to use a header from your own module, you
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   118
should just include it: #include "foo.h" but if you want to include a
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   119
header from another module, you need to include it with #include
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   120
"ns3/bar.h". This allows you to make sure that our "public" ns3 headers
125
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   121
do not conflict with existing system-level headers.   For instance,
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   122
if you were to define a header called queue.h, you would include
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   123
ns3/queue.h rather than queue.h, when including from a separate module,
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   124
since many systems provide a queue.h system include file.  
101
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   125
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   126
4) How to add files to a module ?
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   127
---------------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   128
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   129
In the main SConstruct file, you can add source code
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   130
to the add_sources method. For example, to add a foo.cc
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   131
file to the core module, we coud do this:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   132
core.add_sources ('foo.cc')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   133
Of course, if this file implements public API, its 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   134
header should be installable:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   135
core.add_inst_headers ('foo.h')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   136
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   137
5) How to create a new module ?
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   138
-------------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   139
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   140
# create a new module. First arg is the name of
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   141
# the new module. Second arg is the directory in
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   142
# which all source files for this module reside.
141
5f92897efe08 patch to build documentation from paul@cravenfamily.com
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 140
diff changeset
   143
my_module = build.Ns3Module ('my', 'src/my_dir')
101
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   144
# add it to build system
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   145
ns3.add (my_module)
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   146
# specify module dependencies. Here, depends
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   147
# on the 'ipv4' and 'core' modules
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   148
my_module.add_deps (['core', 'ipv4']) 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   149
# add source code to build located in 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   150
# src/my_dir
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   151
my_module.add_sources ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   152
	'my_a.cc',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   153
	'my_b.cc',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   154
	'my_c.cc'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   155
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   156
my_module.add_sources ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   157
	'my_d.cc'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   158
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   159
# add headers which are not public
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   160
my_module.add_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   161
	'my_a.h',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   162
	'my_c.h'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   163
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   164
# add headers which are public
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   165
my_module.add_inst_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   166
	'my_b.h'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   167
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   168
my_module.add_inst_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   169
	'my_d.h'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   170
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   171
# if you need to link against an external library,
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   172
# you must add 'external' dependencies. Here, the 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   173
# pthread library
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   174
my_module.add_external_dep ('pthread')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   175
# by default, a module is conceptually a library. If you
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   176
# want to generate an executable from a module you need to:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   177
my_module.set_executable ()
168
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
   178