###################################
# SConcscript file for dri targets

Import('*')

drienv = env.Clone()

drienv.Replace(CPPPATH = [
    '#src/mesa/drivers/dri/common',
    xmlpool_options.dir.dir, # Dir to generated xmlpool/options.h
    '#include',
    '#include/GL/internal',
    '#src',
    '#src/mapi',
    '#src/gallium/include',
    '#src/gallium/auxiliary',
    '#src/gallium/drivers',
    '#src/gallium/winsys',
    '#src/mesa',
    '#src/mesa/main',
    '#src/mesa/glapi',
    '#src/mesa/math',
    '#src/mesa/transform',
    '#src/mesa/shader',
    '#src/mesa/swrast',
    '#src/mesa/swrast_setup',
    '#src/egl/main',
    '#src/egl/drivers/dri',
])

drienv.AppendUnique(LIBS = [
    'expat',
])

# if HAVE_DRI2
drienv.PkgUseModules('DRM')
# else
#env.Append(CPPDEFINES = ['__NOT_HAVE_DRM_H'])

sources = drienv.ParseSourceList('Makefile.sources', ['DRI_COMMON_FILES', 'XMLCONFIG_FILES' ])

dri_common = drienv.ConvenienceLibrary(
	target = 'dri_common',
	source = sources,
)

#
# megadrivers_stub
#
env = env.Clone()

env.Append(CPPPATH = [
    '#/include',
    '#/src/',
    '#/src/mapi',
    '#/src/mesa',
])

env.Append(CPPDEFINES = [
    '__NOT_HAVE_DRM_H',
    'HAVE_DLADDR',
])

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

megadrivers_stub = env.ConvenienceLibrary(
	target = 'megadrivers_stub',
	source = sources,
)

env.Alias('megadrivers_stub', megadrivers_stub)

Export([
    'drienv',
    'dri_common',
    'megadrivers_stub',
])
