Alexander Afanasyev | 0ad7c21 | 2012-04-05 13:31:14 -0700 | [diff] [blame] | 1 | ## -*- Mode: python; py-indent-offset: 4; indent-tabs-mode: nil; coding: utf-8; -*- |
| 2 | |
| 3 | import waflib |
| 4 | from waflib.Configure import conf |
| 5 | from waflib import Utils,Logs,Errors |
| 6 | |
| 7 | @conf |
| 8 | def _print_optional_features(conf): |
| 9 | # Write a summary of optional features status |
| 10 | print "---- Summary of optional NS-3 features:" |
| 11 | Logs.pprint ('RED', "---- Summary of optional NS-3 features:") |
| 12 | # for (name, caption, was_enabled, reason_not_enabled) in conf.env['NS3_OPTIONAL_FEATURES']: |
| 13 | # if was_enabled: |
| 14 | # status = 'enabled' |
| 15 | # else: |
| 16 | # status = 'not enabled (%s)' % reason_not_enabled |
| 17 | # print "%-30s: %s" % (caption, status) |
| 18 | |
| 19 | @conf |
| 20 | def _check_dependencies(conf, required, mandatory): |
| 21 | # Logs.pprint ('CYAN', ' + %s' % required) |
| 22 | found = [] |
| 23 | for module in required: |
| 24 | retval = conf.check_cfg(package = 'libns3-dev-%s-debug' % module, |
| 25 | args='--cflags --libs', mandatory=mandatory, |
| 26 | msg="Checking for ns3-%s" % module, |
| 27 | uselib_store='NS3_%s' % module.upper()) |
| 28 | # Logs.pprint ('CYAN', 'NS3_%s' % module.upper()) |
| 29 | if not retval is None: |
| 30 | found.append(module) |
| 31 | import copy |
| 32 | if not 'NS3_MODULES_FOUND' in conf.env: |
| 33 | conf.env['NS3_MODULES_FOUND'] = [] |
| 34 | conf.env['NS3_MODULES_FOUND'] = conf.env['NS3_MODULES_FOUND'] + copy.copy(found) |
| 35 | |
| 36 | def modules_uselib(bld, names): |
| 37 | return ['NS3_%s' % name.upper() for name in names] + \ |
| 38 | ['NS3_LIBRARY_%s' % name.upper() for name in names] + \ |
| 39 | ['NS3_HEADERS_%s' % name.upper() for name in names] |
| 40 | |
| 41 | def modules_found(bld, needed): |
| 42 | for module in needed: |
| 43 | if not module in bld.env['NS3_MODULES_FOUND']: |
| 44 | return False |
| 45 | return True |
| 46 | |
| 47 | @conf |
| 48 | def check_modules(conf, modules, mandatory = True): |
| 49 | import os |
| 50 | |
| 51 | if not 'NS3_CHECK_MODULE_ONCE' in conf.env: |
| 52 | conf.env['NS3_CHECK_MODULE_ONCE'] = '' |
| 53 | |
| 54 | conf.check_cfg(atleast_pkgconfig_version='0.0.0') |
| 55 | |
| 56 | if conf.options.log4cxx: |
| 57 | conf.env.append_value('DEFINES', 'NS3_LOG_ENABLE') |
| 58 | |
| 59 | conf._check_dependencies(modules, mandatory) |
| 60 | conf._print_optional_features |
| 61 | |
| 62 | @conf |
| 63 | def print_ns3_feature_summary(conf): |
| 64 | Logs.pprint ('CYAN', "---- Summary of optional NS-3 features:") |
| 65 | conf._print_optional_features |
| 66 | |