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
2101e04c3fSmrgosmesa_link_with = []
2201e04c3fSmrgosmesa_link_args = []
2301e04c3fSmrgosmesa_link_deps = []
2401e04c3fSmrg
2501e04c3fSmrgif with_shared_glapi
2601e04c3fSmrg  osmesa_link_with += libglapi
2701e04c3fSmrgendif
2801e04c3fSmrgif with_ld_version_script
2901e04c3fSmrg  osmesa_link_args += [
3001e04c3fSmrg    '-Wl,--version-script', join_paths(meson.current_source_dir(), 'osmesa.sym')
3101e04c3fSmrg  ]
3201e04c3fSmrg  osmesa_link_deps += files('osmesa.sym')
3301e04c3fSmrgendif
3401e04c3fSmrg
357ec681f3Smrgif cc.get_id() == 'gcc' and host_machine.cpu_family() != 'x86_64'
367ec681f3Smrg  osmesa_def = 'osmesa.mingw.def'
377ec681f3Smrgelse
387ec681f3Smrg  osmesa_def = 'osmesa.def'
397ec681f3Smrgendif
407ec681f3Smrg
4101e04c3fSmrglibosmesa = shared_library(
4201e04c3fSmrg  osmesa_lib_name,
4301e04c3fSmrg  'target.c',
447ec681f3Smrg  gnu_symbol_visibility : 'hidden',
4501e04c3fSmrg  link_args : [ld_args_gc_sections, osmesa_link_args],
467ec681f3Smrg  vs_module_defs : osmesa_def,
4701e04c3fSmrg  include_directories : [
4801e04c3fSmrg    inc_include, inc_src, inc_gallium, inc_gallium_aux, inc_gallium_winsys,
4901e04c3fSmrg    inc_gallium_drivers,
5001e04c3fSmrg  ],
5101e04c3fSmrg  link_depends : osmesa_link_deps,
529f464c52Smaya  link_whole : [libosmesa_st, libglapi_static],
5301e04c3fSmrg  link_with : [
549f464c52Smaya    libmesa_gallium, libgallium, libws_null, osmesa_link_with,
5501e04c3fSmrg  ],
5601e04c3fSmrg  dependencies : [
577ec681f3Smrg    dep_ws2_32, dep_selinux, dep_thread, dep_clock, dep_unwind,
5801e04c3fSmrg    driver_swrast, driver_swr,
5901e04c3fSmrg  ],
607ec681f3Smrg  name_prefix : host_machine.system() == 'windows' ? '' : 'lib',  # otherwise mingw will create libosmesa.dll
617ec681f3Smrg  soversion : host_machine.system() == 'windows' ? '' : '8',
6201e04c3fSmrg  version : '8.0.0',
637ec681f3Smrg  darwin_versions : '9.0.0',
6401e04c3fSmrg  install : true,
6501e04c3fSmrg)
6601e04c3fSmrg
6701e04c3fSmrgpkg.generate(
6801e04c3fSmrg  name : 'osmesa',
6901e04c3fSmrg  description : 'Mesa Off-screen Rendering Library',
7001e04c3fSmrg  version : '8.0.0',
7101e04c3fSmrg  libraries : libosmesa,
7201e04c3fSmrg  libraries_private : gl_priv_libs,
7301e04c3fSmrg)
747ec681f3Smrg
757ec681f3Smrgif with_tests
767ec681f3Smrg  test('osmesa-render',
777ec681f3Smrg    executable(
787ec681f3Smrg      'osmesa-render',
797ec681f3Smrg      'test-render.cpp',
807ec681f3Smrg      include_directories : [inc_include, inc_src, inc_mapi, inc_mesa, inc_gallium, inc_gallium_aux],
817ec681f3Smrg      link_with: libosmesa,
827ec681f3Smrg      dependencies : [idep_gtest],
837ec681f3Smrg    ),
847ec681f3Smrg    suite: 'gallium'
857ec681f3Smrg  )
867ec681f3Smrgendif
87