#******************************************************************
#
# Copyright 2015 Samsung Electronics All Rights Reserved.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

######################################################################
# Build script for Arduino Enrollee Sample App
######################################################################

Import('env')

enrollee_env = env.Clone()
transport = enrollee_env.get('TARGET_TRANSPORT')

######################################################################
# Build flags
######################################################################
enrollee_env.PrependUnique(CPPPATH = [
        env.get('SRC_DIR') + '/resource/oc_logger/include',
        env.get('SRC_DIR') + '/resource/csdk/logger/include',
        env.get('SRC_DIR') + '/resource/csdk/stack/include',
		env.get('SRC_DIR') + '/extlibs/cjson',
		env.get('SRC_DIR') + '/service/easy-setup/inc',
		env.get('SRC_DIR') + '/service/easy-setup/enrollee/arduino/wifi',
		env.get('SRC_DIR') + '/service/easy-setup/enrollee/inc',
		env.get('SRC_DIR') + '/service/easy-setup/enrollee/src'])

enrollee_env.AppendUnique(CPPDEFINES = ['TB_LOG', 'ESWIFI'])

enrollee_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])

enrollee_env.PrependUnique(LIBS = ['octbstack','ocsrm','connectivity_abstraction','coap', 'ESEnrolleeSDK'])
enrollee = enrollee_env.Program('enrollee', 'enrolleewifi.cpp')
env.CreateBin('enrollee')

i_enrollee = enrollee_env.Install(env.get('BUILD_DIR'), enrollee)

Alias('enrollee', i_enrollee)
env.AppendTarget('enrollee')

if(enrollee_env['UPLOAD'] == True):
	from sys import platform as _platform
	if _platform == "linux" or _platform == "linux2":
		enrollee_env.Upload(env.get('BUILD_DIR') + '/service/easy-setup/sampleapp/enrollee/arduino/enrollee.hex')
	else:
		print 'Please use appropriate install method for your developing machine. Linux is the only supported platform right now.'
