#######################################################################
# SConscript for egl state_tracker

Import('*')

env = env.Clone()

env.Append(CPPPATH = [
    '#/src/egl/main',
    '#/src/gallium/winsys',
    '#/src/gallium/winsys/sw',
    '.',
])

sources = env.ParseSourceList('Makefile.sources', 'common_FILES')

# OpenGL ES and OpenGL
if env['gles']:
    env.Append(CPPDEFINES = [
        'FEATURE_GL=1',
        'FEATURE_ES1=1',
        'FEATURE_ES2=1'
    ])

# OpenVG
if True:
    env.Append(CPPDEFINES = ['FEATURE_VG=1'])

if env['platform'] == 'windows':
    env.Append(CPPDEFINES = ['HAVE_GDI_BACKEND'])
    sources.append(env.ParseSourceList('Makefile.sources', 'gdi_FILES'))
else:
    if env['drm']:
        env.PkgUseModules('DRM')
    if env['x11']:
        env.Append(CPPDEFINES = ['HAVE_X11_BACKEND'])
        env.Prepend(CPPPATH = [
            '#/src/glx',
            '#/src/mapi',
        ])
        sources.append(env.ParseSourceList('Makefile.sources', 'x11_FILES'))
        if env['drm']:
            env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING'])
            sources.append(env.ParseSourceList('Makefile.sources', 'x11_drm_FILES'))
    if env['drm'] and False:
        # XXX: Disabled as it depends on gbm, which is not yet built with scons
        env.Append(CPPDEFINES = ['HAVE_DRM_BACKEND'])
        env.Append(CPPPATH = [
            '#/src/loader',
            '#/src/gbm/main',
            '#/src/gallium/state_trackers/gbm',
        ])
        env.Prepend(LIBS = [
            libloader
        ])
        sources.append(env.ParseSourceList('Makefile.sources', 'drm_FILES'))

st_egl = env.ConvenienceLibrary(
    target = 'st_egl',
    source = sources,
)
Export('st_egl')
