# Copyright AllSeen Alliance. All rights reserved.
#
#    Permission to use, copy, modify, and/or distribute this software for any
#    purpose with or without fee is hereby granted, provided that the above
#    copyright notice and this permission notice appear in all copies.
#
#    THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
#    WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
#    MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
#    ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
#    WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
#    ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
#    OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Import('env')

app_env = env.Clone()
app_env.Append(CPPPATH = ['#agent/inc'])
app_env.Append(CPPPATH = ['#agent/src'])
app_env.Append(CPPPATH = ['#storage/inc'])
app_env.Append(LIBPATH =  '$SEC_DISTDIR/lib')
app_env.Prepend(LIBS = ['ajsecmgr', 'ajsecstorage'])

if app_env['BR'] == 'on':
        # Build apps with bundled daemon support
        app_env.Prepend(LIBS = [app_env['ajrlib']])

# build app
test_app = app_env.Program(target='multipeer_claim',
                           source=[Glob('*.cc')])

# install run scripts
script_dict = {
                '%PREFIX%': Dir('.').abspath,
                '%LIBPATH%': app_env.CreateLibPath(),
                '%TESTAPP%': test_app[0].name
              }
script = app_env.Substfile('run.sh.in', SUBST_DICT=script_dict)
app_env.AddPostAction(script, Chmod(script[0].abspath, 0755))
