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

Import('*')

env = env.Clone()

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

sources = [
    'common/egl_g3d.c',
    'common/egl_g3d_api.c',
    'common/egl_g3d_image.c',
    'common/egl_g3d_st.c',
    'common/egl_g3d_sync.c',
    'common/native_helper.c',
]

if env['platform'] == 'windows':
    env.Append(CPPDEFINES = ['HAVE_GDI_BACKEND'])
    sources.append('gdi/native_gdi.c')
else:
    if env['x11']:
        env.Append(CPPDEFINES = ['HAVE_X11_BACKEND'])
        env.Prepend(CPPPATH = [
            '#/src/glx',
            '#/src/mapi',
        ])
        sources.append([
            'x11/native_x11.c',
            'x11/native_dri2.c',
            'x11/native_ximage.c',
            'x11/x11_screen.c',
            'x11/glxinit.c'])
        if env['dri']:
            env.Append(CPPDEFINES = ['GLX_DIRECT_RENDERING'])
            sources.append(['#/src/glx/dri2.c'])
    if env['drm']:
        env.PkgUseModules('DRM')
        env.Append(CPPDEFINES = ['HAVE_DRM_BACKEND'])
        env.Append(CPPPATH = [
            '#/src/gbm/main',
            '#/src/gallium/state_trackers/gbm',
        ])
        sources.append(['drm/native_drm.c', 'drm/modeset.c'])

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