148becaf0Smrg# Copyright © 2020 Intel Corporation
248becaf0Smrg
348becaf0Smrg# Permission is hereby granted, free of charge, to any person obtaining a copy
448becaf0Smrg# of this software and associated documentation files (the "Software"), to deal
548becaf0Smrg# in the Software without restriction, including without limitation the rights
648becaf0Smrg# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
748becaf0Smrg# copies of the Software, and to permit persons to whom the Software is
848becaf0Smrg# furnished to do so, subject to the following conditions:
948becaf0Smrg
1048becaf0Smrg# The above copyright notice and this permission notice shall be included in
1148becaf0Smrg# all copies or substantial portions of the Software.
1248becaf0Smrg
1348becaf0Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1448becaf0Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1548becaf0Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1648becaf0Smrg# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1748becaf0Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1848becaf0Smrg# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1948becaf0Smrg# SOFTWARE.
2048becaf0Smrg
2148becaf0Smrghost = host_machine.system()
2248becaf0Smrg_pci_access_host_files = []
2348becaf0Smrgif host == 'linux'
2448becaf0Smrg  _pci_access_host_files += ['linux_sysfs.c', 'linux_devmem.c', 'common_vgaarb.c']
2548becaf0Smrgelif host == 'freebsd'
2648becaf0Smrg  _pci_access_host_files += ['freebsd_pci.c', 'common_vgaarb_stub.c']
2748becaf0Smrgelif host == 'netbsd'
2848becaf0Smrg  _pci_access_host_files += ['netbsd_pci.c', 'common_vgaarb_stub.c']
2948becaf0Smrgelif host == 'openbsd'
3048becaf0Smrg  _pci_access_host_files += ['openbsd_pci.c']  # VGA arbiter code is in netbsd_pci.c
3148becaf0Smrgelif host == 'cygwin'
3248becaf0Smrg  _pci_access_host_files += ['x86_pci.c', 'common_vgaarb_stub.c']
3348becaf0Smrgelif host == 'sunos'
3448becaf0Smrg  _pci_access_host_files += ['solx_devfs.c', 'common_vgaarb_stub.c']
3548becaf0Smrgelif host == 'gnu'
3648becaf0Smrg  _pci_access_host_files += ['hurd_pci.c', 'x86_pci.c', 'common_vgaarb_stub.c']
3748becaf0Smrgendif
3848becaf0Smrg
3948becaf0Smrginc_src = include_directories('.')
4048becaf0Smrg
415ad99bdfSmrglibpciaccess = library(
4248becaf0Smrg  'pciaccess',
4348becaf0Smrg  [
4448becaf0Smrg    'common_bridge.c',
4548becaf0Smrg    'common_iterator.c',
4648becaf0Smrg    'common_init.c',
4748becaf0Smrg    'common_interface.c',
4848becaf0Smrg    'common_io.c',
4948becaf0Smrg    'common_capability.c',
5048becaf0Smrg    'common_device_name.c',
5148becaf0Smrg    'common_map.c',
5248becaf0Smrg    _pci_access_host_files,
5348becaf0Smrg    config_h,
5448becaf0Smrg  ],
5548becaf0Smrg  include_directories : inc_include,
5648becaf0Smrg  dependencies : [dep_zlib, extra_libs],
5748becaf0Smrg  version : '0.11.1',
5848becaf0Smrg  install : true,
5948becaf0Smrg)
6048becaf0Smrg
6148becaf0Smrgdep_pciaccess = declare_dependency(
6248becaf0Smrg  link_with : libpciaccess,
6348becaf0Smrg  include_directories : [include_directories('.'), inc_include]
6448becaf0Smrg)
6548becaf0Smrg
6648becaf0Smrgif meson.version().version_compare('>= 0.54.0')
6748becaf0Smrg  meson.override_dependency('pciaccess', dep_pciaccess)
6848becaf0Smrgendif
69