# Copyright (C) 2000 Free Software Foundation, Inc.

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 

# Please email any bugs, comments, and/or additions to this file to:
# bug-dejagnu@prep.ai.mit.edu

# This file was written by Mark Salter. (msalter@redhat.com)


#
# Return link flags used to build eCos-based applications to
# run on target boards using RedBoot.
#
proc ecos_link_flags { args } {
    global board
    global board_info

    if [isnative] {
	return ""
    }

    if [is_remote host] {
	return ""
    }

    if [info exists board] {
	set target_board $board;
    } else {
	set target_board [target_info name];
    }

    set ecos_libdir ""
    if [board_info $target_board exists ecos_installdir] {
	set ecos_dir [board_info $target_board ecos_installdir];
	set ecos_libdir "-L${ecos_dir}/lib"
    }

    return "-Wl,--gc-sections -Wl,-static -nostdlib ${ecos_libdir}"
}


#
# Return any extra CFLAGs needed to compile an eCos based app.
#
proc ecos_extra_cflags { args } {
    global board
    global board_info

    if [isnative] {
	return ""
    }

    if [is_remote host] {
	return ""
    }

    if [info exists board] {
	set target_board $board;
    } else {
	set target_board [target_info name];
    }

    if [board_info $target_board exists extra_cflags] {
	return [board_info $target_board extra_cflags]
    }

    return ""
}


proc ecos_include_flags { args } {
    global board
    global board_info

    if [isnative] {
	return ""
    }

    if [is_remote host] {
	return ""
    }

    if [info exists board] {
	set target_board $board;
    } else {
	set target_board [target_info name];
    }

    if [board_info $target_board exists ecos_installdir] {
	set ecos_dir [board_info $target_board ecos_installdir];
	return " -I${ecos_dir}/include"
    }
    return ""
}

