Files
unison/doc/build.txt

108 lines
3.5 KiB
Plaintext
Raw Normal View History

2007-07-16 21:41:19 -07:00
The Waf build system is used to build ns-3. Waf is a Python-based
build system (http://www.freehackers.org/~tnagy/waf.html)
2008-09-11 08:45:00 -07:00
Note: We've added a wiki page with more complete build instructions
than the quick ones you find below:
http://www.nsnam.org/wiki/index.php/Installation
2007-07-16 21:41:19 -07:00
=== Installing Waf ===
The top-level ns-3 directory should contain a current waf script, so
there is no need to have WAF installed in the system. We are using
some extensions to WAF, which can be found in the 'waf-tools'
directory. The upstream location for these WAF extensions is:
2008-12-29 13:28:54 +00:00
https://code.launchpad.net/~gjc/waf/cmd
2007-07-16 21:41:19 -07:00
=== Building with Waf ===
2007-10-15 21:13:21 -07:00
To build ns-3 with waf type the commands from the top-level directory:
1. ./waf configure [options]
2. ./waf
2007-07-16 21:41:19 -07:00
2007-10-15 21:13:21 -07:00
To see valid configure options, type ./waf --help. The most important
2007-07-16 21:41:19 -07:00
option is -d <debug level>. Valid debug levels (which are listed in
2007-10-15 21:13:21 -07:00
waf --help) are: "debug" or "optimized". It is
2007-07-16 21:41:19 -07:00
also possible to change the flags used for compilation with (e.g.):
2007-10-15 21:13:21 -07:00
CXXFLAGS="-O3" ./waf configure.
2007-07-16 21:41:19 -07:00
[ Note: Unlike some other build tools, to change the build target,
the option must be supplied during the configure stage rather than
2007-10-15 21:13:21 -07:00
the build stage (i.e., "./waf -d optimized" will not work; instead, do
"./waf -d optimized configure; ./waf" ]
2007-07-16 21:41:19 -07:00
The resulting binaries are placed in build/<debuglevel>/srcpath.
Other waf usages include:
2009-06-15 15:42:32 -07:00
1. ./waf --check
2007-07-16 21:41:19 -07:00
Runs the unit tests
2007-10-15 21:13:21 -07:00
2. ./waf --doxygen
2007-07-16 21:41:19 -07:00
Run doxygen to generate documentation
2007-10-15 21:13:21 -07:00
3. ./waf --lcov-report
2007-07-16 21:41:19 -07:00
Run code coverage analysis (assuming the project was configured
with --enable-gcov)
2007-10-15 21:13:21 -07:00
4. ./waf --run "program [args]"
2007-07-16 21:41:19 -07:00
Run a ns3 program, given its target name, with the given
arguments. This takes care of automatically modifying the the
path for finding the ns3 dynamic libraries in the environment
before running the program. Note: the "program [args]" string is
parsed using POSIX shell rules.
2007-10-15 21:13:21 -07:00
4.1 ./waf --run programname --command-template "... %s ..."
Same as --run, but uses a command template with %s replaced by the
actual program (whose name is given by --run). This can be use to
run ns-3 programs with helper tools. For example, to run unit
tests with valgrind, use the command:
2007-10-15 21:13:21 -07:00
./waf --run run-tests --command-template "valgrind %s"
2007-10-15 21:13:21 -07:00
5. ./waf --shell
2007-07-16 21:41:19 -07:00
Starts a nested system shell with modified environment to run ns3 programs.
2007-10-15 21:13:21 -07:00
6. ./waf distclean
2007-07-16 21:41:19 -07:00
Cleans out the entire build/ directory
2007-10-15 21:13:21 -07:00
7. ./waf dist
2007-07-16 21:41:19 -07:00
The command 'waf dist' can be used to create a distribution tarball.
It includes all files in the source directory, except some particular
extensions that are blacklisted, such as back files (ending in ~).
=== Extending ns-3 ===
To add new modules:
1. Create the module directory under src (or src/devices, or whatever);
2. Add the source files to it;
3. Add a 'wscript' describing it;
4. Add the module subdirectory name to the all_modules list in src/wscript.
A module's wscript file is basically a regular Waf script. A ns-3
module is created as a cpp/shlib object, like this:
def build(bld):
obj = bld.create_obj('cpp', 'shlib')
## set module name; by convention it starts with ns3-
obj.name = 'ns3-mymodule'
obj.target = obj.name
## list dependencies to other modules
obj.uselib_local = ['ns3-core']
## list source files (private or public header files excluded)
obj.source = [
'mymodule.cc',
]
## list module public header files
headers = bld.create_obj('ns3header')
headers.source = [
'mymodule-header.h',
]