author | Tom Henderson <tomh@tomh.org> |
Fri, 18 May 2007 11:13:57 -0700 | |
changeset 658 | 32307a281d86 |
parent 657 | be551a3b07c6 |
child 929 | 9394956b7fc4 |
permissions | -rw-r--r-- |
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 |
|
658
32307a281d86
Pick up codingstd.txt in dist; point interested waf users to build-waf.txt in the development branch
Tom Henderson <tomh@tomh.org>
parents:
657
diff
changeset
|
19 |
(Note: An alternative build system (Waf) is being |
32307a281d86
Pick up codingstd.txt in dist; point interested waf users to build-waf.txt in the development branch
Tom Henderson <tomh@tomh.org>
parents:
657
diff
changeset
|
20 |
evaluated in the development branch of ns-3-dev on our server |
32307a281d86
Pick up codingstd.txt in dist; point interested waf users to build-waf.txt in the development branch
Tom Henderson <tomh@tomh.org>
parents:
657
diff
changeset
|
21 |
only (i.e., not in the release tarballs)-- see doc/build-waf.txt) |
657
be551a3b07c6
minor changes due to documentation review
Tom Henderson <tomh@tomh.org>
parents:
635
diff
changeset
|
22 |
|
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
1) Options |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
---------- |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
25 |
|
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
26 |
- 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
|
27 |
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
|
28 |
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
|
29 |
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
|
30 |
- 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
|
31 |
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
|
32 |
- 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
|
33 |
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
|
34 |
- 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
|
35 |
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
|
36 |
- 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
|
37 |
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
|
38 |
- 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
|
39 |
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
|
40 |
- 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
|
41 |
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
|
42 |
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
|
43 |
uses 128 integers. |
037cd2b37c67
split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
125
diff
changeset
|
44 |
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
|
45 |
- 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
|
46 |
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
|
47 |
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
|
48 |
Example: scons inheritenv=y |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
49 |
|
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
50 |
2) Targets |
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 |
|
57
9385fba1589e
add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
17
diff
changeset
|
53 |
- doc: build the doxygen documentation. |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
54 |
Example: scons doc |
57
9385fba1589e
add doc target to BUILD file
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
17
diff
changeset
|
55 |
|
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
56 |
- dbg-shared: a debug 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/dbg-shared/'. |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
58 |
Example: scons dbg-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 |
- dbg-static: a debug 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/dbg-static/'. |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
62 |
Example: scons dbg-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 |
- opt-shared: an optimized build using shared libraries. |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
65 |
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
|
66 |
Example: scons opt-shared |
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 |
- opt-static: an optimized build using static libraries. |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
69 |
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
|
70 |
Example: scons opt-static |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
|
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
72 |
- dbg: an alias for dbg-shared |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
73 |
Example: scons dbg |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
74 |
|
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
- opt: an alias for opt-shared |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
76 |
Example: scons opt |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
77 |
|
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
78 |
- all: alias for dbg-shared, dbg-static, opt-shared |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
79 |
and opt-static |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
80 |
Example: scons all |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
81 |
|
116
d4ee28e845f3
add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
115
diff
changeset
|
82 |
- 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
|
83 |
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
|
84 |
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
|
85 |
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
|
86 |
the gcov data, use the lcov-report target |
472ff5fe2eef
document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
116
diff
changeset
|
87 |
|
472ff5fe2eef
document gcov/lcov targets
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
116
diff
changeset
|
88 |
- 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
|
89 |
is stored in 'build-dir/lcov-report/'. |
116
d4ee28e845f3
add lcov support
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
115
diff
changeset
|
90 |
|
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
91 |
- dist: generate a release tarball and zipfile from the |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
source tree. The tarball and zipfile name are generated |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
93 |
according to the version number stored in the SConstruct |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
94 |
file. |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
95 |
Example in SConstruct: |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
96 |
ns3 = Ns3 () |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
97 |
ns3.name = 'foo' |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
98 |
ns3.version = '0.0.10' |
87
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
99 |
Example command: scons dist |
a1b7dc32df30
beautify build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
57
diff
changeset
|
100 |
Example output files: |
17
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
101 |
foo-0.0.10.tar.gz |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
102 |
foo-0.0.10.zip |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
103 |
|
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
104 |
- distcheck: generate a release tarball and zipfile and |
b959311b6aa1
build instructions
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
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
|
106 |
Example: scons distcheck |
101
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
107 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
108 |
3) How the build system works |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
109 |
----------------------------- |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
110 |
|
125 | 111 |
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
|
112 |
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
|
113 |
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
|
114 |
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
|
115 |
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
|
116 |
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
|
117 |
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
|
118 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
119 |
To build a module, we: |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
120 |
1) generate the .o files |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
121 |
2) link the .o files together |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
122 |
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
|
123 |
top_build_dir/include/ns3. |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
124 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
125 |
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
|
126 |
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
|
127 |
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
|
128 |
"ns3/bar.h". This allows you to make sure that our "public" ns3 headers |
125 | 129 |
do not conflict with existing system-level headers. For instance, |
130 |
if you were to define a header called queue.h, you would include |
|
131 |
ns3/queue.h rather than queue.h, when including from a separate module, |
|
132 |
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
|
133 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
134 |
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
|
135 |
--------------------------------- |
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 |
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
|
138 |
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
|
139 |
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
|
140 |
core.add_sources ('foo.cc') |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
141 |
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
|
142 |
header should be installable: |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
143 |
core.add_inst_headers ('foo.h') |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
144 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
145 |
5) How to create a new module ? |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
146 |
------------------------------- |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
147 |
|
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
148 |
# 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
|
149 |
# 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
|
150 |
# 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
|
151 |
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
|
152 |
# add it to build system |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
153 |
ns3.add (my_module) |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
154 |
# specify module dependencies. Here, depends |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
155 |
# on the 'ipv4' and 'core' modules |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
156 |
my_module.add_deps (['core', 'ipv4']) |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
157 |
# add source code to build located in |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
158 |
# src/my_dir |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
159 |
my_module.add_sources ([ |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
160 |
'my_a.cc', |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
161 |
'my_b.cc', |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
162 |
'my_c.cc' |
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 |
my_module.add_sources ([ |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
165 |
'my_d.cc' |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
166 |
]) |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
167 |
# add headers which are not public |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
168 |
my_module.add_headers ([ |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
169 |
'my_a.h', |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
170 |
'my_c.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 |
# add headers which are public |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
173 |
my_module.add_inst_headers ([ |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
174 |
'my_b.h' |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
175 |
]) |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
176 |
my_module.add_inst_headers ([ |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
177 |
'my_d.h' |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
178 |
]) |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
179 |
# 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
|
180 |
# you must add 'external' dependencies. Here, the |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
181 |
# pthread library |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
182 |
my_module.add_external_dep ('pthread') |
2437ccac8acd
add documentation on build system
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
88
diff
changeset
|
183 |
# 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
|
184 |
# 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
|
185 |
my_module.set_executable () |
168
037cd2b37c67
split high precision implementations in different files
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
125
diff
changeset
|
186 |