############################################################################
# Copyright 2016 Intel Corporation
#
# 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.
############################################################################
Import('*')

env.PartVersion("1.1.1")
env.PartName("dropt")

# sourcefiles
src_files = Pattern(src_dir='src/',
                    includes=['*.c'],
                    excludes=['test_*'],
                    recursive=True).files()

#includes to install
install_headers = Pattern(src_dir='include/',
                          includes=['dropt.h'],
                          recursive=True).files()

internal_headers = Pattern(src_dir='include/',
                           includes=['dropt_string.h'],
                           recursive=True).files()

parts_file = ['dropt.parts']
license_file = ['LICENSE']
makefile = ['Makefile']

if 'install_package' in env['MODE']:
    env.InstallTopLevel(src_files, sub_dir='ext/dropt/src')
    env.InstallTopLevel(install_headers + internal_headers,
                        sub_dir='ext/dropt/include')
    env.InstallTopLevel(parts_file, sub_dir='ext/dropt')
    env.InstallTopLevel(license_file, sub_dir='ext/dropt')
    env.InstallTopLevel(makefile, sub_dir='ext/dropt')
else:
    env.Append(CPPPATH=[AbsDir('include')])

    outputs = env.Library('${PART_NAME}', src_files)
    sdk_outs = env.Sdk(outputs)

    env.SdkInclude(install_headers)
