101e04c3fSmrg# Copyright © 2017 Intel Corporation
201e04c3fSmrg
301e04c3fSmrg# Permission is hereby granted, free of charge, to any person obtaining a copy
401e04c3fSmrg# of this software and associated documentation files (the "Software"), to deal
501e04c3fSmrg# in the Software without restriction, including without limitation the rights
601e04c3fSmrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
701e04c3fSmrg# copies of the Software, and to permit persons to whom the Software is
801e04c3fSmrg# furnished to do so, subject to the following conditions:
901e04c3fSmrg
1001e04c3fSmrg# The above copyright notice and this permission notice shall be included in
1101e04c3fSmrg# all copies or substantial portions of the Software.
1201e04c3fSmrg
1301e04c3fSmrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1401e04c3fSmrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1501e04c3fSmrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1601e04c3fSmrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1701e04c3fSmrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1801e04c3fSmrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1901e04c3fSmrg# SOFTWARE.
2001e04c3fSmrg
2101e04c3fSmrgsubdir('gen')
2201e04c3fSmrg
2301e04c3fSmrginc_glapi = include_directories('.')
2401e04c3fSmrg
2501e04c3fSmrgstatic_glapi_files = []
2601e04c3fSmrgstatic_glapi_args = []
2701e04c3fSmrg
287ec681f3Smrgif with_dri and ['apple', 'windows'].contains(with_dri_platform)
2901e04c3fSmrg  static_glapi_files += [glapi_gentable_c, glapitable_h]
3001e04c3fSmrgendif
3101e04c3fSmrg
3201e04c3fSmrgif with_shared_glapi
3301e04c3fSmrg  static_glapi_files += files(
3401e04c3fSmrg    '../entry.c',
3501e04c3fSmrg    '../entry.h',
3601e04c3fSmrg    '../entry_x86-64_tls.h',
3701e04c3fSmrg    '../entry_x86_tls.h',
3801e04c3fSmrg    '../entry_x86_tsd.h',
3901e04c3fSmrg    '../entry_ppc64le_tls.h',
4001e04c3fSmrg    '../entry_ppc64le_tsd.h',
4101e04c3fSmrg    '../mapi_tmp.h',
4201e04c3fSmrg  )
4301e04c3fSmrg  static_glapi_files += glapi_mapi_tmp_h
4401e04c3fSmrg  static_glapi_args += [
4501e04c3fSmrg    '-DMAPI_MODE_BRIDGE',
4601e04c3fSmrg    '-DMAPI_ABI_HEADER="@0@"'.format(glapi_mapi_tmp_h.full_path()),
479f464c52Smaya    gcc_lto_quirk,
4801e04c3fSmrg  ]
497ec681f3Smrg  if with_platform_windows
507ec681f3Smrg    static_glapi_args += ['-D_GDI32_']
517ec681f3Smrg  endif
5201e04c3fSmrgelse
5301e04c3fSmrg  static_glapi_args += '-DMAPI_MODE_UTIL'
547ec681f3Smrg  if with_platform_windows
557ec681f3Smrg    static_glapi_args += ['-D_GDI32_', '-DBUILD_GL32', '-DKHRONOS_DLL_EXPORTS', '-D_GLAPI_NO_EXPORTS']
567ec681f3Smrg  endif
5701e04c3fSmrg  static_glapi_files += files(
5801e04c3fSmrg    'glapi_dispatch.c',
5901e04c3fSmrg    'glapi_entrypoint.c',
6001e04c3fSmrg    'glapi_getproc.c',
6101e04c3fSmrg    'glapi_nop.c',
6201e04c3fSmrg    'glapi.c',
6301e04c3fSmrg    'glapi.h',
6401e04c3fSmrg    'glapi_priv.h',
6501e04c3fSmrg  )
6601e04c3fSmrg  static_glapi_files += files_mapi_util
6701e04c3fSmrg  static_glapi_files += [
6801e04c3fSmrg    glapitable_h, glapi_mapi_tmp_h, glprocs_h, glapitemp_h,
6901e04c3fSmrg  ]
7001e04c3fSmrg  if with_asm_arch == 'x86'
7101e04c3fSmrg    static_glapi_files += glapi_x86_s
7201e04c3fSmrg  elif with_asm_arch == 'x86_64'
7301e04c3fSmrg    static_glapi_files += glapi_x86_64_s
7401e04c3fSmrg  elif with_asm_arch == 'sparc'
7501e04c3fSmrg    static_glapi_files += glapi_sparc_s
7601e04c3fSmrg  endif
7701e04c3fSmrgendif
7801e04c3fSmrg
7901e04c3fSmrglibglapi_static = static_library(
8001e04c3fSmrg  'glapi_static',
8101e04c3fSmrg  static_glapi_files,
8201e04c3fSmrg  include_directories : [inc_mesa, inc_include, inc_src, inc_mapi],
8301e04c3fSmrg  c_args : [c_msvc_compat_args, static_glapi_args],
8401e04c3fSmrg  dependencies : [dep_thread, dep_selinux],
8501e04c3fSmrg  build_by_default : false,
8601e04c3fSmrg)
8701e04c3fSmrg
887ec681f3Smrg# TODO: this test doesn't compile on windows with mingw or msvc due to
897ec681f3Smrg# undefined symbols from libglapi_static, but that should be fixable.
907ec681f3Smrgif with_any_opengl and not with_shared_glapi and with_tests and not with_platform_windows
9101e04c3fSmrg  test(
9201e04c3fSmrg    'glapi_static_check_table',
9301e04c3fSmrg    executable(
9401e04c3fSmrg      'glapi_static_check_table',
9501e04c3fSmrg      ['tests/check_table.cpp', glapitable_h],
9601e04c3fSmrg      include_directories : [inc_include, inc_src, inc_mesa, inc_mapi],
9701e04c3fSmrg      link_with : [libglapi_static],
9801e04c3fSmrg      dependencies : [idep_gtest, dep_thread],
999f464c52Smaya    ),
1009f464c52Smaya    suite : ['mapi'],
10101e04c3fSmrg  )
10201e04c3fSmrgendif
103