author | Tom Henderson <tomh@tomh.org> |
Fri, 30 Jan 2015 11:34:38 -0800 | |
changeset 11188 | e010083f6592 |
parent 10401 | 6e9d4ceb880b |
permissions | -rw-r--r-- |
929 | 1 |
The Waf build system is used to build ns-3. Waf is a Python-based |
2 |
build system (http://www.freehackers.org/~tnagy/waf.html) |
|
3 |
||
3688 | 4 |
Note: We've added a wiki page with more complete build instructions |
5 |
than the quick ones you find below: |
|
10401
6e9d4ceb880b
Update ns-3 wiki URL
Daniel Lertpratchya <nikkipui@gmail.com>
parents:
7621
diff
changeset
|
6 |
http://www.nsnam.org/wiki/Installation |
3688 | 7 |
|
929 | 8 |
=== Installing Waf === |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
9 |
|
5449
a9678e91ec7d
Update the build.txt file with new WAF information
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4534
diff
changeset
|
10 |
The top-level ns-3 directory should contain a current waf script, so |
a9678e91ec7d
Update the build.txt file with new WAF information
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4534
diff
changeset
|
11 |
there is no need to have WAF installed in the system. We are using |
a9678e91ec7d
Update the build.txt file with new WAF information
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4534
diff
changeset
|
12 |
some extensions to WAF, which can be found in the 'waf-tools' |
a9678e91ec7d
Update the build.txt file with new WAF information
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
4534
diff
changeset
|
13 |
directory. The upstream location for these WAF extensions is: |
4064
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3688
diff
changeset
|
14 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3688
diff
changeset
|
15 |
https://code.launchpad.net/~gjc/waf/cmd |
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3688
diff
changeset
|
16 |
|
10222f483860
Upgrade to new WAF, work in progress
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
3688
diff
changeset
|
17 |
|
929 | 18 |
=== Building with Waf === |
19 |
||
1788 | 20 |
To build ns-3 with waf type the commands from the top-level directory: |
21 |
1. ./waf configure [options] |
|
22 |
2. ./waf |
|
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
|
1788 | 24 |
To see valid configure options, type ./waf --help. The most important |
929 | 25 |
option is -d <debug level>. Valid debug levels (which are listed in |
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
26 |
waf --help) are: "debug" or "optimized", with debug being default. It is |
929 | 27 |
also possible to change the flags used for compilation with (e.g.): |
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
28 |
CXXFLAGS="-O3" ./waf configure. By default, ns-3 is built as debug code, |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
29 |
with examples and tests disabled, and with python bindings enabled. |
57
9385fba1589e
add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
17
diff
changeset
|
30 |
|
929 | 31 |
[ Note: Unlike some other build tools, to change the build target, |
32 |
the option must be supplied during the configure stage rather than |
|
1788 | 33 |
the build stage (i.e., "./waf -d optimized" will not work; instead, do |
34 |
"./waf -d optimized configure; ./waf" ] |
|
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
36 |
The resulting executables and libraries are placed in build/. |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
|
929 | 38 |
Other waf usages include: |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
39 |
|
7024
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
40 |
1. ./waf configure --enable-examples --enable-tests |
4392d52b3536
Make examples not be built by default
Mitch Watrous <watrous@u.washington.edu>
parents:
6998
diff
changeset
|
41 |
Turn on examples and tests. |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
42 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
43 |
2. ./waf configure --disable-python |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
44 |
Disable python bindings. |
116
d4ee28e845f3
add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
115
diff
changeset
|
45 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
46 |
3. ./waf --doxygen |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
47 |
Run doxygen to generate documentation |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
48 |
|
1788 | 49 |
4. ./waf --run "program [args]" |
929 | 50 |
Run a ns3 program, given its target name, with the given |
51 |
arguments. This takes care of automatically modifying the the |
|
52 |
path for finding the ns3 dynamic libraries in the environment |
|
53 |
before running the program. Note: the "program [args]" string is |
|
54 |
parsed using POSIX shell rules. |
|
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
55 |
|
1788 | 56 |
4.1 ./waf --run programname --command-template "... %s ..." |
935
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
57 |
|
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
58 |
Same as --run, but uses a command template with %s replaced by the |
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
59 |
actual program (whose name is given by --run). This can be use to |
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
60 |
run ns-3 programs with helper tools. For example, to run unit |
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
61 |
tests with valgrind, use the command: |
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
62 |
|
1788 | 63 |
./waf --run run-tests --command-template "valgrind %s" |
935
53e1e53c373f
WAF: add a --command-template option to e.g. allow running programs with valgrind, gdb, etc.
Gustavo J. A. M. Carneiro <gjc@inescporto.pt>
parents:
934
diff
changeset
|
64 |
|
1788 | 65 |
5. ./waf --shell |
929 | 66 |
Starts a nested system shell with modified environment to run ns3 programs. |
67 |
||
1788 | 68 |
6. ./waf distclean |
929 | 69 |
Cleans out the entire build/ directory |
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
70 |
|
1788 | 71 |
7. ./waf dist |
929 | 72 |
The command 'waf dist' can be used to create a distribution tarball. |
73 |
It includes all files in the source directory, except some particular |
|
74 |
extensions that are blacklisted, such as back files (ending in ~). |
|
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
75 |
|
929 | 76 |
=== Extending ns-3 === |
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
77 |
|
929 | 78 |
To add new modules: |
7145
a925e518220b
Rescan wifi's bindings and fix some paths in the documentation
Mitch Watrous <watrous@u.washington.edu>
parents:
7024
diff
changeset
|
79 |
1. Create the module directory under src; |
929 | 80 |
2. Add the source files to it; |
81 |
3. Add a 'wscript' describing it; |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
82 |
|
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
83 |
A convenience program to auto-generate the template of a new module can |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
84 |
be found in src/create-module.py. |
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
85 |
|
929 | 86 |
A module's wscript file is basically a regular Waf script. A ns-3 |
87 |
module is created as a cpp/shlib object, like this: |
|
88 |
||
89 |
def build(bld): |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
90 |
module = bld.create_ns3_module('ns3-mymodule', ['core']) |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
91 |
module.source = [ |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
92 |
'model/ns3-mymodule.cc', |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
93 |
'helper/ns3-mymodule-helper.cc', |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
94 |
] |
168
037cd2b37c67
split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
125
diff
changeset
|
95 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
96 |
headers = bld.new_task_gen(features=['ns3header']) |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
97 |
headers.module = 'ns3-mymodule' |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
98 |
headers.source = [ |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
99 |
'model/ns3-mymodule.h', |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
100 |
'helper/ns3-mymodule-helper.h', |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
101 |
] |
929 | 102 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
103 |
if bld.env.ENABLE_EXAMPLES: |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
104 |
bld.add_subdirs('examples') |
929 | 105 |
|
7621
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
106 |
# bld.ns3_python_bindings() |
b0120c820a67
Fix outdated README information
Tom Henderson <tomh@tomh.org>
parents:
7145
diff
changeset
|
107 |