# -----------------------------------------------------------------------------------------
#
#   jamrules.win.inc
#
#   Bob Cook Development, Robotics Library
#   http://www.bobcookdev.com/rl/
#    
#   Implements the jamrules actions for the Win32 platform.
#
#   Copyright (C) 2007 Bob Cook
#
#       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., 
#       51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
#
# -----------------------------------------------------------------------------------------


if $(TRACE) { echo "trace /jamrules.win.inc" ; }


WINAVR_INSTALL_DIR = "C:\\WinAVR-20090313" ;


# -----------------------------------------------------------------------------------------

actions avr_as
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(2)
    avr-gcc -mmcu=$(AVR_DEVICE) -c -o $(1) -I$(AVR_INCDIR) $(2)
}


# -----------------------------------------------------------------------------------------

actions avr_cc
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(2)
    avr-gcc -mmcu=$(AVR_DEVICE) -Wall -Os -mcall-prologues -c -o $(1) -I$(AVR_INCDIR) $(2)
}


# -----------------------------------------------------------------------------------------

actions avr_c++
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(2)
    avr-gcc -mmcu=$(AVR_DEVICE) -Wall -Os -mcall-prologues -c -o $(1) -I$(AVR_INCDIR) $(2)
}


# -----------------------------------------------------------------------------------------

actions avr_link
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(1)
    avr-gcc -g -Wall $(AVR_OPTIM) -mmcu=$(AVR_DEVICE) -o $(1) -L$(AVR_LIBDIR) -l$(AVR_LIBS) $(AVR_EXTRA_LIBS) -Wl,-Map,$(AVR_LINKMAP) $(2)
}


# -----------------------------------------------------------------------------------------

actions avr_list_from_executable
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(1)
    avr-objdump -h -S $(2) > $(1)
}


# -----------------------------------------------------------------------------------------

actions avr_texthex_from_executable
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(1)
    avr-objcopy -j .text -j .data -O ihex $(2) $(1)
}


# -----------------------------------------------------------------------------------------

actions avr_eepromhex_from_executable
{
    set PATH=$(WINAVR_INSTALL_DIR)\BIN;$(WINAVR_INSTALL_DIR)\UTILS\BIN
    set AVR_DEV_ENV=$(WINAVR_INSTALL_DIR)
    set INCLUDE=
    set LIB=
    echo $(1)
    avr-objcopy -j .eeprom --change-section-lma .eeprom=0 -O ihex $(2) $(1)
}


