def configure_device_netx4000(conf):
    conf.gcc_flags()

    f = conf.env.append_value

    f('ASFLAGS_compile_debug',    ['-Wa,-gdwarf2'])
    f('ASFLAGS_compile_debugrel', ['-Wa,-gdwarf2'])

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x,[ '-mlong-calls',
              '-mapcs',
              '-fno-common',])

        f(x + '_compile_debug',    ['-O0', '-g', '-gdwarf-2'])
        f(x + '_compile_debugrel', ['-Os', '-g', '-gdwarf-2'])
        f(x + '_compile_release',  ['-Os'])

    f('ASFLAGS',[ '-mapcs',
                  '-c'])

    f('LINKFLAGS', ['-mthumb-interwork', '-nostdlib'])

    f('DEFINES', ['_NETX_'])
    f('STLIB_nxo_standardlibs',       ['gcc'])
    f('STLIB_default_standardlibs',   ['gcc'])

    for x in 'CFLAGS CXXFLAGS ASFLAGS LINKFLAGS'.split():
        # Floating point operations will invoke library functions
        # no hardware floating instructions will be enabled
        # see WAF-132 for details
        f(x, ['-march=armv7-r'])

        # software floating point
        f(x, ['-mfloat-abi=soft'])
def gcc_netx_flags(conf):
    conf.gcc_flags()

    f = conf.env.append_value

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x + '_compile_debug',    ['-O0', '-g', '-gdwarf-2'])
        f(x + '_compile_debugrel', ['-Os', '-g', '-gdwarf-2'])
        f(x + '_compile_release',  ['-Os'])

    f('ASFLAGS_compile_debug',    ['-Wa,-gdwarf2'])
    f('ASFLAGS_compile_debugrel', ['-Wa,-gdwarf2'])

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x,[ '-mlong-calls',
              '-mapcs',
              '-mthumb-interwork',
              '-fshort-enums',
              '-fno-common'])

    f('ASFLAGS',[ '-mapcs',
                  '-mthumb-interwork',
                  '-fshort-enums',
                  '-c'])

    f('LINKFLAGS', [ '-mthumb-interwork', '-nostdlib'])

    f('DEFINES', ['_NETX_'])
    f('STLIB_nxo_standardlibs', ['m', 'gcc'])
    f('STLIB_default_standardlibs',   ['m', 'c', 'gcc'])
def configure_device_linux(conf):
    conf.gcc_flags()

    f = conf.env.append_value

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x + '_compile_debug',    ['-O0', '-g'])
        f(x + '_compile_debugrel', ['-O3', '-g'])
        f(x + '_compile_release', ['-O3'])

    f('STLIB',   ['m', 'c', 'gcc'])
    f('TOOL_OPTIONS', ["linkerscript_optional"])
def configure_device_native(conf):
    conf.gcc_flags()

    f = conf.env.append_value

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x + '_compile_debug',    ['-O0', '-g',])
        f(x + '_compile_debugrel', ['-O3', '-g',])
        f(x + '_compile_release',  ['-O3'])

    f('ASFLAGS_compile_debug',    ['-Wa,-g'])
    f('ASFLAGS_compile_debugrel', ['-Wa,-g'])
    f('TOOL_OPTIONS', ["linkerscript_optional"])
def configure_device_netx90(conf):
    conf.gcc_flags()

    # Cortex-M4 onyl implements Thumb-2 instruction encoding but
    # no ARM instruction enconding
    conf.env['CFLAGS_compile_arm']      = []
    conf.env['CXXFLAGS_compile_arm']    = []
    conf.env['LINKFLAGS_compile_arm']   = []
    conf.env['CFLAGS_compile_thumb']    = []
    conf.env['CXXFLAGS_compile_thumb']  = []
    conf.env['LINKFLAGS_compile_thumb'] = []

    f = conf.env.append_value

    f('ASFLAGS_compile_debug',    ['-Wa,-gdwarf2'])
    f('ASFLAGS_compile_debugrel', ['-Wa,-gdwarf2'])

    for x in 'CFLAGS CXXFLAGS'.split():
        f(x,[ '-mlong-calls',
              '-mapcs',
              '-fno-common',
              '-mthumb'])

        f(x + '_compile_debug',    ['-O0', '-g', '-gdwarf-2'])
        f(x + '_compile_debugrel', ['-Os', '-g', '-gdwarf-2'])
        f(x + '_compile_release',  ['-Os'])

    f('ASFLAGS',[ '-mapcs',
                  '-c',
                  '-mthumb'])

    # -mthumb is needed for linking to select correct libraries
    # see gcc -print-multi-lib output
    f('LINKFLAGS', [ '-nostdlib', '-mthumb'])

    f('DEFINES', ['_NETX_'])
    f('STLIB_nxo_standardlibs',       ['gcc'])
    f('STLIB_default_standardlibs',   ['gcc'])

    for x in 'CFLAGS CXXFLAGS ASFLAGS LINKFLAGS'.split():
        # Floating point operations will invoke library functions
        # no hardware floating instructions will be enabled
        # see WAF-132 for details
        f(x, ['-march=armv7e-m'])

        # software floating point
        f(x, ['-mfloat-abi=soft'])