# Copyright (C) 2002, 2011 by Red Hat, Incorporated. All rights reserved.
#
# Permission to use, copy, modify, and distribute this software
# is freely granted, provided that this notice is preserved.
#

# flags.exp: overrides the dejagnu versions of newlib_link_flags
# and newlib_include_flags.

# These versions of the procedures generate link and include flags
# by searching for the needed files in the current build and source
# directories, rather than in the build and source paths of the
# compiler being used.

proc newlib_link_flags { args } {
    global tool_root_dir
    global srcdir objdir

    verbose "In newlib version of newlib_link_flags...\n"

    if [is_remote host] {
	return ""
    }

    set ld_script_path [lookfor_file ${tool_root_dir} "ld/ldscripts"];
    if { $ld_script_path != "" } {
	set result "-L[file dirname $ld_script_path]"
    } else {
	set result ""
    }

    return "$result -B$objdir -L$objdir"
}

proc newlib_include_flags { args } {
    global srcdir objdir

    verbose "In newlib version of newlib_include_flags...\n"

    if [is_remote host] {
	return ""
    }

    set newlib_dir [lookfor_file ${srcdir} newlib/libc/include/assert.h]
    if { ${newlib_dir} != "" } {
        set newlib_dir [file dirname ${newlib_dir}]
    }
    return " -I$objdir/targ-include -I$objdir -I${newlib_dir}"
}