SConstruct
changeset 8 cb4ae01ba180
child 13 b69ebc273a06
equal deleted inserted replaced
7:e53ac3c458e9 8:cb4ae01ba180
       
     1 
       
     2 import os
       
     3 import os.path
       
     4 import shutil
       
     5 
       
     6 class Ns3Module:
       
     7 	def __init__ (self, name, dir):
       
     8 		self.sources = []
       
     9 		self.inst_headers = []
       
    10 		self.headers = []
       
    11 		self.extra_dist = []
       
    12 		self.deps = []
       
    13 		self.external_deps = []
       
    14 		self.config = []
       
    15 		self.name = name
       
    16 		self.dir = dir
       
    17 		self.executable = False
       
    18 		self.library = True
       
    19 	def set_library (self):
       
    20 		self.library = True
       
    21 		self.executable = False
       
    22 	def set_executable (self):
       
    23 		self.library = False
       
    24 		self.executable = True
       
    25 	def add_config (self, config_fn):
       
    26 		self.config.append (config_fn)
       
    27 	def add_extra_dist (self, dist):
       
    28 		self.extra_dist.append (dist)
       
    29 	def add_external_dep (self, dep):
       
    30 		self.external_deps.append (dep)
       
    31 	def add_dep (self, dep):
       
    32 		self.deps.append (dep)
       
    33 	def add_deps (self, deps):
       
    34 		self.deps.extend (deps)
       
    35 	def add_source (self, source):
       
    36 		self.sources.append (source)
       
    37 	def add_sources (self, sources):
       
    38 		self.sources.extend (sources)
       
    39 	def add_header (self, header):
       
    40 		self.headers.append (header)
       
    41 	def add_headers (self, headers):
       
    42 		self.headers.extend (headers)
       
    43 	def add_inst_header (self, header):
       
    44 		self.inst_headers.append (header)
       
    45 	def add_inst_headers (self, headers):
       
    46 		self.inst_headers.extend (headers)
       
    47 
       
    48 def MyCopyAction (target, source, env):
       
    49 	try:
       
    50 		if len (target) == len (source):
       
    51 			for i in range (len(target)):
       
    52 				shutil.copy (source[i].path, target[i].path)
       
    53 			return 0
       
    54 		else:
       
    55 			return 'invalid target/source match'
       
    56 	except:
       
    57 		print
       
    58 		return 'exception'
       
    59 def MyCopyActionPrint (target, source, env):
       
    60 	if len (target) == len (source):
       
    61 		output = ''
       
    62 		for i in range (len(target)):
       
    63 			output = output + 'copy \'' + source[i].path + '\' to \'' + target[i].path  + '\''
       
    64 			if i < len (target) - 1:
       
    65 				output = output + '\n'
       
    66 		return output
       
    67 	else:
       
    68 		return 'error in copy'
       
    69 def GcxxEmitter (target, source, env):
       
    70 	if os.path.exists (source[0].path):
       
    71 		return [target, source]
       
    72 	else:
       
    73 		return [[], []]
       
    74 def MyRmTree (target, source, env):
       
    75 	shutil.rmtree (env['RM_DIR'])
       
    76 	return 0
       
    77 def MyRmTreePrint (target, source, env):
       
    78 	return ''
       
    79 def print_cmd_line(s, target, src, env):
       
    80 	print 'Building ' + (' and '.join([str(x) for x in target])) + '...'
       
    81 
       
    82 class Ns3BuildVariant:
       
    83 	def __init__ (self):
       
    84 		self.static = False
       
    85 		self.gcxx_deps = False
       
    86 		self.gcxx_root = ''
       
    87 		self.build_root = ''
       
    88 		self.env = None
       
    89 
       
    90 class Ns3:
       
    91 	def __init__ (self):
       
    92 		self.__modules = []
       
    93 		self.extra_dist = []
       
    94 		self.build_dir = 'build'
       
    95 		self.version = '0.0.1'
       
    96 		self.name = 'noname'
       
    97 	def add (self, module):
       
    98 		self.__modules.append (module)
       
    99 	def add_extra_dist (self, dist):
       
   100 		self.extra_dist.append (dist)
       
   101 	def __get_module (self, name):
       
   102 		for module in self.__modules:
       
   103 			if module.name == name:
       
   104 				return module
       
   105 		return None
       
   106 	def get_mod_output (self, module, variant):
       
   107 		if module.executable:
       
   108 			suffix = variant.env.subst (variant.env['PROGSUFFIX'])
       
   109 			filename = os.path.join (variant.build_root, 'bin',
       
   110 						 module.name + suffix)
       
   111 		else:
       
   112 			if variant.static:
       
   113 				prefix = variant.env['LIBPREFIX']
       
   114 				suffix = variant.env['LIBSUFFIX']
       
   115 			else:
       
   116 				prefix = variant.env['SHLIBPREFIX']
       
   117 				suffix = variant.env['SHLIBSUFFIX']
       
   118 			prefix = variant.env.subst (prefix)
       
   119 			suffix = variant.env.subst (suffix)
       
   120 			filename = os.path.join (variant.build_root, 'lib',
       
   121 						 prefix + module.name + suffix)
       
   122 		return filename				
       
   123 	def get_obj_builders (self, variant, module):
       
   124 		env = variant.env
       
   125 		objects = []
       
   126 		if len (module.config) > 0:
       
   127 			src_config_file = os.path.join (self.build_dir, 'config', module.name + '-config.h')
       
   128 			tgt_config_file = os.path.join (variant.build_root, 'include',
       
   129 							'ns3', module.name + '-config.h')
       
   130 		
       
   131 		for source in module.sources:
       
   132 			obj_file = os.path.splitext (source)[0] + '.o'
       
   133 			tgt = os.path.join (variant.build_root, module.dir, obj_file)
       
   134 			src = os.path.join (module.dir, source)
       
   135 			if variant.static:
       
   136 				obj_builder = env.StaticObject (target = tgt, source = src)
       
   137 			else:
       
   138 				obj_builder = env.SharedObject (target = tgt, source = src)
       
   139 			if len (module.config) > 0:
       
   140 				config_file = env.MyCopyBuilder (target = [tgt_config_file],
       
   141 								 source = [src_config_file])
       
   142 				env.Depends (obj_builder, config_file)
       
   143 			if variant.gcxx_deps:
       
   144 				gcno_tgt = os.path.join (variant.build_root, module.dir, 
       
   145 							 os.path.splitext (source)[0] + '.gcno')
       
   146 				gcda_tgt = os.path.join (variant.build_root, module.dir,
       
   147 							 os.path.splitext (source)[0] + '.gcda')
       
   148 				gcda_src = os.path.join (variant.gcxx_root, module.dir, 
       
   149 							 os.path.splitext (source)[0] + '.gcda')
       
   150 				gcno_src = os.path.join (variant.gcxx_root, module.dir, 
       
   151 							 os.path.splitext (source)[0] + '.gcno')
       
   152 				gcno_builder = env.CopyGcxxBuilder (target = gcno_tgt, source = gcno_src)
       
   153 				gcda_builder = env.CopyGcxxBuilder (target = gcda_tgt, source = gcda_src)
       
   154 				env.Depends (obj_builder, gcda_builder)
       
   155 				env.Depends (obj_builder, gcno_builder)
       
   156 			objects.append (obj_builder)
       
   157 		return objects
       
   158 	def get_internal_deps (self, module, hash):
       
   159 		for dep_name in module.deps:
       
   160 			dep = self.__get_module (dep_name)
       
   161 			hash[dep_name] = dep
       
   162 			self.get_internal_deps (dep, hash)
       
   163 	def get_external_deps (self, module):
       
   164 		hash = {}
       
   165 		self.get_internal_deps (module, hash)
       
   166 		ext_hash = {}
       
   167 		for mod in hash.values ():
       
   168 			for ext_dep in mod.external_deps:
       
   169 				ext_hash[ext_dep] = 1
       
   170 		return ext_hash.keys ()
       
   171 	def get_sorted_deps (self, module):
       
   172 		h = {}
       
   173 		self.get_internal_deps (module, h)
       
   174 		modules = []
       
   175 		for dep in h.keys ():
       
   176 			deps_copy = []
       
   177 			mod = h[dep]
       
   178 			deps_copy.extend (mod.deps)
       
   179 			modules.append ([mod, deps_copy])
       
   180 		sorted = []
       
   181 		while len (modules) > 0:
       
   182 			to_remove = []
       
   183 			for item in modules:
       
   184 				if len (item[1]) == 0:
       
   185 					to_remove.append (item[0].name)
       
   186 			for item in to_remove:
       
   187 				for i in modules:
       
   188 					if item in i[1]:
       
   189 						i[1].remove (item)
       
   190 			new_modules = []
       
   191 			for mod in modules:
       
   192 				found = False
       
   193 				for i in to_remove:
       
   194 					if i == mod[0].name:
       
   195 						found = True
       
   196 						break
       
   197 				if not found:
       
   198 					new_modules.append (mod)
       
   199 			modules = new_modules
       
   200 			sorted.extend (to_remove)
       
   201 		sorted.reverse ()
       
   202 		# append external deps
       
   203 		ext_deps = self.get_external_deps (module)
       
   204 		for dep in ext_deps:
       
   205 			sorted.append (dep)
       
   206 		return sorted
       
   207 			
       
   208 	def gen_mod_dep (self, variant):
       
   209 		build_root = variant.build_root
       
   210 		cpp_path = os.path.join (variant.build_root, 'include')
       
   211 		env = variant.env
       
   212 		env.Append (CPPPATH=[cpp_path])
       
   213 		header_dir = os.path.join (build_root, 'include', 'ns3')
       
   214 		lib_path = os.path.join (build_root, 'lib')
       
   215 		module_builders = []
       
   216 		for module in self.__modules:
       
   217 			objects = self.get_obj_builders (variant, module)
       
   218 			libs = self.get_sorted_deps (module)
       
   219 
       
   220 			filename = self.get_mod_output (module, variant)
       
   221 			if module.executable:
       
   222 				module_builder = env.Program (target = filename, source = objects,
       
   223 							      LIBPATH=lib_path, LIBS=libs, RPATH=lib_path)
       
   224 			else:
       
   225 				if variant.static:
       
   226 					module_builder = env.StaticLibrary (target = filename, source = objects)
       
   227 				else:
       
   228 					module_builder = env.SharedLibrary (target = filename, source = objects,
       
   229 									    LIBPATH=lib_path, LIBS=libs)
       
   230 					
       
   231 			for dep_name in module.deps:
       
   232 				dep = self.__get_module (dep_name)
       
   233 				env.Depends (module_builder, self.get_mod_output (dep, variant))
       
   234 					
       
   235 			for header in module.inst_headers:
       
   236 				tgt = os.path.join (header_dir, header)
       
   237 				src = os.path.join (module.dir, header)
       
   238 				#builder = env.Install (target = tgt, source = src)
       
   239 				header_builder = env.MyCopyBuilder (target = tgt, source = src)
       
   240 				env.Depends (module_builder, header_builder)
       
   241 				
       
   242 			module_builders.append (module_builder)
       
   243 		return module_builders
       
   244 	def gen_mod_config (self, env):
       
   245 		config_dir = os.path.join (self.build_dir, 'config')
       
   246 		for module in self.__modules:
       
   247 			if len (module.config) > 0:
       
   248 				config_file = os.path.join (config_dir, module.name + '-config.h')
       
   249 				config_file_guard = module.name + '_CONFIG_H'
       
   250 				config_file_guard.upper ()
       
   251 				if not os.path.isfile (config_file):
       
   252 					if not os.path.isdir (config_dir):
       
   253 						os.makedirs (config_dir)
       
   254 					outfile = open (config_file, 'w')
       
   255 					outfile.write ('#ifndef ' + config_file_guard + '\n')
       
   256 					outfile.write ('#define ' + config_file_guard + '\n')
       
   257 					config = env.Configure ()
       
   258 					for fn in module.config:
       
   259 						output = fn (env, config)
       
   260 						for o in output:
       
   261 							outfile.write (o)
       
   262 							outfile.write ('\n')
       
   263 					outfile.write ('#endif /*' + config_file_guard + '*/\n')
       
   264 					config.Finish ()
       
   265 	def generate_dependencies (self):
       
   266 		env = Environment()
       
   267 		self.gen_mod_config (env)
       
   268 		cc = env['CC']
       
   269 		cxx = env.subst (env['CXX'])
       
   270 		if cc == 'cl' and cxx == 'cl':
       
   271 			env = Environment (tools = ['mingw'])
       
   272 			cc = env['CC']
       
   273 			cxx = env.subst (env['CXX'])
       
   274 		if cc == 'gcc' and cxx == 'g++':
       
   275 			common_flags = ['-g3', '-Wall', '-Werror']
       
   276 			debug_flags = []
       
   277 			opti_flags = ['-O3']
       
   278 		elif cc == 'cl' and cxx == 'cl':
       
   279 			env = Environment (ENV = os.environ)
       
   280 			common_flags = []
       
   281 			debug_flags = ['-W1', '-GX', '-EHsc', '-D_DEBUG', '/MDd']
       
   282 			opti_flags = ['-O2', '-EHsc', '-DNDEBUG', '/MD']
       
   283 		env.Append (CCFLAGS=common_flags,
       
   284 			    CPPDEFINES=['RUN_SELF_TESTS'],
       
   285 			    TARFLAGS='-c -z')
       
   286 		verbose = ARGUMENTS.get('verbose', 'n')
       
   287 		if verbose == 'n':
       
   288 			env['PRINT_CMD_LINE_FUNC'] = print_cmd_line
       
   289 		header_builder = Builder (action = Action (MyCopyAction, strfunction = MyCopyActionPrint))
       
   290 		env.Append (BUILDERS = {'MyCopyBuilder':header_builder})
       
   291 		gcxx_builder = Builder (action = Action (MyCopyAction, strfunction = MyCopyActionPrint),
       
   292 					emitter = GcxxEmitter)
       
   293 		env.Append (BUILDERS = {'CopyGcxxBuilder':gcxx_builder})
       
   294 		variant = Ns3BuildVariant ()
       
   295 		builders = []
       
   296 		
       
   297 
       
   298 		gcov_env = env.Copy ()
       
   299 		gcov_env.Append (CFLAGS=['-fprofile-arcs', '-ftest-coverage'],
       
   300 				 CXXFLAGS=['-fprofile-arcs', '-ftest-coverage'],
       
   301 				 LINKFLAGS=['-fprofile-arcs'])
       
   302 		# code coverage analysis
       
   303 		variant.static = False
       
   304 		variant.env = gcov_env
       
   305 		variant.build_root = os.path.join (self.build_dir, 'gcov')
       
   306 		builders = self.gen_mod_dep (variant)
       
   307 		for builder in builders:
       
   308 			gcov_env.Alias ('gcov', builder)
       
   309 
       
   310 
       
   311 		opt_env = env.Copy ()
       
   312 		opt_env.Append (CFLAGS=opti_flags,
       
   313 				CXXFLAGS=opti_flags,
       
   314 				CPPDEFINES=['NDEBUG'])
       
   315 		# optimized static support
       
   316 		variant.static = True
       
   317 		variant.env = opt_env
       
   318 		variant.build_root = os.path.join (self.build_dir, 'opt-static')
       
   319 		builders = self.gen_mod_dep (variant)
       
   320 		for builder in builders:
       
   321 			opt_env.Alias ('opt-static', builder)
       
   322 
       
   323 
       
   324 		opt_env = env.Copy ()
       
   325 		opt_env.Append (CFLAGS=opti_flags,
       
   326 				CXXFLAGS=opti_flags,
       
   327 				CPPDEFINES=['NDEBUG'])
       
   328 		# optimized shared support
       
   329 		variant.static = False
       
   330 		variant.env = opt_env
       
   331 		variant.build_root = os.path.join (self.build_dir, 'opt-shared')
       
   332 		builders = self.gen_mod_dep (variant)
       
   333 		for builder in builders:
       
   334 			opt_env.Alias ('opt-shared', builder)
       
   335 
       
   336 
       
   337 		arc_env = env.Copy ()
       
   338 		arc_env.Append (CFLAGS=opti_flags,
       
   339 				CXXFLAGS=opti_flags,
       
   340 				CPPDEFINES=['NDEBUG'])
       
   341 		arc_env.Append (CFLAGS=['-frandom-seed=0','-fprofile-generate'],
       
   342 				CXXFLAGS=['-frandom-seed=0','-fprofile-generate'],
       
   343 				LINKFLAGS=['-frandom-seed=0', '-fprofile-generate'])
       
   344 		# arc profiling
       
   345 		variant.static = False
       
   346 		variant.env = arc_env
       
   347 		variant.build_root = os.path.join (self.build_dir, 'opt-arc')
       
   348 		builders = self.gen_mod_dep (variant)
       
   349 		for builder in builders:
       
   350 			arc_env.Alias ('opt-arc', builder)
       
   351 
       
   352 
       
   353 		arcrebuild_env = env.Copy ()
       
   354 		arcrebuild_env.Append (CFLAGS=opti_flags,
       
   355 				       CXXFLAGS=opti_flags,
       
   356 				       CPPDEFINES=['NDEBUG'])
       
   357 		arcrebuild_env.Append (CFLAGS=['-frandom-seed=0', '-fprofile-use'],
       
   358 				       CXXFLAGS=['-frandom-seed=0', '-fprofile-use'],
       
   359 				       LINKFLAGS=['-frandom-seed=0','-fprofile-use'])
       
   360 		# arc rebuild
       
   361 		variant.static = False
       
   362 		variant.env = arcrebuild_env
       
   363 		variant.gcxx_deps = True
       
   364 		variant.gcxx_root = os.path.join (self.build_dir, 'opt-arc')
       
   365 		variant.build_root = os.path.join (self.build_dir, 'opt-arc-rebuild')
       
   366 		builders = self.gen_mod_dep (variant)
       
   367 		for builder in builders:
       
   368 			arcrebuild_env.Alias ('opt-arc-rebuild', builder)
       
   369 		variant.gcxx_deps = False
       
   370 
       
   371 
       
   372 
       
   373 
       
   374 		dbg_env = env.Copy ()
       
   375 		env.Append (CFLAGS=debug_flags,
       
   376 			    CXXFLAGS=debug_flags,)
       
   377 		# debug static support
       
   378 		variant.static = True
       
   379 		variant.env = dbg_env
       
   380 		variant.build_root = os.path.join (self.build_dir, 'dbg-static')
       
   381 		builders = self.gen_mod_dep (variant)
       
   382 		for builder in builders:
       
   383 			dbg_env.Alias ('dbg-static', builder)
       
   384 
       
   385 		dbg_env = env.Copy ()
       
   386 		env.Append (CFLAGS=debug_flags,
       
   387 			    CXXFLAGS=debug_flags,)
       
   388 		# debug shared support
       
   389 		variant.static = False
       
   390 		variant.env = dbg_env
       
   391 		variant.build_root = os.path.join (self.build_dir, 'dbg-shared')
       
   392 		builders = self.gen_mod_dep (variant)
       
   393 		for builder in builders:
       
   394 			dbg_env.Alias ('dbg-shared', builder)
       
   395 
       
   396 		env.Alias ('dbg', 'dbg-shared')
       
   397 		env.Alias ('opt', 'opt-shared')
       
   398 		env.Default ('dbg')
       
   399 		env.Alias ('all', ['dbg-shared', 'dbg-static', 'opt-shared', 'opt-static'])
       
   400 
       
   401 
       
   402 		# dist support
       
   403 		dist_env = env.Copy ()
       
   404 		if dist_env['PLATFORM'] == 'posix':
       
   405 			dist_list = []
       
   406 			for module in self.__modules:
       
   407 				for f in module.sources:
       
   408 					dist_list.append (os.path.join (module.dir, f))
       
   409 				for f in module.headers:
       
   410 					dist_list.append (os.path.join (module.dir, f))
       
   411 				for f in module.inst_headers:
       
   412 					dist_list.append (os.path.join (module.dir, f))
       
   413 				for f in module.extra_dist:
       
   414 					dist_list.append (os.path.join (module.dir, f))
       
   415 			for f in self.extra_dist:
       
   416 				dist_list.append (tag, f)
       
   417 			dist_list.append ('SConstruct')
       
   418 
       
   419 			targets = []
       
   420 			basename = self.name + '-' + self.version
       
   421 			for src in dist_list:
       
   422 				tgt = os.path.join (basename, src)
       
   423 				targets.append (dist_env.MyCopyBuilder (target = tgt, source = src))
       
   424 			tar = basename + '.tar.gz'
       
   425 			zip = basename + '.zip'
       
   426 			tmp_tar = os.path.join (self.build_dir, tar)
       
   427 			tmp_zip = os.path.join (self.build_dir, zip)
       
   428 			dist_tgt = [tar, zip]
       
   429 			dist_src = [tmp_tar, tmp_zip]
       
   430 			dist_env.Tar (tmp_tar, targets)
       
   431 			dist_env.Zip (tmp_zip, targets)
       
   432 			dist_builder = dist_env.MyCopyBuilder (target = dist_tgt, source = dist_src)
       
   433 			dist_env.Alias ('dist', dist_builder)
       
   434 			dist_env.Append (RM_DIR=basename)
       
   435 			dist_env.AddPostAction (dist_builder, dist_env.Action (MyRmTree,
       
   436 									       strfunction = MyRmTreePrint))
       
   437 			dist_builder = dist_env.MyCopyBuilder (target = dist_tgt, source = dist_src)
       
   438 			dist_env.Alias ('fastdist', dist_tgt)
       
   439 
       
   440 			# distcheck
       
   441 			distcheck_list = []
       
   442 			for src in dist_list:
       
   443 				tgt = os.path.join (self.build_dir, basename, src)
       
   444 				distcheck_list.append (tgt)
       
   445 			untar = env.Command (distcheck_list, tar,
       
   446 					     ['cd ' + self.build_dir + ' && tar -zxf ../' + tar])
       
   447 			scons_dir = os.path.join (self.build_dir, basename)
       
   448 			distcheck_builder = env.Command ('x',distcheck_list,
       
   449 							 ['cd ' + scons_dir + ' && scons'])
       
   450 			env.AlwaysBuild (distcheck_builder)
       
   451 			env.Alias ('distcheck', distcheck_builder)
       
   452 
       
   453 
       
   454 ns3 = Ns3 ()
       
   455 ns3.build_dir = 'build-dir'
       
   456 ns3.version = '0.0.1'
       
   457 ns3.name = 'ns3'
       
   458 
       
   459 
       
   460 #
       
   461 # The Core module
       
   462 #
       
   463 core = Ns3Module ('core', 'src/core')
       
   464 ns3.add (core)
       
   465 core.add_sources ([
       
   466         'reference-list-test.cc',
       
   467         'callback-test.cc',
       
   468         'test.cc'
       
   469 	])
       
   470 env = Environment ()
       
   471 if env['PLATFORM'] == 'posix':
       
   472 	core.add_external_dep ('pthread')
       
   473 	core.add_sources ([
       
   474 		'unix-system-semaphore.cc',
       
   475 		'unix-system-thread.cc',
       
   476 		'unix-system-mutex.cc',
       
   477 		'unix-exec-commands.cc',
       
   478 		'unix-wall-clock-ms.cc',
       
   479 		'unix-system-file.cc'
       
   480 		])
       
   481 elif env['PLATFORM'] == 'win32':
       
   482 	core.add_sources ([
       
   483 		'win32-system-semaphore.cc',
       
   484 		'win32-system-thread.cc',
       
   485 		'win32-system-mutex.cc',
       
   486 		'win32-wall-clock-ms.cc',
       
   487 		'win32-system-file.cc'
       
   488 		])
       
   489 core.add_inst_headers ([
       
   490 	'system-semaphore.h',
       
   491         'system-thread.h',
       
   492         'system-mutex.h',
       
   493 	'system-file.h',
       
   494         'exec-commands.h',
       
   495         'wall-clock-ms.h',
       
   496         'reference-list.h',
       
   497         'callback.h',
       
   498         'test.h'
       
   499 	])
       
   500 
       
   501 
       
   502 #
       
   503 # The Simu module
       
   504 #
       
   505 simu = Ns3Module ('simulator', 'src/simulator')
       
   506 ns3.add (simu)
       
   507 simu.add_dep ('core')
       
   508 simu.add_sources ([
       
   509 	'scheduler.cc', 
       
   510 	'scheduler-list.cc',
       
   511         'scheduler-heap.cc',
       
   512         'scheduler-map.cc',
       
   513         'event-impl.cc',
       
   514         'event-tcc.cc',
       
   515         'event-tcc-test.cc',
       
   516         'simulator.cc',
       
   517 	])
       
   518 simu.add_headers ([
       
   519 	'scheduler.h',
       
   520 	'scheduler-heap.h',
       
   521 	'scheduler-map.h',
       
   522 	'scheduler-list.h'
       
   523 	])
       
   524 simu.add_inst_headers ([
       
   525 	'event.h',
       
   526 	'event-impl.h',
       
   527 	'simulator.h',
       
   528 	'event.tcc'
       
   529 	])
       
   530 
       
   531 #
       
   532 # The Common module
       
   533 #
       
   534 common = Ns3Module ('common', 'src/common')
       
   535 common.add_deps (['core', 'simulator'])
       
   536 ns3.add (common)
       
   537 common.add_sources ([
       
   538 	'buffer.cc',
       
   539 	'mac-address-factory.cc',
       
   540 	'static-position.cc',
       
   541 	'chunk.cc',
       
   542 	'mac-network-interface.cc',
       
   543 	'static-speed-position.cc',
       
   544 	'chunk-constant-data.cc',
       
   545 	'packet.cc',
       
   546 	'tags.cc',
       
   547 	'chunk-llc-snap.cc',
       
   548 	'packet-logger.cc',
       
   549 	'chunk-utils.cc',
       
   550 	'pcap-writer.cc',
       
   551 	'trace-container.cc',
       
   552 	'population-analysis.cc',
       
   553 	'traced-variable-test.cc',
       
   554 	'ipv4-address.cc',
       
   555 	'position.cc',
       
   556 	'trace-stream-test.cc',
       
   557 	'ipv4-network-interface.cc',
       
   558 	'random-uniform-mrg32k3a.cc',
       
   559 	'utils.cc',
       
   560 	'llc-snap-encapsulation.cc',
       
   561 	'rng-mrg32k3a.cc',
       
   562 	'mac-address.cc',
       
   563 	'timeout.cc',
       
   564 	'seed-generator-mrg32k3a.cc'
       
   565 	])
       
   566 common.add_inst_headers ([
       
   567 	'ipv4-address.h',
       
   568 	'buffer.h',
       
   569 	'chunk.h',
       
   570 	'tags.h',
       
   571 	'packet.h',
       
   572 	'ipv4-network-interface.h',
       
   573 	'count-ptr-holder.tcc',
       
   574 	'ui-traced-variable.tcc',
       
   575 	'si-traced-variable.tcc',
       
   576 	'f-traced-variable.tcc',
       
   577 	'callback-logger.h',
       
   578 	'trace-container.h',
       
   579 	'packet-logger.h',
       
   580 	'chunk-constant-data.h',
       
   581 	'mac-address.h',
       
   582 	'chunk-utils.h',
       
   583 	'sgi-hashmap.h',
       
   584 	'llc-snap-encapsulation.h',
       
   585 	'mac-network-interface.h',
       
   586 	'population-analysis.h',
       
   587 	'position.h',
       
   588 	'random-uniform.h',
       
   589 	'timeout.h',
       
   590 	'trace-stream.h',
       
   591 	'pcap-writer.h',
       
   592 	'mac-address-factory.h',
       
   593 	'static-position.h',
       
   594 	'utils.h'
       
   595 	])
       
   596 common.add_headers ([
       
   597 	'chunk-llc-snap.h',
       
   598 	'ref-ptr.h',
       
   599 	'rng-mrg32k3a.h',
       
   600 	'seed-generator.h',
       
   601 	'static-speed-position.h'
       
   602 	])
       
   603 
       
   604 
       
   605 # utils
       
   606 run_tests = Ns3Module ('run-tests', 'utils')
       
   607 ns3.add (run_tests)
       
   608 run_tests.set_executable ()
       
   609 run_tests.add_deps (['core', 'simulator', 'common', 'ipv4', 'arp', 'ethernet', '80211'])
       
   610 run_tests.add_source ('run-tests.cc')
       
   611 
       
   612 bench_packets = Ns3Module ('bench-packets', 'utils')
       
   613 #ns3.add (bench_packets)
       
   614 bench_packets.set_executable ()
       
   615 bench_packets.add_dep ('core')
       
   616 bench_packets.add_source ('bench-packets.cc')
       
   617 
       
   618 bench_simu = Ns3Module ('bench-simulator', 'utils')
       
   619 ns3.add (bench_simu)
       
   620 bench_simu.set_executable ()
       
   621 bench_simu.add_dep ('simulator')
       
   622 bench_simu.add_source ('bench-simulator.cc')
       
   623 
       
   624 
       
   625 # samples
       
   626 main_callback = Ns3Module ('main-callback', 'samples')
       
   627 main_callback.set_executable ()
       
   628 ns3.add (main_callback)
       
   629 main_callback.add_dep ('core')
       
   630 main_callback.add_source ('main-callback.cc')
       
   631 
       
   632 main_event = Ns3Module ('main-event', 'samples')
       
   633 main_event.set_executable ()
       
   634 ns3.add (main_event)
       
   635 main_event.add_dep ('simulator')
       
   636 main_event.add_source ('main-event.cc')
       
   637 
       
   638 main_trace = Ns3Module ('main-trace', 'samples')
       
   639 ns3.add (main_trace)
       
   640 main_trace.add_dep ('common')
       
   641 main_trace.set_executable ()
       
   642 main_trace.add_source ('main-trace.cc')
       
   643 
       
   644 main_simu = Ns3Module ('main-simulator', 'samples')
       
   645 ns3.add (main_simu)
       
   646 main_simu.set_executable ()
       
   647 main_simu.add_dep ('simulator')
       
   648 main_simu.add_source ('main-simulator.cc')
       
   649 
       
   650 main_packet = Ns3Module ('main-packet', 'samples')
       
   651 ns3.add (main_packet)
       
   652 main_packet.set_executable ()
       
   653 main_packet.add_dep ('common')
       
   654 main_packet.add_source ('main-packet.cc')
       
   655 
       
   656 
       
   657 ns3.generate_dependencies ()
       
   658 
       
   659 
       
   660