doc/build.txt
author Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
Thu, 17 May 2007 11:32:22 +0200
changeset 635 71b92dfe5f55
parent 634 BUILD@7dbf8f0dc819
child 657 be551a3b07c6
permissions -rw-r--r--
write README, contributing.txt, reorganize the other documentation files
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"
634
7dbf8f0dc819 fix scons dist and scons all for gcc 4.1
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 179
diff changeset
    32
- cc: the C compiler to use:
7dbf8f0dc819 fix scons dist and scons all for gcc 4.1
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 179
diff changeset
    33
Example: scons cc=gcc-4.0
7dbf8f0dc819 fix scons dist and scons all for gcc 4.1
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 179
diff changeset
    34
- cxx: the C++ compiler to use:
7dbf8f0dc819 fix scons dist and scons all for gcc 4.1
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 179
diff changeset
    35
Example: scons cxx=g++-4.0
168
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    36
- 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
    37
  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
    38
  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
    39
  uses 128 integers.
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
    40
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
    41
- 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
    42
  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
    43
  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
    44
Example: scons inheritenv=y
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    46
2) Targets
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    47
----------
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
57
9385fba1589e add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 17
diff changeset
    49
- doc: build the doxygen documentation.
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    50
Example: scons doc
57
9385fba1589e add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 17
diff changeset
    51
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
- dbg-shared: a debug build using shared libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    53
  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
    54
Example: scons dbg-shared
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
- dbg-static: a debug build using static libraries
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    57
  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
    58
Example: scons dbg-static
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-shared: an optimized build using shared libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
  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
    62
Example: scons opt-shared
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
- opt-static: an optimized build using static libraries.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  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
    66
Example: scons opt-static
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    67
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
- dbg: an alias for dbg-shared
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    69
Example: scons dbg
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    71
- opt: an alias for opt-shared
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    72
Example: scons opt
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    73
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
- all: alias for dbg-shared, dbg-static, opt-shared 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    75
  and opt-static
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    76
Example: scons all
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    77
116
d4ee28e845f3 add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 115
diff changeset
    78
- 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
    79
  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
    80
  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
    81
  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
    82
  the gcov data, use the lcov-report target
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    83
472ff5fe2eef document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 116
diff changeset
    84
- 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
    85
  is stored in 'build-dir/lcov-report/'.
116
d4ee28e845f3 add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 115
diff changeset
    86
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    87
- dist: generate a release tarball and zipfile from the 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    88
  source tree. The tarball and zipfile name are generated
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    89
  according to the version number stored in the SConstruct
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    90
  file.
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    91
Example in SConstruct:
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    92
ns3 = Ns3 ()
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    93
ns3.name = 'foo'
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    94
ns3.version = '0.0.10'
87
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    95
Example command: scons dist
a1b7dc32df30 beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 57
diff changeset
    96
Example output files:
17
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    97
foo-0.0.10.tar.gz
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    98
foo-0.0.10.zip
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    99
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   100
- distcheck: generate a release tarball and zipfile and 
b959311b6aa1 build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   101
  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
   102
Example: scons distcheck
101
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   103
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   104
3) How the build system works
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   105
-----------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   106
125
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   107
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
   108
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
   109
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
   110
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
   111
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
   112
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
   113
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
   114
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   115
To build a module, we:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   116
1) generate the .o files
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   117
2) link the .o files together 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   118
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
   119
top_build_dir/include/ns3.
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   120
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   121
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
   122
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
   123
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
   124
"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
   125
do not conflict with existing system-level headers.   For instance,
a0cda913dee5 a few wordsmithing changes
Tom Henderson <tomh@tomh.org>
parents: 118
diff changeset
   126
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
   127
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
   128
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
   129
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   130
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
   131
---------------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   132
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   133
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
   134
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
   135
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
   136
core.add_sources ('foo.cc')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   137
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
   138
header should be installable:
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   139
core.add_inst_headers ('foo.h')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   140
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   141
5) How to create a new module ?
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   142
-------------------------------
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   143
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   144
# 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
   145
# 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
   146
# 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
   147
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
   148
# add it to build system
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   149
ns3.add (my_module)
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   150
# specify module dependencies. Here, depends
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   151
# on the 'ipv4' and 'core' modules
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   152
my_module.add_deps (['core', 'ipv4']) 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   153
# add source code to build located in 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   154
# src/my_dir
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   155
my_module.add_sources ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   156
	'my_a.cc',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   157
	'my_b.cc',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   158
	'my_c.cc'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   159
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   160
my_module.add_sources ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   161
	'my_d.cc'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   162
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   163
# add headers which are not public
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   164
my_module.add_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   165
	'my_a.h',
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   166
	'my_c.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
# add headers which are public
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   169
my_module.add_inst_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   170
	'my_b.h'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   171
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   172
my_module.add_inst_headers ([
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   173
	'my_d.h'
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   174
])
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   175
# 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
   176
# you must add 'external' dependencies. Here, the 
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   177
# pthread library
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   178
my_module.add_external_dep ('pthread')
2437ccac8acd add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 88
diff changeset
   179
# 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
   180
# 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
   181
my_module.set_executable ()
168
037cd2b37c67 split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 125
diff changeset
   182