#######################################################################
# Copyright 2016 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 Linux Enrollee Sample App
######################################################################

Import('env')

print Dir('#').abspath
print Dir('.').abspath

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

######################################################################
# Build flags
######################################################################
enrollee_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
enrollee_env.AppendUnique(CXXFLAGS = ['-Wall', '-std=c++0x'])

if env.get('RELEASE'):
    enrollee_env.AppendUnique(CCFLAGS = ['-Os'])
    enrollee_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
else:
    enrollee_env.AppendUnique(CCFLAGS = ['-g'])

if env.get('LOGGING'):
    env.AppendUnique(CPPDEFINES = ['TB_LOG'])

enrollee_env.PrependUnique(CPPPATH = [
		env.get('SRC_DIR') + '/resource/include',
        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/linux/wifi',
        env.get('SRC_DIR') + '/service/easy-setup/enrollee/inc',
        env.get('SRC_DIR') + '/service/easy-setup/enrollee/src'])

enrollee_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'ocsrm', 'pthread', 'connectivity_abstraction','coap', 'ESEnrolleeSDK'])
if enrollee_env.get('SECURED') == '1':
	enrollee_env.PrependUnique(LIBS = ['ocpmapi', 'ocprovision'])

enrollee = enrollee_env.Program('enrollee', 'enrolleewifi.c')

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

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