[Mesa-dev] [PATCH v2 06/12] meson: Build i965 and dri stack

Dylan Baker dylan at pnwbakers.com
Thu Oct 5 17:12:24 UTC 2017


This gets pretty much the entire classic tree building, as well as
i965, including the various glapis. There are some workarounds for bugs
that are fixed in meson 0.43.0, which is due out on October 8th.

I have tested this with piglit using glx.

v2: - fix typo "vaule" -> "value"
    - use gtest dep instead of linking to libgtest (rebase error)
    - use gtest dep instead of linking against libgtest (rebase error)
    - copy the megadriver, then create hard links from that, then delete
      the megadriver. This matches the behavior of the autotools build.
      (Eric A)
    - Use host_machine instead of target_machine (Eric A)
    - Put a comment in the right place (Eric A)
    - Don't have two variables for the same information (Eric A)
    - Put pre_args at top of file in this patch (Eric A)
    - Fix glx generators in this patch instead of next (Eric A)
    - Remove -DMESON hack (Eric A)
    - add sha1_h to mesa in this patch (Eric A)
    - Put generators in loops when possible to reduce code in
      mapi/glapi/gen (Eric A)

Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
 src/meson.build => bin/install_megadrivers.py      |  63 ++-
 include/meson.build                                |  38 ++
 meson.build                                        | 111 +++-
 meson_options.txt                                  |  12 +
 src/compiler/{ => glsl/glcpp}/meson.build          |  57 +-
 src/compiler/glsl/meson.build                      | 229 +++++++-
 src/compiler/glsl/tests/meson.build                |  76 +++
 src/compiler/meson.build                           |  12 +-
 src/git_sha1.h.in                                  |   1 +
 src/{compiler/glsl => mapi/es1api}/meson.build     |  39 +-
 src/{compiler/glsl => mapi/es2api}/meson.build     |  38 +-
 src/mapi/glapi/gen/meson.build                     | 249 +++++++++
 src/mapi/glapi/meson.build                         |  82 +++
 {include => src/mapi}/meson.build                  |  19 +-
 src/mapi/shared-glapi/meson.build                  |  61 +++
 .../glsl => mesa/drivers/dri/common}/meson.build   |  24 +-
 src/mesa/drivers/dri/i965/meson.build              | 178 +++++++
 src/{ => mesa/drivers/dri}/meson.build             |  63 ++-
 src/{compiler/glsl => mesa/main}/meson.build       |  29 +-
 src/mesa/meson.build                               | 582 +++++++++++++++++++++
 src/{compiler/glsl => mesa/program}/meson.build    |  18 +-
 src/meson.build                                    |  26 +-
 src/util/meson.build                               |   3 +-
 src/{compiler/glsl => util/xmlpool}/meson.build    |  13 +-
 24 files changed, 1869 insertions(+), 154 deletions(-)
 copy src/meson.build => bin/install_megadrivers.py (54%)
 mode change 100644 => 100755
 copy src/compiler/{ => glsl/glcpp}/meson.build (58%)
 create mode 100644 src/compiler/glsl/tests/meson.build
 create mode 100644 src/git_sha1.h.in
 copy src/{compiler/glsl => mapi/es1api}/meson.build (53%)
 copy src/{compiler/glsl => mapi/es2api}/meson.build (54%)
 create mode 100644 src/mapi/glapi/meson.build
 copy {include => src/mapi}/meson.build (81%)
 create mode 100644 src/mapi/shared-glapi/meson.build
 copy src/{compiler/glsl => mesa/drivers/dri/common}/meson.build (69%)
 create mode 100644 src/mesa/drivers/dri/i965/meson.build
 copy src/{ => mesa/drivers/dri}/meson.build (53%)
 copy src/{compiler/glsl => mesa/main}/meson.build (55%)
 create mode 100644 src/mesa/meson.build
 copy src/{compiler/glsl => mesa/program}/meson.build (74%)
 copy src/{compiler/glsl => util/xmlpool}/meson.build (80%)

diff --git a/src/meson.build b/bin/install_megadrivers.py
old mode 100644
new mode 100755
similarity index 54%
copy from src/meson.build
copy to bin/install_megadrivers.py
index 76ff497e565..a5a46201ccb
--- a/src/meson.build
+++ b/bin/install_megadrivers.py
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+# encoding=utf-8
 # Copyright © 2017 Intel Corporation
 
 # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -18,31 +20,36 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: libglsl_util
-
-# TODO: git_sha. There's a meson builtin for this
-
-inc_common = include_directories(
-  '../include', '.', 'mapi', 'mesa', 'gallium/include', 'gallium/auxiliary')
-inc_mesa = include_directories('mesa')
-inc_mapi = include_directories('mapi')
-
-subdir('gtest')
-subdir('util')
-#subdir('mapi/glapi/gen')
-# TODO: mapi
-# TODO: opengl
-# TODO: glx
-# TODO: osmesa
-subdir('compiler')
-subdir('egl/wayland/wayland-drm')
-subdir('vulkan')
-subdir('amd')
-subdir('intel')
-# TODO: vc4
-# TODO: opengl_common
-# TODO: dri_glx
-# TODO: gbm
-# TODO: egl
-# TODO: radv
-# TODO: gallium
+"""Script to install megadriver symlinks for meson."""
+
+from __future__ import print_function
+import argparse
+import os
+import shutil
+
+
+def main():
+    parser = argparse.ArgumentParser()
+    parser.add_argument('megadriver')
+    parser.add_argument('libdir')
+    parser.add_argument('drivers', nargs='+')
+    args = parser.parse_args()
+
+    to = os.path.join(os.environ.get('MESON_INSTALL_DESTDIR_PREFIX'), args.libdir)
+    master = os.path.join(to, os.path.basename(args.megadriver))
+
+    if not os.path.exists(to):
+        os.makedirs(to)
+    shutil.copy(args.megadriver, master)
+
+    for each in args.drivers:
+        driver = os.path.join(to, each)
+        if os.path.exists(driver):
+            os.unlink(driver)
+        print('installing {} to {}'.format(args.megadriver, to))
+        os.link(master, driver)
+    os.unlink(master)
+
+
+if __name__ == '__main__':
+    main()
diff --git a/include/meson.build b/include/meson.build
index 93def7e0ec2..beb57e3e044 100644
--- a/include/meson.build
+++ b/include/meson.build
@@ -20,3 +20,41 @@
 
 inc_drm_uapi = include_directories('drm-uapi')
 inc_vulkan = include_directories('vulkan')
+
+if with_gles1
+  install_headers(
+    'GLES/egl.h', 'GLES/gl.h', 'GLES/glext.h', 'GLES/glplatform.h',
+    subdir : 'GLES',
+  )
+endif
+
+if with_gles2
+  install_headers(
+    'GLES2/gl2.h', 'GLES2/gl2ext.h', 'GLES2/gl2platform.h',
+    subdir : 'GLES2',
+  )
+  install_headers(
+    'GLES3/gl3.h', 'GLES3/gl32.h', 'GLES3/gl32.h', 'GLES3/gl3ext.h',
+    'GLES3/gl3platform.h',
+    subdir : 'GLES3',
+  )
+endif
+
+if with_gles1 or with_gles2 # or with_egl
+  install_headers('KHR/khrplatform.h', subdir : 'KHR')
+endif
+
+if with_opengl
+  install_headers(
+    'GL/gl.h', 'GL/glext.h', 'GL/glcorearb.h', 'GL/gl_mangle.h',
+    subdir : 'GL',
+  )
+endif
+
+if with_glx
+  install_headers('GL/glx.h', 'GL/glext.h', 'GL/glx_mangle.h', subdir : 'GL')
+endif
+
+if with_osmesa
+  install_headers('GL/osmesa.h', subdir : 'GL')
+endif
diff --git a/meson.build b/meson.build
index 97809e98289..be6094e1d53 100644
--- a/meson.build
+++ b/meson.build
@@ -21,10 +21,68 @@
 project('mesa', ['c', 'cpp'], version : '17.3.0-devel', license : 'MIT',
         default_options : ['c_std=c99', 'cpp_std=c++11'])
 
+# Arguments for the preprocessor, put these in a separate array from the C and
+# C++ (cpp in meson terminology) arguments since they need to be added to the
+# default arguments for both C and C++.
+pre_args = [
+  '-D__STDC_CONSTANT_MACROS',
+  '-D__STDC_FORMAT_MACROS',
+  '-D__STDC_LIMIT_MACROS',
+  '-DVERSION="@0@"'.format(meson.project_version()),
+  '-DPACKAGE_VERSION=VERSION',
+  '-DPACKAGE_BUGREPORT="https://bugs.freedesktop.org/enter_bug.cgi?product=Mesa"',
+]
+
 with_dri3 = true  # XXX: need a switch for this
 with_vulkan_icd_dir = get_option('vulkan-icd-dir')
 with_tests = get_option('build-tests')
 with_valgrind = get_option('valgrind')
+with_asm = get_option('asm')
+
+# XXX: yeah, do these
+with_appledri = false
+with_windowsdri = false
+
+with_gles1 = get_option('gles1')
+with_gles2 = get_option('gles2')
+with_opengl = get_option('opengl')
+with_any_opengl = with_opengl or with_gles1 or with_gles2
+with_shared_glapi = get_option('shared-glapi')
+
+# TODO: these will need options, but at the moment they just control header
+# installs
+with_glx = false
+with_osmesa = false
+
+# shared-glapi is required if at least two OpenGL APIs are being built
+if not with_shared_glapi
+  if ((with_gles1 and with_gles2) or (with_gles1 and with_opengl)
+      or (with_gles2 and with_opengl))
+    error('shared-glapi required for building two or more of OpenGL, OpenGL ES 1.x, OpenGL ES 2.x')
+  endif
+endif
+
+# We require OpenGL for OpenGL ES
+if (with_gles1 or with_gles2) and not with_opengl
+  error('building OpenGL ES without OpenGL is not supported.')
+endif
+
+with_dri = false
+with_dri_i965 = false
+_drivers = get_option('dri-drivers')
+if _drivers != ''
+  _split = _drivers.split(',')
+  with_dri_i965 = _split.contains('i965')
+  with_dri = true
+endif
+
+if not with_dri
+  with_gles1 = false
+  with_gles2 = false
+  with_opengl = false
+  with_any_opengl = false
+  with_shared_glapi = false
+endif
 
 # TODO: there are more platforms required for non-vulkan drivers
 with_platform_wayland = false
@@ -63,13 +121,6 @@ if cc.get_id() == 'gcc' and cc.version().version_compare('< 4.4.6')
   error('When using GCC, version 4.4.6 or later is required.')
 endif
 
-# Arguments for the preprocessor, put these in a separate array from the C and
-# C++ (cpp in meson terminology) arguments since they need to be added to the
-# default arguments for both C and C++.
-pre_args = ['-D__STDC_CONSTANT_MACROS', '-D__STDC_FORMAT_MACROS',
-            '-D__STDC_LIMIT_MACROS',
-            '-DVERSION="@0@"'.format(meson.project_version())]
-
 # Define DEBUG for debug and debugoptimized builds
 if get_option('buildtype').startswith('debug')
   pre_args += '-DDEBUG'
@@ -204,7 +255,39 @@ endif
 
 # TODO: cross-compiling. I don't think this is relavent to meson
 
-# TODO: assembly support. mesa and vc4
+# FIXME: enable asm when cross compiler
+# This is doable (autotools does it), but it's not of immediate concern
+if meson.is_cross_build()
+  message('Cross compiling, disabling asm')
+  with_asm = false
+endif
+
+with_asm_arch = ''
+if with_asm
+  # TODO: SPARC and PPC
+  if host_machine.cpu_family() == 'x86'
+    if ['linux', 'bsd'].contains(host_machine.system()) # FIXME: hurd?
+      with_asm_arch = 'x86'
+      pre_args += ['-DUSE_X86_ASM', '-DUSE_MMX_ASM', '-DUSE_3DNOW_ASM',
+                   '-DUSE_SSE_ASM']
+    endif
+  elif host_machine.cpu_family() == 'x86_64'
+    if host_machine.system() == 'linux'
+      with_asm_arch = 'x86_64'
+      pre_args += ['-DUSE_X86_64_ASM']
+    endif
+  elif host_machine.cpu_family() == 'arm'
+    if host_machine.system() == 'linux'
+      with_asm_arch = 'arm'
+      pre_args += ['-DUSE_ARM_ASM']
+    endif
+  elif host_machine.cpu_family() == 'aarch64'
+    if host_machine.system() == 'linux'
+      with_asm_arch = 'aarch64'
+      pre_args += ['-DUSE_AARCH64_ASM']
+    endif
+  endif
+endif
 
 # Check for standard headers and functions
 if cc.has_header_symbol('sys/sysmacros.h', 'major')
@@ -264,9 +347,9 @@ if cc.has_function('dlopen')
 else
   dep_dl = cc.find_library('dl')
 endif
-
-if not cc.has_function('dladdr', dependencies : dep_dl)
-  error('dl library doesn\'t have dladdr')
+if cc.has_function('dladdr', dependencies : dep_dl)
+  # This is really only required for megadrivers
+  pre_args += '-DHAVE_DLADDR'
 endif
 
 if cc.has_function('dl_iterate_phdr')
@@ -336,7 +419,11 @@ endif
 
 # pthread stubs. Lets not and say we didn't
 
+prog_bison = find_program('bison', required : with_any_opengl)
+prog_flex = find_program('flex', required : with_any_opengl)
+
 # TODO: selinux
+dep_selinux = []
 
 # TODO: llvm-prefix and llvm-shared-libs
 
@@ -453,5 +540,7 @@ endforeach
 
 inc_include = include_directories('include')
 
+pkg = import('pkgconfig')
+
 subdir('include')
 subdir('src')
diff --git a/meson_options.txt b/meson_options.txt
index 6ca19db3497..f352f384c14 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -20,12 +20,24 @@
 
 option('platforms', type : 'string', value : 'x11,wayland',
        description : 'comma separated list of window systems to support. wayland, x11, surfaceless, drm, etc.')
+option('dri-drivers', type : 'string', value : 'i965',
+       description : 'comma separated list of dri drivers to build.')
 option('vulkan-drivers', type : 'string', value : 'intel,amd',
        description : 'comma separated list of vulkan drivers to build.')
 option('shader-cache', type : 'boolean', value : true,
        description : 'Build with on-disk shader cache support')
 option('vulkan-icd-dir', type : 'string', value : '',
        description : 'Location relative to prefix to put vulkan icds on install. Default: $datadir/vulkan/icd.d')
+option('shared-glapi', type : 'boolean', value : true,
+       description : 'Whether to build a shared or static glapi')
+option('gles1', type : 'boolean', value : true,
+       description : 'Build support for OpenGL ES 1.x')
+option('gles2', type : 'boolean', value : true,
+       description : 'Build support for OpenGL ES 2.x and 3.x')
+option('opengl', type : 'boolean', value : true,
+       description : 'Build support for OpenGL (all versions)')
+option('asm', type : 'boolean', value : true,
+       description : 'Build assembly code if possible')
 option('valgrind', type : 'boolean', value : true,
        description : 'Build with valgrind support if possible')
 option('build-tests', type : 'boolean', value : false,
diff --git a/src/compiler/meson.build b/src/compiler/glsl/glcpp/meson.build
similarity index 58%
copy from src/compiler/meson.build
copy to src/compiler/glsl/glcpp/meson.build
index 9a40e2e3a1a..17ee1a242cd 100644
--- a/src/compiler/meson.build
+++ b/src/compiler/glsl/glcpp/meson.build
@@ -18,40 +18,39 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-inc_compiler = include_directories('.')
-inc_nir = include_directories('nir')
-inc_glsl = include_directories('glsl')
-
-subdir('glsl')
-
-files_libcompiler = files(
-  'builtin_type_macros.h',
-  'glsl_types.cpp',
-  'glsl_types.h',
-  'nir_types.cpp',
-  'nir_types.h',
-  'shader_enums.c',
-  'shader_enums.h',
-  'shader_info.h',
+glcpp_parse = custom_target(
+  'glcpp-parse.[ch]',
+  input : 'glcpp-parse.y',
+  output : ['glcpp-parse.c', 'glcpp-parse.h'],
+  command : [prog_bison, '-o', '@OUTPUT0@', '-p', 'glcpp_parser_',
+             '--defines=@OUTPUT1@', '@INPUT@'],
 )
 
-libcompiler = static_library(
-  'compiler',
-  [files_libcompiler, ir_expression_operation_h],
-  include_directories : [inc_mapi, inc_mesa, inc_compiler, inc_common],
-  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+glcpp_lex = custom_target(
+  'glcpp-lex.c',
+  input : 'glcpp-lex.l',
+  output : 'glcpp-lex.c',
+  command : [prog_flex, '-o', '@OUTPUT@', '@INPUT@'],
+)
+
+libglcpp = static_library(
+  'glcpp',
+  [glcpp_lex, glcpp_parse, files('glcpp.h', 'pp.c')],
+  link_with : libmesa_util,
+  include_directories : [inc_common],
+  c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args],
   cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
   build_by_default : false,
 )
 
-subdir('nir')
-
-spirv2nir = executable(
-  'spirv2nir',
-  [files('spirv/spirv2nir.c'), dummy_cpp],
-  dependencies : [dep_m, dep_thread],
-  include_directories : [inc_common, inc_nir, include_directories('spirv')],
-  link_with : [libnir, libmesa_util],
-  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+glcpp = executable(
+  'glcpp',
+  'glcpp.c',
+  dependencies : [dep_m],
+  include_directories : [inc_common],
+  link_with : [libglcpp, libglsl_util],
+  c_args : [c_vis_args, no_override_init_args, c_msvc_compat_args],
   build_by_default : false,
 )
+
+# TODO: figure out how to make all of these tests work.
diff --git a/src/compiler/glsl/meson.build b/src/compiler/glsl/meson.build
index 0a2537d4981..f712d524a40 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/compiler/glsl/meson.build
@@ -18,12 +18,231 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
+subdir('glcpp')
 
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
+glsl_parser = custom_target(
+  'glsl_parser',
+  input : 'glsl_parser.yy',
+  output : ['glsl_parser.cpp', 'glsl_parser.h'],
+  command : [prog_bison, '-o', '@OUTPUT0@', '-p', '_mesa_glsl_',
+             '--defines=@OUTPUT1@', '@INPUT@'],
+)
+
+glsl_lexer_cpp = custom_target(
+  'glsl_lexer_cpp',
+  input : 'glsl_lexer.ll',
+  output : 'glsl_lexer.cpp',
+  command : [prog_flex, '-o', '@OUTPUT@', '@INPUT@'],
+)
+
+ir_expression_operation_constant_h = custom_target(
+  'ir_expression_operation_constant.h',
   input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
+  output : 'ir_expression_operation_constant.h',
+  command : [prog_python2, '@INPUT@', 'constant'],
   capture : true,
 )
+
+ir_expression_operation_strings_h = custom_target(
+  'ir_expression_operation_strings.h',
+  input : 'ir_expression_operation.py',
+  output : 'ir_expression_operation_strings.h',
+  command : [prog_python2, '@INPUT@', 'strings'],
+  capture : true,
+)
+
+files_libglsl = files(
+  'ast.h',
+  'ast_array_index.cpp',
+  'ast_expr.cpp',
+  'ast_function.cpp',
+  'ast_to_hir.cpp',
+  'ast_type.cpp',
+  'blob.c',
+  'blob.h',
+  'builtin_functions.cpp',
+  'builtin_functions.h',
+  'builtin_int64.h',
+  'builtin_types.cpp',
+  'builtin_variables.cpp',
+  'generate_ir.cpp',
+  'glsl_parser_extras.cpp',
+  'glsl_parser_extras.h',
+  'glsl_symbol_table.cpp',
+  'glsl_symbol_table.h',
+  'glsl_to_nir.cpp',
+  'glsl_to_nir.h',
+  'hir_field_selection.cpp',
+  'ir_array_refcount.cpp',
+  'ir_array_refcount.h',
+  'ir_basic_block.cpp',
+  'ir_basic_block.h',
+  'ir_builder.cpp',
+  'ir_builder.h',
+  'ir_clone.cpp',
+  'ir_constant_expression.cpp',
+  'ir.cpp',
+  'ir.h',
+  'ir_equals.cpp',
+  'ir_expression_flattening.cpp',
+  'ir_expression_flattening.h',
+  'ir_function_can_inline.cpp',
+  'ir_function_detect_recursion.cpp',
+  'ir_function_inlining.h',
+  'ir_function.cpp',
+  'ir_hierarchical_visitor.cpp',
+  'ir_hierarchical_visitor.h',
+  'ir_hv_accept.cpp',
+  'ir_optimization.h',
+  'ir_print_visitor.cpp',
+  'ir_print_visitor.h',
+  'ir_reader.cpp',
+  'ir_reader.h',
+  'ir_rvalue_visitor.cpp',
+  'ir_rvalue_visitor.h',
+  'ir_set_program_inouts.cpp',
+  'ir_uniform.h',
+  'ir_validate.cpp',
+  'ir_variable_refcount.cpp',
+  'ir_variable_refcount.h',
+  'ir_visitor.h',
+  'linker.cpp',
+  'linker.h',
+  'link_atomics.cpp',
+  'link_functions.cpp',
+  'link_interface_blocks.cpp',
+  'link_uniforms.cpp',
+  'link_uniform_initializers.cpp',
+  'link_uniform_block_active_visitor.cpp',
+  'link_uniform_block_active_visitor.h',
+  'link_uniform_blocks.cpp',
+  'link_varyings.cpp',
+  'link_varyings.h',
+  'list.h',
+  'loop_analysis.cpp',
+  'loop_analysis.h',
+  'loop_unroll.cpp',
+  'lower_blend_equation_advanced.cpp',
+  'lower_buffer_access.cpp',
+  'lower_buffer_access.h',
+  'lower_const_arrays_to_uniforms.cpp',
+  'lower_discard.cpp',
+  'lower_discard_flow.cpp',
+  'lower_distance.cpp',
+  'lower_if_to_cond_assign.cpp',
+  'lower_instructions.cpp',
+  'lower_int64.cpp',
+  'lower_jumps.cpp',
+  'lower_mat_op_to_vec.cpp',
+  'lower_noise.cpp',
+  'lower_offset_array.cpp',
+  'lower_packed_varyings.cpp',
+  'lower_named_interface_blocks.cpp',
+  'lower_packing_builtins.cpp',
+  'lower_subroutine.cpp',
+  'lower_tess_level.cpp',
+  'lower_texture_projection.cpp',
+  'lower_variable_index_to_cond_assign.cpp',
+  'lower_vec_index_to_cond_assign.cpp',
+  'lower_vec_index_to_swizzle.cpp',
+  'lower_vector.cpp',
+  'lower_vector_derefs.cpp',
+  'lower_vector_insert.cpp',
+  'lower_vertex_id.cpp',
+  'lower_output_reads.cpp',
+  'lower_shared_reference.cpp',
+  'lower_ubo_reference.cpp',
+  'opt_algebraic.cpp',
+  'opt_array_splitting.cpp',
+  'opt_conditional_discard.cpp',
+  'opt_constant_folding.cpp',
+  'opt_constant_propagation.cpp',
+  'opt_constant_variable.cpp',
+  'opt_copy_propagation.cpp',
+  'opt_copy_propagation_elements.cpp',
+  'opt_dead_builtin_variables.cpp',
+  'opt_dead_builtin_varyings.cpp',
+  'opt_dead_code.cpp',
+  'opt_dead_code_local.cpp',
+  'opt_dead_functions.cpp',
+  'opt_flatten_nested_if_blocks.cpp',
+  'opt_flip_matrices.cpp',
+  'opt_function_inlining.cpp',
+  'opt_if_simplification.cpp',
+  'opt_minmax.cpp',
+  'opt_noop_swizzle.cpp',
+  'opt_rebalance_tree.cpp',
+  'opt_redundant_jumps.cpp',
+  'opt_structure_splitting.cpp',
+  'opt_swizzle_swizzle.cpp',
+  'opt_tree_grafting.cpp',
+  'opt_vectorize.cpp',
+  'program.h',
+  'propagate_invariance.cpp',
+  's_expression.cpp',
+  's_expression.h',
+  'string_to_uint_map.cpp',
+  'string_to_uint_map.h',
+  'shader_cache.cpp',
+  'shader_cache.h',
+)
+
+files_libglsl_standalone = files(
+  'ir_builder_print_visitor.cpp',
+  'ir_builder_print_visitor.h',
+  'opt_add_neg_to_sub.h',
+  'standalone_scaffolding.cpp',
+  'standalone_scaffolding.h',
+  'standalone.cpp',
+  'standalone.h',
+)
+
+libglsl = static_library(
+  'glsl',
+  [files_libglsl, glsl_parser, glsl_lexer_cpp, ir_expression_operation_h,
+   ir_expression_operation_strings_h, ir_expression_operation_constant_h],
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  link_with : [libnir, libglcpp],
+  include_directories : [inc_common, inc_nir],
+  dependencies : [dep_valgrind],
+  build_by_default : false,
+)
+
+libglsl_standalone = static_library(
+  'glsl_standalone',
+  [files_libglsl_standalone, ir_expression_operation_h],
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common],
+  link_with : [libglsl, libglsl_util, libmesa_util],
+  dependencies : [dep_thread],
+  build_by_default : false,
+)
+
+glsl_compiler = executable(
+  'glsl_compiler',
+  'main.cpp',
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  dependencies : [dep_clock],
+  include_directories : [inc_common],
+  link_with : [libglsl_standalone],
+  build_by_default : false,
+)
+
+glsl_test = executable(
+  'glsl_test',
+  ['test.cpp', 'test_optpass.cpp', 'test_optpass.h',
+   ir_expression_operation_h],
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common],
+  dependencies : [dep_clock, dep_thread],
+  link_with : [libglsl, libglsl_standalone, libglsl_util],
+  build_by_default : false,
+)
+
+if with_tests
+  subdir('tests')
+endif
diff --git a/src/compiler/glsl/tests/meson.build b/src/compiler/glsl/tests/meson.build
new file mode 100644
index 00000000000..ae04743c5a0
--- /dev/null
+++ b/src/compiler/glsl/tests/meson.build
@@ -0,0 +1,76 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+glsl_blob_test = executable(
+  'blob_test',
+  'blob_test.c',
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  include_directories : [inc_common, inc_glsl],
+  link_with : [libglsl],
+)
+
+glsl_cache_test = executable(
+  'cache_test',
+  'cache_test.c',
+  c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
+  include_directories : [inc_common, inc_glsl],
+  link_with : [libglsl],
+  dependencies : [dep_clock, dep_thread],
+)
+
+glsl_general_ir_test = executable(
+  'general_ir_test',
+  ['array_refcount_test.cpp', 'builtin_variable_test.cpp',
+   'invalidate_locations_test.cpp', 'general_ir_test.cpp',
+   'lower_int64_test.cpp', 'opt_add_neg_to_sub_test.cpp', 'varyings_test.cpp',
+   ir_expression_operation_h],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common, inc_glsl],
+  link_with : [libglsl, libglsl_standalone, libglsl_util],
+  dependencies : [dep_clock, dep_thread, idep_gtest],
+)
+
+glsl_uniform_initializer_test = executable(
+  'uniform_initializer_test',
+  ['copy_constant_to_storage_tests.cpp', 'set_uniform_initializer_tests.cpp',
+   'uniform_initializer_utils.cpp', 'uniform_initializer_utils.h',
+   ir_expression_operation_h],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common, inc_glsl],
+  link_with : [libglsl, libglsl_util],
+  dependencies : [dep_thread, idep_gtest],
+)
+
+glsl_sampler_types_test = executable(
+  'sampler_types_test',
+  ['sampler_types_test.cpp', ir_expression_operation_h],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common, inc_glsl],
+  link_with : [libglsl, libglsl_util],
+  dependencies : [dep_thread, idep_gtest],
+)
+
+test('blob_test', glsl_blob_test)
+test('cache_test', glsl_cache_test)
+test('general_ir_test', glsl_general_ir_test)
+test('uniform_initializer_test', glsl_uniform_initializer_test)
+test('sampler_types_test', glsl_sampler_types_test)
+
+# TODO: figure out how to get the shell based tests to work?
diff --git a/src/compiler/meson.build b/src/compiler/meson.build
index 9a40e2e3a1a..58d52e4c6cb 100644
--- a/src/compiler/meson.build
+++ b/src/compiler/meson.build
@@ -22,8 +22,6 @@ inc_compiler = include_directories('.')
 inc_nir = include_directories('nir')
 inc_glsl = include_directories('glsl')
 
-subdir('glsl')
-
 files_libcompiler = files(
   'builtin_type_macros.h',
   'glsl_types.cpp',
@@ -35,6 +33,14 @@ files_libcompiler = files(
   'shader_info.h',
 )
 
+ir_expression_operation_h = custom_target(
+  'ir_expression_operation.h',
+  input : 'glsl/ir_expression_operation.py',
+  output : 'ir_expression_operation.h',
+  command : [prog_python2, '@INPUT@', 'enum'],
+  capture : true,
+)
+
 libcompiler = static_library(
   'compiler',
   [files_libcompiler, ir_expression_operation_h],
@@ -55,3 +61,5 @@ spirv2nir = executable(
   c_args : [c_vis_args, c_msvc_compat_args, no_override_init_args],
   build_by_default : false,
 )
+
+subdir('glsl')
diff --git a/src/git_sha1.h.in b/src/git_sha1.h.in
new file mode 100644
index 00000000000..dc17f5e6614
--- /dev/null
+++ b/src/git_sha1.h.in
@@ -0,0 +1 @@
+#define MESA_GIT_SHA1 "git- at VCS_TAG@"
diff --git a/src/compiler/glsl/meson.build b/src/mapi/es1api/meson.build
similarity index 53%
copy from src/compiler/glsl/meson.build
copy to src/mapi/es1api/meson.build
index 0a2537d4981..acb2238c442 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/mapi/es1api/meson.build
@@ -18,12 +18,37 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
-
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
+es1_glapi_mapi_tmp_h = custom_target(
+  'es1_glapi_mapi_tmp.h',
+  input : ['../mapi_abi.py', gl_and_es_api_files],
+  output : 'glapi_mapi_tmp.h',
+  command : [prog_python2, '@INPUT0@', '--printer', 'es1api', '@INPUT1@'],
+  depend_files : api_xml_files,
   capture : true,
 )
+
+libglesv1_cm = shared_library(
+  'GLESv1_CM',
+  ['../entry.c', es1_glapi_mapi_tmp_h],
+  c_args : [c_msvc_compat_args, c_vis_args, '-DMAPI_MODE_BRIDGE',
+            '-DMAPI_ABI_HEADER="@0@"'.format(es1_glapi_mapi_tmp_h.full_path())],
+  link_args : [ld_args_gc_sections],
+  include_directories : [inc_src, inc_include, inc_mapi],
+  link_with : libglapi,
+  dependencies : [dep_thread, dep_libdrm, dep_m, dep_dl],
+  version : '1.1',
+  install : true,
+)
+
+pkg.generate(
+  libraries : libglesv1_cm,
+  # TODO: private libraries?
+  name : 'glesv1_cm',
+  version : meson.project_version(),
+  description : 'Mesa OpenGL ES 1.1 CM library',
+  filebase : 'glesv1_cm'
+)
+
+if with_tests
+  test('es1-ABI-check', find_program('ABI-check'))
+endif
diff --git a/src/compiler/glsl/meson.build b/src/mapi/es2api/meson.build
similarity index 54%
copy from src/compiler/glsl/meson.build
copy to src/mapi/es2api/meson.build
index 0a2537d4981..615e32cc8d9 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/mapi/es2api/meson.build
@@ -18,12 +18,36 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
-
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
+es2_glapi_mapi_tmp_h = custom_target(
+  'es2_glapi_mapi_tmp.h',
+  input : ['../mapi_abi.py', gl_and_es_api_files],
+  output : 'glapi_mapi_tmp.h',
+  command : [prog_python2, '@INPUT0@', '--printer', 'es2api', '@INPUT1@'],
+  depend_files : api_xml_files,
   capture : true,
 )
+
+libgles2 = shared_library(
+  'GLESv2',
+  ['../entry.c', es2_glapi_mapi_tmp_h],
+  c_args : [c_msvc_compat_args, c_vis_args, '-DMAPI_MODE_BRIDGE',
+            '-DMAPI_ABI_HEADER="@0@"'.format(es2_glapi_mapi_tmp_h.full_path())],
+  link_args : [ld_args_gc_sections],
+  include_directories : [inc_src, inc_include, inc_mapi],
+  link_with : libglapi,
+  dependencies : [dep_thread, dep_libdrm, dep_m, dep_dl],
+  version : '2',
+  install : true,
+)
+
+pkg.generate(
+  libraries : libgles2,
+  name : 'glesv2',
+  version : meson.project_version(),
+  description : 'Mesa OpenGL ES 2.0 library',
+  filebase : 'glesv2'
+)
+
+if with_tests
+  test('es2-ABI-check', find_program('ABI-check'))
+endif
diff --git a/src/mapi/glapi/gen/meson.build b/src/mapi/glapi/gen/meson.build
index 3612f1f6416..79aa2accc2a 100644
--- a/src/mapi/glapi/gen/meson.build
+++ b/src/mapi/glapi/gen/meson.build
@@ -17,3 +17,252 @@
 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
+
+gl_and_es_api_files = files('gl_and_es_API.xml')
+
+api_xml_files = files(
+  'gl_API.xml',
+  'es_EXT.xml',
+  'gl_and_es_API.xml',
+  'gl_and_glX_API.xml',
+  'ARB_base_instance.xml',
+  'ARB_blend_func_extended.xml',
+  'ARB_bindless_texture.xml',
+  'ARB_clear_buffer_object.xml',
+  'ARB_clear_texture.xml',
+  'ARB_clip_control.xml',
+  'ARB_color_buffer_float.xml',
+  'ARB_compressed_texture_pixel_storage.xml',
+  'ARB_compute_shader.xml',
+  'ARB_compute_variable_group_size.xml',
+  'ARB_copy_buffer.xml',
+  'ARB_copy_image.xml',
+  'ARB_debug_output.xml',
+  'ARB_depth_buffer_float.xml',
+  'ARB_depth_clamp.xml',
+  'ARB_direct_state_access.xml',
+  'ARB_draw_buffers.xml',
+  'ARB_draw_buffers_blend.xml',
+  'ARB_draw_elements_base_vertex.xml',
+  'ARB_draw_indirect.xml',
+  'ARB_draw_instanced.xml',
+  'ARB_ES2_compatibility.xml',
+  'ARB_ES3_compatibility.xml',
+  'ARB_framebuffer_no_attachments.xml',
+  'ARB_framebuffer_object.xml',
+  'ARB_get_program_binary.xml',
+  'ARB_get_texture_sub_image.xml',
+  'ARB_gpu_shader_fp64.xml',
+  'ARB_gpu_shader_int64.xml',
+  'ARB_gpu_shader5.xml',
+  'ARB_indirect_parameters.xml',
+  'ARB_instanced_arrays.xml',
+  'ARB_internalformat_query.xml',
+  'ARB_internalformat_query2.xml',
+  'ARB_invalidate_subdata.xml',
+  'ARB_map_buffer_range.xml',
+  'ARB_multi_bind.xml',
+  'ARB_pipeline_statistics_query.xml',
+  'ARB_program_interface_query.xml',
+  'ARB_robustness.xml',
+  'ARB_sample_shading.xml',
+  'ARB_sampler_objects.xml',
+  'ARB_seamless_cube_map.xml',
+  'ARB_separate_shader_objects.xml',
+  'ARB_shader_atomic_counters.xml',
+  'ARB_shader_image_load_store.xml',
+  'ARB_shader_subroutine.xml',
+  'ARB_shader_storage_buffer_object.xml',
+  'ARB_sparse_buffer.xml',
+  'ARB_sync.xml',
+  'ARB_tessellation_shader.xml',
+  'ARB_texture_barrier.xml',
+  'ARB_texture_buffer_object.xml',
+  'ARB_texture_buffer_range.xml',
+  'ARB_texture_compression_rgtc.xml',
+  'ARB_texture_cube_map_array.xml',
+  'ARB_texture_float.xml',
+  'ARB_texture_gather.xml',
+  'ARB_texture_multisample.xml',
+  'ARB_texture_rgb10_a2ui.xml',
+  'ARB_texture_rg.xml',
+  'ARB_texture_storage_multisample.xml',
+  'ARB_texture_storage.xml',
+  'ARB_texture_view.xml',
+  'ARB_uniform_buffer_object.xml',
+  'ARB_vertex_array_object.xml',
+  'ARB_vertex_attrib_64bit.xml',
+  'ARB_vertex_attrib_binding.xml',
+  'ARB_viewport_array.xml',
+  'AMD_draw_buffers_blend.xml',
+  'AMD_performance_monitor.xml',
+  'ARB_vertex_type_2_10_10_10_rev.xml',
+  'APPLE_object_purgeable.xml',
+  'APPLE_vertex_array_object.xml',
+  'EXT_draw_buffers2.xml',
+  'EXT_external_objects.xml',
+  'EXT_external_objects_fd.xml',
+  'EXT_framebuffer_object.xml',
+  'EXT_gpu_shader4.xml',
+  'EXT_packed_depth_stencil.xml',
+  'EXT_provoking_vertex.xml',
+  'EXT_separate_shader_objects.xml',
+  'EXT_texture_array.xml',
+  'EXT_texture_integer.xml',
+  'EXT_transform_feedback.xml',
+  'EXT_window_rectangles.xml',
+  'GREMEDY_string_marker.xml',
+  'INTEL_performance_query.xml',
+  'KHR_debug.xml',
+  'KHR_context_flush_control.xml',
+  'KHR_robustness.xml',
+  'KHR_robustness_es.xml',
+  'KHR_texture_compression_astc.xml',
+  'NV_conditional_render.xml',
+  'NV_primitive_restart.xml',
+  'NV_texture_barrier.xml',
+  'NV_vdpau_interop.xml',
+  'OES_EGL_image.xml',
+  'OES_fixed_point.xml',
+  'OES_single_precision.xml',
+  'OES_texture_compression_astc.xml',
+  'GL3x.xml',
+  'GL4x.xml',
+)
+
+glapi_gen_depends = files(
+  'gl_XML.py',
+  'glX_XML.py',
+  'license.py',
+  'static_data.py',
+  'typeexpr.py',
+) + api_xml_files
+
+glx_gen_depends = files(
+  'glX_API.xml',
+  'glX_XML.py',
+  'glX_proto_common.py',
+) + api_xml_files
+
+glapi_mapi_tmp_h = custom_target(
+  'glapi_mapi_tmp.h',
+  input : ['../../mapi_abi.py', 'gl_and_es_API.xml'],
+  output : 'glapi_mapi_tmp.h',
+  command : [prog_python2, '@INPUT0@', '--printer', 'glapi', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+gl_procs_h = custom_target(
+  'gl_procs.h',
+  input : ['gl_procs.py', 'gl_and_es_API.xml'],
+  output : 'gl_procs.h',
+  command : [prog_python2, '@INPUT0@', '-c', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+glapitemp_h = custom_target(
+  'glapitemp.h',
+  input : ['gl_apitemp.py', 'gl_and_es_API.xml'],
+  output : 'glapitemp.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+glapitable_h = custom_target(
+  'glapitable.h',
+  input : ['gl_table.py', 'gl_and_es_API.xml'],
+  output : 'glapitable.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+glapi_gentable_c = custom_target(
+  'glapi_gentable.c',
+  input : ['gl_gentable.py', 'gl_and_es_API.xml'],
+  output : 'glapi_gentable.c',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+main_enums_c = custom_target(
+  'enums.c',
+  input : ['gl_enums.py', files('../registry/gl.xml')],
+  output : 'enums.c',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  capture : true,
+)
+
+main_api_exec_c = custom_target(
+  'api_exec.c',
+  input : ['gl_genexec.py', 'gl_and_es_API.xml'],
+  output : 'api_exec.c',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : files('apiexec.py') + glapi_gen_depends,
+  capture : true,
+)
+
+main_marshal_generated_c = custom_target(
+  'marshal_generated.c',
+  input : ['gl_marshal.py', 'gl_and_es_API.xml'],
+  output : 'marshal_generated.c',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : files('marshal_XML.py') + glapi_gen_depends,
+  capture : true,
+)
+
+glx_generated = []
+
+foreach x : [['indirect.c', 'proto'], ['indirect.h', 'init_h'], ['indirect_init.c', 'init_c']]
+  glx_generated += custom_target(
+    x[0],
+    input : ['glX_proto_send.py', 'gl_API.xml'],
+    output : x[0],
+    command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@', '-m', x[1]],
+    depend_files : glx_gen_depends,
+    capture : true,
+  )
+endforeach
+
+foreach x : [['indirect_size.h', ['-m', 'size_h', '--header-tag', '_INDIRECT_SIZE_H_']],
+             ['indirect_size.c', ['-m', 'size_c']]]
+  glx_generated += custom_target(
+    x[0],
+    input : ['glX_proto_size.py', 'gl_API.xml'],
+    output : x[0],
+    command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@', '--only-set', x[1]],
+    depend_files : glx_gen_depends,
+    capture : true,
+  )
+endforeach
+
+glapi_x86_s = custom_target(
+  'glapi_x86.S',
+  input : ['gl_x86_asm.py', gl_and_es_api_files],
+  output : 'glapi_x86.S',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+glapi_x86_64_s = custom_target(
+  'glapi_x86-64.S',
+  input : ['gl_x86-64_asm.py', gl_and_es_api_files],
+  output : 'glapi_x86-64.S',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+glapi_sparc_s = custom_target(
+  'glapi_sparc.S',
+  input : ['gl_SPARC_asm.py', gl_and_es_api_files],
+  output : 'glapi_sparc.S',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
diff --git a/src/mapi/glapi/meson.build b/src/mapi/glapi/meson.build
new file mode 100644
index 00000000000..d09cf94e36f
--- /dev/null
+++ b/src/mapi/glapi/meson.build
@@ -0,0 +1,82 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+static_glapi_files = []
+static_glapi_args = []
+
+if with_appledri or with_windowsdri
+  static_glapi_files += files('glapi_gentable.c')
+endif
+
+if with_shared_glapi
+  static_glapi_files += files(
+    '../entry.c',
+    '../entry.h',
+    '../entry_x86-64_tls.h',
+    '../entry_x86_tls.h',
+    '../entry_x86_tsd.h',
+    '../entry_ppc64le_tls.h',
+    '../entry_ppc64le_tsd.h',
+    '../mapi_tmp.h',
+  )
+  static_glapi_files += glapi_mapi_tmp_h
+  static_glapi_args += [
+    '-DMAPI_MODE_BRIDGE',
+    '-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path()),
+  ]
+else
+  static_glapi_args += '-DMAPI_MODE_UTIL'
+  static_glapi_files += files(
+    'glapi_dispatch.c',
+    'glapi_entrypoint.c',
+    'glapi_getproc.c',
+    'glapi_nop.c',
+    'glapi.c',
+    'glapi.h',
+    'glapi_priv.h',
+  )
+  static_glapi_files += files_mapi_util
+  if with_asm_arch == 'x86'
+    static_glapi_files += glapi_x86_s
+  elif with_asm_arch == 'x86_64'
+    static_glapi_files += glapi_x86_64_s
+  endif
+  # TODO: SPARC asm
+endif
+
+libglapi_static = static_library(
+  'glapi_static',
+  static_glapi_files,
+  include_directories : [inc_mesa, inc_include, inc_src],
+  c_args : [c_msvc_compat_args, static_glapi_args],
+  dependencies : [dep_thread, dep_selinux],
+  build_by_default : false,
+)
+
+if not with_shared_glapi and with_tests
+  glapi_static_check_table = executable(
+    'glapi_static_check_table',
+    'tests/check_table.cpp',
+    link_with : [libglapi_static],
+    dependencies : [idep_gtest],
+  )
+
+  test('glapi_static_check_table', glapi_static_check_table)
+endif
diff --git a/include/meson.build b/src/mapi/meson.build
similarity index 81%
copy from include/meson.build
copy to src/mapi/meson.build
index 93def7e0ec2..ce94ee4b27a 100644
--- a/include/meson.build
+++ b/src/mapi/meson.build
@@ -18,5 +18,20 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-inc_drm_uapi = include_directories('drm-uapi')
-inc_vulkan = include_directories('vulkan')
+files_mapi_util = files(
+  'u_current.c',
+  'u_current.h',
+  'u_execmem.c',
+  'u_execmem.h',
+)
+
+if with_shared_glapi
+  subdir('shared-glapi')
+endif
+subdir('glapi')
+if with_gles1
+  subdir('es1api')
+endif
+if with_gles2
+  subdir('es2api')
+endif
diff --git a/src/mapi/shared-glapi/meson.build b/src/mapi/shared-glapi/meson.build
new file mode 100644
index 00000000000..0d88de0545f
--- /dev/null
+++ b/src/mapi/shared-glapi/meson.build
@@ -0,0 +1,61 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_mapi_glapi = files(
+  '../entry.c',
+  '../mapi_glapi.c',
+  '../stub.c',
+  '../stub.h',
+  '../table.c',
+  '../table.h',
+)
+
+shared_glapi_mapi_tmp_h = custom_target(
+  'shared_glapi_mapi_tmp.h',
+  input : ['../mapi_abi.py', gl_and_es_api_files],
+  output : 'glapi_mapi_tmp.h',
+  command : [prog_python2, '@INPUT0@', '--printer', 'shared-glapi', '@INPUT1@'],
+  depend_files : api_xml_files,
+  capture : true,
+)
+
+libglapi = shared_library(
+  'glapi',
+  [files_mapi_glapi, files_mapi_util, shared_glapi_mapi_tmp_h],
+  c_args : [c_msvc_compat_args, '-DMAPI_MODE_GLAPI',
+            '-DMAPI_ABI_HEADER="@0@"'.format(shared_glapi_mapi_tmp_h.full_path())],
+  link_args : [ld_args_gc_sections],
+  include_directories : [inc_src, inc_include, inc_mapi],
+  dependencies : [dep_thread, dep_selinux],
+  install : true,
+)
+
+if with_tests
+  shared_glapi_test = executable(
+    ['shared-glapi-test', glapitable_h],
+    'tests/check_table.cpp',
+    cpp_args : [cpp_msvc_compat_args],
+    include_directories : [inc_src, inc_include, inc_mapi],
+    link_with : [libglapi],
+    dependencies : [dep_thread, idep_gtest],
+  )
+
+  test('shared-glapi-test', shared_glapi_test)
+endif
diff --git a/src/compiler/glsl/meson.build b/src/mesa/drivers/dri/common/meson.build
similarity index 69%
copy from src/compiler/glsl/meson.build
copy to src/mesa/drivers/dri/common/meson.build
index 0a2537d4981..d9a9abdfb7a 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/mesa/drivers/dri/common/meson.build
@@ -18,12 +18,22 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
+inc_dri_common = include_directories('.')
 
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
-  capture : true,
+libdricommon = static_library(
+  'dricommon',
+  ['utils.c', 'utils.h', 'dri_util.c', 'dri_util.h', xmlpool_options_h],
+  include_directories : [inc_common, inc_util],
+  c_args : c_vis_args,
+  dependencies : dep_libdrm,
+  build_by_default : false,
+)
+
+libmegadriver_stub = static_library(
+  'megadriver_stub',
+  'megadriver_stub.c',
+  include_directories : inc_common,
+  c_args : c_vis_args,
+  dependencies : dep_libdrm,
+  build_by_default : false,
 )
diff --git a/src/mesa/drivers/dri/i965/meson.build b/src/mesa/drivers/dri/i965/meson.build
new file mode 100644
index 00000000000..0fbad4181a2
--- /dev/null
+++ b/src/mesa/drivers/dri/i965/meson.build
@@ -0,0 +1,178 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+files_i965 = files(
+  'brw_binding_tables.c',
+  'brw_blorp.c',
+  'brw_blorp.h',
+  'brw_bufmgr.c',
+  'brw_bufmgr.h',
+  'brw_clear.c',
+  'brw_clip.c',
+  'brw_compute.c',
+  'brw_conditional_render.c',
+  'brw_context.c',
+  'brw_context.h',
+  'brw_cs.c',
+  'brw_cs.h',
+  'brw_curbe.c',
+  'brw_defines.h',
+  'brw_draw.c',
+  'brw_draw.h',
+  'brw_draw_upload.c',
+  'brw_ff_gs.c',
+  'brw_ff_gs_emit.c',
+  'brw_ff_gs.h',
+  'brw_formatquery.c',
+  'brw_gs.c',
+  'brw_gs.h',
+  'brw_gs_surface_state.c',
+  'brw_link.cpp',
+  'brw_meta_util.c',
+  'brw_meta_util.h',
+  'brw_misc_state.c',
+  'brw_multisample_state.h',
+  'brw_nir_uniforms.cpp',
+  'brw_object_purgeable.c',
+  'brw_pipe_control.c',
+  'brw_performance_query.h',
+  'brw_performance_query.c',
+  'brw_program.c',
+  'brw_program.h',
+  'brw_program_cache.c',
+  'brw_primitive_restart.c',
+  'brw_queryobj.c',
+  'brw_reset.c',
+  'brw_sf.c',
+  'brw_state.h',
+  'brw_state_upload.c',
+  'brw_structs.h',
+  'brw_surface_formats.c',
+  'brw_sync.c',
+  'brw_tcs.c',
+  'brw_tcs_surface_state.c',
+  'brw_tes.c',
+  'brw_tes_surface_state.c',
+  'brw_urb.c',
+  'brw_util.c',
+  'brw_util.h',
+  'brw_vs.c',
+  'brw_vs.h',
+  'brw_vs_surface_state.c',
+  'brw_wm.c',
+  'brw_wm.h',
+  'brw_wm_surface_state.c',
+  'gen4_blorp_exec.h',
+  'gen6_clip_state.c',
+  'gen6_constant_state.c',
+  'gen6_depth_state.c',
+  'gen6_multisample_state.c',
+  'gen6_queryobj.c',
+  'gen6_sampler_state.c',
+  'gen6_sol.c',
+  'gen6_urb.c',
+  'gen7_cs_state.c',
+  'gen7_l3_state.c',
+  'gen7_misc_state.c',
+  'gen7_sol_state.c',
+  'gen7_urb.c',
+  'gen8_depth_state.c',
+  'gen8_multisample_state.c',
+  'hsw_queryobj.c',
+  'hsw_sol.c',
+  'intel_batchbuffer.c',
+  'intel_batchbuffer.h',
+  'intel_blit.c',
+  'intel_blit.h',
+  'intel_buffer_objects.c',
+  'intel_buffer_objects.h',
+  'intel_buffers.c',
+  'intel_buffers.h',
+  'intel_copy_image.c',
+  'intel_extensions.c',
+  'intel_fbo.c',
+  'intel_fbo.h',
+  'intel_image.h',
+  'intel_mipmap_tree.c',
+  'intel_mipmap_tree.h',
+  'intel_pixel_bitmap.c',
+  'intel_pixel.c',
+  'intel_pixel_copy.c',
+  'intel_pixel_draw.c',
+  'intel_pixel.h',
+  'intel_pixel_read.c',
+  'intel_screen.c',
+  'intel_screen.h',
+  'intel_state.c',
+  'intel_tex.c',
+  'intel_tex_copy.c',
+  'intel_tex.h',
+  'intel_tex_image.c',
+  'intel_tex_obj.h',
+  'intel_tex_validate.c',
+  'intel_tiled_memcpy.c',
+  'intel_tiled_memcpy.h',
+  'intel_upload.c',
+  'libdrm_macros.h',
+)
+
+i965_gen_libs = []
+foreach v : ['40', '45', '50', '60', '70', '75', '80', '90', '100']
+  _lib = static_library(
+    'libi965_gen at 0@'.format(v),
+    ['genX_blorp_exec.c', 'genX_state_upload.c', nir_opcodes_h, gen_xml_pack],
+    include_directories : [inc_common, inc_intel, inc_dri_common],
+    c_args : [c_vis_args, no_override_init_args, '-msse2',
+              '-DGEN_VERSIONx10=@0@'.format(v)],
+    dependencies : [dep_libdrm],
+  )
+  i965_gen_libs += _lib
+endforeach
+
+oa_generator = generator(
+  prog_python2,
+  arguments : ['@CURRENT_SOURCE_DIR@/brw_oa.py', '@INPUT@',
+               '--chipset', '@EXTRA_ARGS@', '--code', '@OUTPUT0@',
+               '--header', '@OUTPUT1@'],
+  output : ['@BASENAME at .c', '@BASENAME at .h'],
+)
+
+i965_oa_sources = []
+foreach hw : ['hsw', 'bdw', 'chv', 'sklgt2', 'sklgt3', 'sklgt4', 'bxt',
+              'kblgt2', 'kblgt3', 'glk']
+  _xml = 'brw_oa_ at 0@.xml'.format(hw)
+  i965_oa_sources += oa_generator.process(_xml, extra_args : hw)
+endforeach
+
+libi965 = static_library(
+  'i965',
+  [files_i965, i965_oa_sources, nir_opcodes_h, ir_expression_operation_h,
+   xmlpool_options_h],
+  include_directories : [inc_common, inc_intel, inc_dri_common, inc_util,
+                         inc_drm_uapi, inc_nir],
+  c_args : [c_vis_args, no_override_init_args, '-msse2'],
+  cpp_args : [cpp_vis_args, '-msse2'],
+  link_with : [i965_gen_libs, libintel_common, libisl, libintel_compiler,
+               libblorp],
+  dependencies : [dep_libdrm, dep_valgrind],
+)
+
+dri_drivers += libi965
+dri_link += 'i965_dri.so'
diff --git a/src/meson.build b/src/mesa/drivers/dri/meson.build
similarity index 53%
copy from src/meson.build
copy to src/mesa/drivers/dri/meson.build
index 76ff497e565..fc851e8a6b4 100644
--- a/src/meson.build
+++ b/src/mesa/drivers/dri/meson.build
@@ -18,31 +18,38 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: libglsl_util
-
-# TODO: git_sha. There's a meson builtin for this
-
-inc_common = include_directories(
-  '../include', '.', 'mapi', 'mesa', 'gallium/include', 'gallium/auxiliary')
-inc_mesa = include_directories('mesa')
-inc_mapi = include_directories('mapi')
-
-subdir('gtest')
-subdir('util')
-#subdir('mapi/glapi/gen')
-# TODO: mapi
-# TODO: opengl
-# TODO: glx
-# TODO: osmesa
-subdir('compiler')
-subdir('egl/wayland/wayland-drm')
-subdir('vulkan')
-subdir('amd')
-subdir('intel')
-# TODO: vc4
-# TODO: opengl_common
-# TODO: dri_glx
-# TODO: gbm
-# TODO: egl
-# TODO: radv
-# TODO: gallium
+subdir('common')
+
+dri_drivers = []
+dri_link = []
+if with_dri_i965
+  subdir('i965')
+endif
+
+if with_dri
+  libmesa_dri_drivers = shared_library(
+    'mesa_dri_drivers',
+    dummy_cpp,  # see meson #2180
+    link_whole : dri_drivers,
+    link_with : [libmegadriver_stub, libdricommon, libxmlconfig, libglapi,
+                 libmesa_util, libnir, libmesa_classic],
+    dependencies : [dep_selinux, dep_libdrm, dep_expat, dep_m, dep_thread,
+                    dep_dl],
+    link_args : [ld_args_bsymbolic, ld_args_gc_sections],
+  )
+
+  pkg.generate(
+    name : 'dri',
+    filebase : 'dri',
+    description : 'Direct Rendering Infrastructure',
+    version : meson.project_version(),
+    requires_private : ['libdrm >= 2.4.75'],  # FIXME: don't hardcode this
+  )
+
+  meson.add_install_script(
+    join_paths(meson.source_root(), 'bin/install_megadrivers.py'),
+    libmesa_dri_drivers.full_path(),
+    join_paths(get_option('libdir'), 'dri'),
+    dri_link,
+  )
+endif
diff --git a/src/compiler/glsl/meson.build b/src/mesa/main/meson.build
similarity index 55%
copy from src/compiler/glsl/meson.build
copy to src/mesa/main/meson.build
index 0a2537d4981..57487fe4da5 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/mesa/main/meson.build
@@ -18,12 +18,29 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
+main_dispatch_h = custom_target(
+  'dispatch.h',
+  input : [files('../../mapi/glapi/gen/gl_table.py'), gl_and_es_api_files],
+  output : 'dispatch.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@', '-m', 'remap_table'],
+  depend_files : glapi_gen_depends,
+  capture : true,
+)
+
+main_marshal_generated_h = custom_target(
+  'marshal_generated.h',
+  input : [files('../../mapi/glapi/gen/gl_marshal_h.py'), gl_and_es_api_files],
+  output : 'marshal_generated.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : files('../../mapi/glapi/gen/marshal_XML.py') + glapi_gen_depends,
+  capture : true,
+)
 
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
+main_remap_helper_h = custom_target(
+  'remap_helper.h',
+  input : [files('../../mapi/glapi/gen/remap_helper.py'), gl_and_es_api_files],
+  output : 'remap_helper.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : glapi_gen_depends,
   capture : true,
 )
diff --git a/src/mesa/meson.build b/src/mesa/meson.build
new file mode 100644
index 00000000000..665b35e5339
--- /dev/null
+++ b/src/mesa/meson.build
@@ -0,0 +1,582 @@
+# Copyright © 2017 Intel Corporation
+
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+# TODO: main/tests
+# TODO: xlib_glx
+# TODO: osmesa
+# TODO: asm_offsets
+
+subdir('program')
+subdir('main')
+
+# program files
+# program nir files
+# files shared between classic mesa and gallium mesa
+files_libmesa_common = files(
+  'program/arbprogparse.c',
+  'program/arbprogparse.h',
+  'program/ir_to_mesa.cpp',
+  'program/ir_to_mesa.h',
+  'program/prog_cache.c',
+  'program/prog_cache.h',
+  'program/prog_execute.c',
+  'program/prog_execute.h',
+  'program/prog_instruction.c',
+  'program/prog_instruction.h',
+  'program/prog_noise.c',
+  'program/prog_noise.h',
+  'program/prog_opt_constant_fold.c',
+  'program/prog_optimize.c',
+  'program/prog_optimize.h',
+  'program/prog_parameter.c',
+  'program/prog_parameter.h',
+  'program/prog_parameter_layout.c',
+  'program/prog_parameter_layout.h',
+  'program/prog_print.c',
+  'program/prog_print.h',
+  'program/program.c',
+  'program/program.h',
+  'program/programopt.c',
+  'program/programopt.h',
+  'program/program_parse_extra.c',
+  'program/program_parser.h',
+  'program/prog_statevars.c',
+  'program/prog_statevars.h',
+  'program/symbol_table.c',
+  'program/symbol_table.h',
+  'program/prog_to_nir.c',
+  'program/prog_to_nir.h',
+  'main/accum.c',
+  'main/accum.h',
+  'main/api_arrayelt.c',
+  'main/api_arrayelt.h',
+  'main/api_exec.h',
+  'main/api_loopback.c',
+  'main/api_loopback.h',
+  'main/api_validate.c',
+  'main/api_validate.h',
+  'main/arbprogram.c',
+  'main/arbprogram.h',
+  'main/arrayobj.c',
+  'main/arrayobj.h',
+  'main/atifragshader.c',
+  'main/atifragshader.h',
+  'main/attrib.c',
+  'main/attrib.h',
+  'main/barrier.c',
+  'main/barrier.h',
+  'main/bbox.c',
+  'main/bbox.h',
+  'main/blend.c',
+  'main/blend.h',
+  'main/blit.c',
+  'main/blit.h',
+  'main/bufferobj.c',
+  'main/bufferobj.h',
+  'main/buffers.c',
+  'main/buffers.h',
+  'main/clear.c',
+  'main/clear.h',
+  'main/clip.c',
+  'main/clip.h',
+  'main/colormac.h',
+  'main/colortab.c',
+  'main/colortab.h',
+  'main/compute.c',
+  'main/compute.h',
+  'main/compiler.h',
+  'main/condrender.c',
+  'main/condrender.h',
+  'main/config.h',
+  'main/context.c',
+  'main/context.h',
+  'main/convolve.c',
+  'main/convolve.h',
+  'main/copyimage.c',
+  'main/copyimage.h',
+  'main/core.h',
+  'main/cpuinfo.c',
+  'main/cpuinfo.h',
+  'main/dd.h',
+  'main/debug.c',
+  'main/debug.h',
+  'main/debug_output.c',
+  'main/debug_output.h',
+  'main/depth.c',
+  'main/depth.h',
+  'main/dlist.c',
+  'main/dlist.h',
+  'main/drawpix.c',
+  'main/drawpix.h',
+  'main/drawtex.c',
+  'main/drawtex.h',
+  'main/enable.c',
+  'main/enable.h',
+  'main/enums.h',
+  'main/errors.c',
+  'main/errors.h',
+  'main/eval.c',
+  'main/eval.h',
+  'main/execmem.c',
+  'main/extensions.c',
+  'main/extensions.h',
+  'main/extensions_table.c',
+  'main/extensions_table.h',
+  'main/externalobjects.c',
+  'main/externalobjects.h',
+  'main/fbobject.c',
+  'main/fbobject.h',
+  'main/feedback.c',
+  'main/feedback.h',
+  'main/ff_fragment_shader.cpp',
+  'main/ffvertex_prog.c',
+  'main/ffvertex_prog.h',
+  'main/fog.c',
+  'main/fog.h',
+  'main/format_pack.h',
+  'main/format_unpack.h',
+  'main/formatquery.c',
+  'main/formatquery.h',
+  'main/formats.c',
+  'main/formats.h',
+  'main/format_utils.c',
+  'main/format_utils.h',
+  'main/framebuffer.c',
+  'main/framebuffer.h',
+  'main/get.c',
+  'main/get.h',
+  'main/genmipmap.c',
+  'main/genmipmap.h',
+  'main/getstring.c',
+  'main/glformats.c',
+  'main/glformats.h',
+  'main/glthread.c',
+  'main/glthread.h',
+  'main/glheader.h',
+  'main/hash.c',
+  'main/hash.h',
+  'main/hint.c',
+  'main/hint.h',
+  'main/histogram.c',
+  'main/histogram.h',
+  'main/image.c',
+  'main/image.h',
+  'main/imports.c',
+  'main/imports.h',
+  'main/light.c',
+  'main/light.h',
+  'main/lines.c',
+  'main/lines.h',
+  'main/macros.h',
+  'main/marshal.c',
+  'main/marshal.h',
+  'main/matrix.c',
+  'main/matrix.h',
+  'main/mipmap.c',
+  'main/mipmap.h',
+  'main/mm.c',
+  'main/mm.h',
+  'main/mtypes.h',
+  'main/multisample.c',
+  'main/multisample.h',
+  'main/objectlabel.c',
+  'main/objectlabel.h',
+  'main/objectpurge.c',
+  'main/objectpurge.h',
+  'main/pack.c',
+  'main/pack.h',
+  'main/pbo.c',
+  'main/pbo.h',
+  'main/performance_monitor.c',
+  'main/performance_monitor.h',
+  'main/performance_query.c',
+  'main/performance_query.h',
+  'main/pipelineobj.c',
+  'main/pipelineobj.h',
+  'main/pixel.c',
+  'main/pixel.h',
+  'main/pixelstore.c',
+  'main/pixelstore.h',
+  'main/pixeltransfer.c',
+  'main/pixeltransfer.h',
+  'main/points.c',
+  'main/points.h',
+  'main/polygon.c',
+  'main/polygon.h',
+  'main/program_resource.c',
+  'main/program_resource.h',
+  'main/querymatrix.c',
+  'main/querymatrix.h',
+  'main/queryobj.c',
+  'main/queryobj.h',
+  'main/rastpos.c',
+  'main/rastpos.h',
+  'main/readpix.c',
+  'main/readpix.h',
+  'main/remap.c',
+  'main/remap.h',
+  'main/renderbuffer.c',
+  'main/renderbuffer.h',
+  'main/robustness.c',
+  'main/samplerobj.c',
+  'main/samplerobj.h',
+  'main/scissor.c',
+  'main/scissor.h',
+  'main/shaderapi.c',
+  'main/shaderapi.h',
+  'main/shaderimage.c',
+  'main/shaderimage.h',
+  'main/shaderobj.c',
+  'main/shaderobj.h',
+  'main/shader_query.cpp',
+  'main/shared.c',
+  'main/shared.h',
+  'main/state.c',
+  'main/state.h',
+  'main/stencil.c',
+  'main/stencil.h',
+  'main/syncobj.c',
+  'main/syncobj.h',
+  'main/texcompress.c',
+  'main/texcompress_bptc.c',
+  'main/texcompress_bptc.h',
+  'main/texcompress_cpal.c',
+  'main/texcompress_cpal.h',
+  'main/texcompress_etc.c',
+  'main/texcompress_etc.h',
+  'main/texcompress_etc_tmp.h',
+  'main/texcompress_fxt1.c',
+  'main/texcompress_fxt1.h',
+  'main/texcompress.h',
+  'main/texcompress_rgtc.c',
+  'main/texcompress_rgtc.h',
+  'main/texcompress_s3tc.c',
+  'main/texcompress_s3tc.h',
+  'main/texenv.c',
+  'main/texenv.h',
+  'main/texenvprogram.h',
+  'main/texformat.c',
+  'main/texformat.h',
+  'main/texgen.c',
+  'main/texgen.h',
+  'main/texgetimage.c',
+  'main/texgetimage.h',
+  'main/teximage.c',
+  'main/teximage.h',
+  'main/texobj.c',
+  'main/texobj.h',
+  'main/texparam.c',
+  'main/texparam.h',
+  'main/texstate.c',
+  'main/texstate.h',
+  'main/texstorage.c',
+  'main/texstorage.h',
+  'main/texstore.c',
+  'main/texstore.h',
+  'main/texturebindless.c',
+  'main/texturebindless.h',
+  'main/textureview.c',
+  'main/textureview.h',
+  'main/transformfeedback.c',
+  'main/transformfeedback.h',
+  'main/uniform_query.cpp',
+  'main/uniforms.c',
+  'main/uniforms.h',
+  'main/varray.c',
+  'main/varray.h',
+  'main/vdpau.c',
+  'main/vdpau.h',
+  'main/version.c',
+  'main/version.h',
+  'main/viewport.c',
+  'main/viewport.h',
+  'main/vtxfmt.c',
+  'main/vtxfmt.h',
+  'main/es1_conversion.c',
+  'main/es1_conversion.h',
+  'math/m_debug.h',
+  'math/m_debug_clip.c',
+  'math/m_debug_norm.c',
+  'math/m_debug_util.h',
+  'math/m_debug_xform.c',
+  'math/m_eval.c',
+  'math/m_eval.h',
+  'math/m_matrix.c',
+  'math/m_matrix.h',
+  'math/m_trans_tmp.h',
+  'math/m_translate.c',
+  'math/m_translate.h',
+  'math/m_vector.c',
+  'math/m_vector.h',
+  'vbo/vbo_attrib.h',
+  'vbo/vbo_attrib_tmp.h',
+  'vbo/vbo_context.c',
+  'vbo/vbo_context.h',
+  'vbo/vbo_exec_api.c',
+  'vbo/vbo_exec_array.c',
+  'vbo/vbo_exec.c',
+  'vbo/vbo_exec_draw.c',
+  'vbo/vbo_exec_eval.c',
+  'vbo/vbo_exec.h',
+  'vbo/vbo.h',
+  'vbo/vbo_minmax_index.c',
+  'vbo/vbo_noop.c',
+  'vbo/vbo_noop.h',
+  'vbo/vbo_primitive_restart.c',
+  'vbo/vbo_rebase.c',
+  'vbo/vbo_save_api.c',
+  'vbo/vbo_save.c',
+  'vbo/vbo_save_draw.c',
+  'vbo/vbo_save.h',
+  'vbo/vbo_save_loopback.c',
+  'vbo/vbo_split.c',
+  'vbo/vbo_split_copy.c',
+  'vbo/vbo_split.h',
+  'vbo/vbo_split_inplace.c',
+)
+
+# mesa files
+files_libmesa_classic = files(
+  'math/m_clip_tmp.h',
+  'math/m_copy_tmp.h',
+  'math/m_dotprod_tmp.h',
+  'math/m_norm_tmp.h',
+  'math/m_xform.c',
+  'math/m_xform.h',
+  'math/m_xform_tmp.h',
+  'tnl/t_context.c',
+  'tnl/t_context.h',
+  'tnl/t_draw.c',
+  'tnl/tnl.h',
+  'tnl/t_pipeline.c',
+  'tnl/t_pipeline.h',
+  'tnl/t_vb_cliptmp.h',
+  'tnl/t_vb_fog.c',
+  'tnl/t_vb_light.c',
+  'tnl/t_vb_lighttmp.h',
+  'tnl/t_vb_normals.c',
+  'tnl/t_vb_points.c',
+  'tnl/t_vb_program.c',
+  'tnl/t_vb_render.c',
+  'tnl/t_vb_rendertmp.h',
+  'tnl/t_vb_texgen.c',
+  'tnl/t_vb_texmat.c',
+  'tnl/t_vb_vertex.c',
+  'tnl/t_vertex.c',
+  'tnl/t_vertex_generic.c',
+  'tnl/t_vertex.h',
+  'tnl/t_vertex_sse.c',
+  'tnl/t_vp_build.c',
+  'tnl/t_vp_build.h',
+  'swrast/s_aaline.c',
+  'swrast/s_aaline.h',
+  'swrast/s_aalinetemp.h',
+  'swrast/s_aatriangle.c',
+  'swrast/s_aatriangle.h',
+  'swrast/s_aatritemp.h',
+  'swrast/s_alpha.c',
+  'swrast/s_alpha.h',
+  'swrast/s_atifragshader.c',
+  'swrast/s_atifragshader.h',
+  'swrast/s_bitmap.c',
+  'swrast/s_blend.c',
+  'swrast/s_blend.h',
+  'swrast/s_blit.c',
+  'swrast/s_chan.h',
+  'swrast/s_clear.c',
+  'swrast/s_context.c',
+  'swrast/s_context.h',
+  'swrast/s_copypix.c',
+  'swrast/s_depth.c',
+  'swrast/s_depth.h',
+  'swrast/s_drawpix.c',
+  'swrast_setup/ss_tritmp.h',
+  'swrast_setup/ss_vb.h',
+  'swrast_setup/swrast_setup.h',
+  'swrast/s_feedback.c',
+  'swrast/s_feedback.h',
+  'swrast/s_fog.c',
+  'swrast/s_fog.h',
+  'swrast/s_fragprog.c',
+  'swrast/s_fragprog.h',
+  'swrast/s_lines.c',
+  'swrast/s_lines.h',
+  'swrast/s_linetemp.h',
+  'swrast/s_logic.c',
+  'swrast/s_logic.h',
+  'swrast/s_masking.c',
+  'swrast/s_masking.h',
+  'swrast/s_points.c',
+  'swrast/s_points.h',
+  'swrast/s_renderbuffer.c',
+  'swrast/s_renderbuffer.h',
+  'swrast/s_span.c',
+  'swrast/s_span.h',
+  'swrast/s_stencil.c',
+  'swrast/s_stencil.h',
+  'swrast/s_texcombine.c',
+  'swrast/s_texcombine.h',
+  'swrast/s_texfetch.c',
+  'swrast/s_texfetch.h',
+  'swrast/s_texfetch_tmp.h',
+  'swrast/s_texfilter.c',
+  'swrast/s_texfilter.h',
+  'swrast/s_texrender.c',
+  'swrast/s_texture.c',
+  'swrast/s_triangle.c',
+  'swrast/s_triangle.h',
+  'swrast/s_tritemp.h',
+  'swrast/swrast.h',
+  'swrast/s_zoom.c',
+  'swrast/s_zoom.h',
+  'swrast_setup/ss_context.c',
+  'swrast_setup/ss_context.h',
+  'swrast_setup/ss_triangle.c',
+  'swrast_setup/ss_triangle.h',
+  'drivers/common/driverfuncs.c',
+  'drivers/common/driverfuncs.h',
+  'drivers/common/meta_blit.c',
+  'drivers/common/meta_generate_mipmap.c',
+  'drivers/common/meta_tex_subimage.c',
+  'drivers/common/meta.c',
+  'drivers/common/meta.h',
+  'x86/common_x86.c',
+  'x86/x86_xform.c',
+  'x86/3dnow.c',
+  'x86/sse.c',
+  'x86/rtasm/x86sse.c',
+  'x86/rtasm/x86sse.h',
+  'sparc/sparc.c',
+  'x86-64/x86-64.c',
+)
+
+# TODO: sse41
+libmesa_sse41 = []
+
+matypes_h = []
+if with_asm_arch == 'x86' or with_asm_arch == 'x86_64'
+  gen_matypes = executable(
+    'gen_matypes',
+    'x86/gen_matypes.c',
+    c_args : [c_vis_args, c_msvc_compat_args],
+    include_directories : inc_common,
+  )
+  matypes_h = custom_target(
+    'matypes.h',
+    output : 'matypes.h',
+    command : [gen_matypes],
+    capture : true,
+  )
+endif
+if with_asm_arch == 'x86'
+  files_libmesa_common += files(
+    'x86/assyntax.h',
+    'x86/clip_args.h',
+    'x86/norm_args.h',
+    'x86/xform_args.h',
+    'x86/common_x86_asm.S',
+    'x86/common_x86_asm.h',
+    'x86/common_x86_features.h',
+    'x86/x86_xform.h',
+    'x86/x86_xform2.S',
+    'x86/x86_xform3.S',
+    'x86/x86_xform4.S',
+    'x86/x86_cliptest.S',
+    'x86/mmx.h',
+    'x86/mmx_blend.S',
+    'x86/mmx_blendtmp.h',
+    'x86/3dnow.h',
+    'x86/3dnow_xform1.S',
+    'x86/3dnow_xform2.S',
+    'x86/3dnow_xform3.S',
+    'x86/3dnow_xform4.S',
+    'x86/sse.h',
+    'x86/sse_xform1.S',
+    'x86/sse_xform2.S',
+    'x86/sse_xform3.S',
+    'x86/sse_xform4.S',
+    'x86/sse_normal.S',
+    'x86/read_rgba_span_x86.S',
+  )
+elif with_asm_arch == 'x86_64'
+  files_libmesa_common += files('x86-64/x86-64.h', 'x86-64/xform4.S')
+endif
+# TODO: sparc
+
+format_fallback_c = custom_target(
+  'format_fallback.c',
+  input : ['main/format_fallback.py', 'main/formats.csv'],
+  output : 'format_fallback.c',
+  command : [prog_python2, '@INPUT0@', '@INPUT1@', '@OUTPUT@'],
+  depend_files : files('main/format_parser.py'),
+)
+
+get_hash_h = custom_target(
+  'get_hash.h',
+  input : ['main/get_hash_generator.py', gl_and_es_api_files],
+  output : 'get_hash.h',
+  command : [prog_python2, '@INPUT0@', '-f', '@INPUT1@'],
+  depend_files : files('main/get_hash_params.py'),
+  capture : true,
+)
+
+foreach x : [['format_info.h', 'format_info.py'],
+             ['format_pack.c', 'format_pack.py'],
+             ['format_unpack.c', 'format_unpack.py']]
+  files_libmesa_common += custom_target(
+    x[0],
+    input : ['main/@0@'.format(x[1]), 'main/formats.csv'],
+    output : x[0],
+    command : [prog_python2, '@INPUT0@', '@INPUT1@'],
+    depend_files : files('main/format_parser.py'),
+    capture : true,
+  )
+endforeach
+
+files_libmesa_common += [
+  mesa_lex,
+  program_parse_tab,
+  main_api_exec_c,
+  main_enums_c,
+  format_fallback_c,
+  get_hash_h,
+  main_marshal_generated_c,
+  main_marshal_generated_h,
+  main_dispatch_h,
+  ir_expression_operation_h,
+  nir_opcodes_h,
+  main_remap_helper_h,
+  matypes_h,
+  sha1_h,
+]
+
+libmesa_classic = static_library(
+  'mesa_classic',
+  [files_libmesa_common, files_libmesa_classic],
+  c_args : [c_vis_args, c_msvc_compat_args],
+  cpp_args : [cpp_vis_args, cpp_msvc_compat_args],
+  include_directories : [inc_common, include_directories('main')],
+  link_with : [libglsl, libmesa_sse41],
+  build_by_default : false,
+)
+
+# TODO: gallium
+
+subdir('drivers/dri')
diff --git a/src/compiler/glsl/meson.build b/src/mesa/program/meson.build
similarity index 74%
copy from src/compiler/glsl/meson.build
copy to src/mesa/program/meson.build
index 0a2537d4981..5f3325ff53c 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/mesa/program/meson.build
@@ -18,12 +18,16 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
+mesa_lex = custom_target(
+  'mesa_lex',
+  input : 'program_lexer.l',
+  output : 'lex.yy.c',
+  command : [prog_flex, '-o', '@OUTPUT@', '@INPUT@'],
+)
 
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
-  capture : true,
+program_parse_tab = custom_target(
+  'program_parse_tab.[ch]',
+  input : 'program_parse.y',
+  output : ['program_parse.tab.c', 'program_parse.tab.h'],
+  command : [prog_bison, '-o', '@OUTPUT0@', '--defines=@OUTPUT1@', '@INPUT@'],
 )
diff --git a/src/meson.build b/src/meson.build
index 76ff497e565..8e0860bb5a5 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -18,19 +18,31 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: libglsl_util
-
-# TODO: git_sha. There's a meson builtin for this
-
 inc_common = include_directories(
   '../include', '.', 'mapi', 'mesa', 'gallium/include', 'gallium/auxiliary')
 inc_mesa = include_directories('mesa')
 inc_mapi = include_directories('mapi')
+inc_src = include_directories('.')
+
+libglsl_util = static_library(
+  'glsl_util',
+  files('mesa/main/extensions_table.c', 'mesa/main/imports.c',
+        'mesa/program/prog_parameter.c', 'mesa/program/symbol_table.c',
+        'mesa/program/dummy_errors.c'),
+  include_directories : [inc_common],
+  c_args : [c_vis_args],
+  build_by_default : false,
+)
+
+sha1_h = vcs_tag(
+  input : 'git_sha1.h.in',
+  output : 'git_sha1.h',
+)
 
 subdir('gtest')
 subdir('util')
-#subdir('mapi/glapi/gen')
-# TODO: mapi
+subdir('mapi/glapi/gen')
+subdir('mapi')
 # TODO: opengl
 # TODO: glx
 # TODO: osmesa
@@ -40,7 +52,7 @@ subdir('vulkan')
 subdir('amd')
 subdir('intel')
 # TODO: vc4
-# TODO: opengl_common
+subdir('mesa')
 # TODO: dri_glx
 # TODO: gbm
 # TODO: egl
diff --git a/src/util/meson.build b/src/util/meson.build
index 7a619dedb18..c9cb3e861e9 100644
--- a/src/util/meson.build
+++ b/src/util/meson.build
@@ -18,9 +18,10 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: subdir('xmlpool')
 inc_util = include_directories('.')
 
+subdir('xmlpool')
+
 files_mesa_util = files(
   'bitscan.c',
   'bitscan.h',
diff --git a/src/compiler/glsl/meson.build b/src/util/xmlpool/meson.build
similarity index 80%
copy from src/compiler/glsl/meson.build
copy to src/util/xmlpool/meson.build
index 0a2537d4981..97693fac8c4 100644
--- a/src/compiler/glsl/meson.build
+++ b/src/util/xmlpool/meson.build
@@ -18,12 +18,11 @@
 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
-# TODO: the rest of this file
-
-ir_expression_operation_h = custom_target(
-  'ir_expression_operation.h',
-  input : 'ir_expression_operation.py',
-  output : 'ir_expression_operation.h',
-  command : [prog_python2, '@INPUT@', 'enum'],
+xmlpool_options_h = custom_target(
+  'xmlpool_options.h',
+  input : ['gen_xmlpool.py', 't_options.h'],
+  output : 'options.h',
+  command : [prog_python2, '@INPUT@', meson.current_source_dir()],
   capture : true,
+  depend_files : files('ca.po', 'es.po', 'de.po', 'nl.po', 'sv.po', 'fr.po'),
 )
-- 
2.14.1



More information about the mesa-dev mailing list