#   Copyright (c) 2009 Axel Wachtler
#   All rights reserved.
#
#   Redistribution and use in source and binary forms, with or without
#   modification, are permitted provided that the following conditions
#   are met:
#
#   * Redistributions of source code must retain the above copyright
#     notice, this list of conditions and the following disclaimer.
#   * Redistributions in binary form must reproduce the above copyright
#     notice, this list of conditions and the following disclaimer in the
#     documentation and/or other materials provided with the distribution.
#   * Neither the name of the authors nor the names of its contributors
#     may be used to endorse or promote products derived from this software
#     without specific prior written permission.
#
#   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
#   AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
#   IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
#   ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
#   LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
#   CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
#   SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
#   INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
#   CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
#   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
#   POSSIBILITY OF SUCH DAMAGE.

# $Id: SConscript,v 1.7 2010/01/20 20:11:13 awachtler Exp $

#=== modules ==================================================================
import pprint, glob, os
Import("contr board")

#=== setup build environment ==================================================
avrlocal = contr.Clone()
avrlocal["dir_arduino"] = "${dir_install.abspath}/arduino-0017-uracoli"
#=== targets ==================================================================
for src in glob.glob("examples/Radio/*/*.pde"):
    dstdir = "${dir_arduino}/%s" % os.path.split(src)[0]
    avrlocal.Install(dstdir, src)
    avrlocal.Install(dstdir, "zigbit/Makefile")

avrlocal.Install("${dir_arduino}/hardware",
                 "boards.txt")

avrlocal.Install("${dir_arduino}",
                 ["README.zigbit", "arduino-0017-zigbit.patch"])


common_corefiles = [ # arduino core files
                   "zigbit/Makefile",
                   "zigbit/binary.h",
                   "zigbit/HardwareRadio.h",
                   "zigbit/HardwareSerial.cpp",
                   "zigbit/HardwareSerial.h",
                   "zigbit/main.cxx",
                   "zigbit/Print.cpp",
                   "zigbit/Print.h",
                   "zigbit/WConstants.h",
                   "zigbit/WInterrupts.c",
                   "zigbit/wiring_analog.c",
                   "zigbit/wiring.c",
                   "zigbit/wiring_digital.c",
                   "zigbit/wiring.h",
                   "zigbit/wiring_private.h",
                   "zigbit/wiring_pulse.c",
                   "zigbit/wiring_shift.c",
                   "zigbit/WMath.cpp",
                   "zigbit/WProgram.h", 
                   "zigbit/PureVirtual.cpp", 
                   # uracoli headers and libs
                   "${dir_install}/inc/radio.h",
                   "${dir_install}/inc/const.h",
                   ]

                 
core = avrlocal.Install("${dir_arduino}/hardware/cores/uracoli",
                        common_corefiles + [
                          "zigbit/pins_zigbit.c",
                          "zigbit/pins_zigbit.h",
                          "${dir_install}/lib/libradio_wdba1281.a"
                        ])

#core1 = avrlocal.Install("${dir_arduino}/hardware/cores/derfa1",
#                        common_corefiles + [
#                          "zigbit/pins_derfa1.c",
#                          "zigbit/pins_derfa1.h",
#                          "${dir_install}/lib/libradio_derfa1.a"
#                        ])

libs = avrlocal.Install("${dir_arduino}/lib", "lib/pde-0017.jar")
avrlocal.Alias("arduino", "$dir_arduino")
avrlocal.Clean("arduino", "$dir_arduino")



