xc16_gcc.py - Configure waf for the xc16 compilerΒΆ

This was copied from waf v1.8.21 then modified for the xc16 compiler.

#!/usr/bin/env python

encoding: utf-8 Thomas Nagy, 2006-2010 (ita) Ralf Habacker, 2006 (rh) Yinon Ehrlich, 2009


gcc/llvm detection.

from waflib.Tools.gcc import configure
from waflib.Tools import ccroot
import xc16_ar
from waflib.Configure import conf

def find_gcc(conf):

Find the program gcc, and if present, try to detect its version number

    cc = conf.find_program(['xc16-gcc'], var='CC')
    conf.get_cc_version(cc, gcc=True)
    conf.env.CC_NAME = 'xc16-gcc'

def gcc_modifier_PIC24(conf):
    v = conf.env
    v['cprogram_PATTERN'] = '%s.elf'
    v.append_value('CFLAGS', [

Select the processor.


Create an ELF-formatted binary.


Generate debugging info


For debug, don’t optimize.


Analyze printf strings to see if the integer-only variant of printf can be used. See the manual.


Turn on helpful warnings.

      '-Wall', '-Wextra', '-Wdeclaration-after-statement', '-Wlong-long',
    v.append_value('LINKFLAGS', [