#
# Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
#
# -*- mode: python; -*-

import re

Import('BuildEnv')
env = BuildEnv.Clone()

# Versions of gcc < 4.4 do not support 'pragma diagnostic'
if env['CC'] == 'gcc':
    version = env['CCVERSION'].split('.')
    gcc_major = int(version[0])
    gcc_minor = int(version[1])
    if gcc_major < 4 or (gcc_major == 4 and gcc_minor < 4):
        cflags = env['CCFLAGS']
        cflags.append('-Wno-unused-function')
# end

env['CCFLAGS'].append(env['CPPDEFPREFIX'] + 'RAPIDJSON_NAMESPACE=contrail_rapidjson')

def get_sources(targets):
    return [x for x in targets if re.match(r'(.*)\.cc$', x.abspath)]

targets = env.IFMapAutogen('vnc_cfg.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('ifmap_vnc', lib_srcs)

targets = env.IFMapAutogen('bgp_schema.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('bgp_schema', lib_srcs)

targets = env.TypeAutogen('xmpp_unicast.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('xmpp_unicast', lib_srcs)

targets = env.TypeAutogen('xmpp_multicast.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('xmpp_multicast', lib_srcs)

targets = env.TypeAutogen('xmpp_mvpn.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('xmpp_mvpn', lib_srcs)

targets = env.TypeAutogen('xmpp_enet.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('xmpp_enet', lib_srcs)

targets = env.TypeAutogen('services.xsd')
lib_srcs = get_sources(targets)
lib = env.Library('services', lib_srcs)

env.SConscript('test/SConscript', exports='BuildEnv', duplicate = 0)
