Alexander Afanasyev | 1dd37ed | 2013-08-14 18:08:09 -0700 | [diff] [blame^] | 1 | #! /usr/bin/env python |
| 2 | # encoding: utf-8 |
| 3 | |
| 4 | from waflib import Configure |
| 5 | |
| 6 | @Configure.conf |
| 7 | def add_supported_cflags(self, cflags): |
| 8 | """ |
| 9 | Check which cflags are supported by compiler and add them to env.CFLAGS variable |
| 10 | """ |
| 11 | self.start_msg('Checking allowed flags for c compiler') |
| 12 | |
| 13 | supportedFlags = [] |
| 14 | for flag in cflags: |
| 15 | if self.check_cc (cflags=[flag], mandatory=False): |
| 16 | supportedFlags += [flag] |
| 17 | |
| 18 | self.end_msg (' '.join (supportedFlags)) |
| 19 | self.env.CFLAGS += supportedFlags |
| 20 | |
| 21 | def configure(conf): |
| 22 | conf.load ('gnu_dirs') |
| 23 | |
| 24 | if conf.options.debug: |
| 25 | conf.define ('_DEBUG', 1) |
| 26 | conf.add_supported_cflags (cflags = ['-O0', |
| 27 | '-Wall', |
| 28 | '-Wno-unused-variable', |
| 29 | '-g3', |
| 30 | '-Wno-unused-private-field', # only clang supports |
| 31 | '-fcolor-diagnostics', # only clang supports |
| 32 | '-Qunused-arguments' # only clang supports |
| 33 | ]) |
| 34 | else: |
| 35 | conf.add_supported_cflags (cflags = ['-O3', '-g']) |
| 36 | |
| 37 | def options(opt): |
| 38 | opt.load ('gnu_dirs') |
| 39 | opt.add_option('--debug',action='store_true',default=False,dest='debug',help='''debugging mode''') |