meson.build revision 5ad99bdf
1# Copyright © 2018-2020 Intel Corporation 2 3# Permission is hereby granted, free of charge, to any person obtaining a copy 4# of this software and associated documentation files (the "Software"), to deal 5# in the Software without restriction, including without limitation the rights 6# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7# copies of the Software, and to permit persons to whom the Software is 8# furnished to do so, subject to the following conditions: 9 10# The above copyright notice and this permission notice shall be included in 11# all copies or substantial portions of the Software. 12 13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 19# SOFTWARE. 20 21project( 22 'libpciaccess', 23 ['c'], 24 version : '0.18.1', 25 license : 'MIT', 26 meson_version : '>= 0.48.0', 27 default_options : ['buildtype=debugoptimized'], 28) 29 30c = meson.get_compiler('c') 31 32add_project_arguments( 33 c.get_supported_arguments( 34 '-Wpointer-arith', 35 '-Wmissing-declarations', 36 '-Wformat=2', 37 '-Wstrict-prototypes', 38 '-Wmissing-prototypes', 39 '-Wnested-externs', 40 '-Wbad-function-cast', 41 '-Wold-style-definition', 42 '-Wdeclaration-after-statement', 43 '-Wunused', 44 '-Wuninitialized', 45 '-Wshadow', 46 '-Wmissing-noreturn', 47 '-Wmissing-format-attribute', 48 '-Wredundant-decls', 49 '-Wlogical-op', 50 '-Werror=implicit', 51 '-Werror=nonnull', 52 '-Werror=init-self', 53 '-Werror=main', 54 '-Werror=missing-braces', 55 '-Werror=sequence-point', 56 '-Werror=return-type', 57 '-Werror=trigraphs', 58 '-Werror=array-bounds', 59 '-Werror=write-strings', 60 '-Werror=address', 61 '-Werror=int-to-pointer-cast', 62 ), 63 language : 'c' 64) 65 66config = configuration_data() 67 68config.set_quoted( 69 'PCIIDS_PATH', 70 join_paths(get_option('prefix'), get_option('datadir'), get_option('pci-ids')) 71) 72if get_option('linux-rom-fallback') 73 config.set('LINUX_ROM', 1) 74endif 75 76dep_zlib = dependency('zlib', required : get_option('zlib')) 77if dep_zlib.found() 78 config.set('HAVE_ZLIB', 1) 79endif 80 81extra_libs = [] 82if host_machine.system() == 'netbsd' 83 extra_libs += c.find_library('pci') 84 if host_machine.cpu_family() == 'x86' 85 extra_libs += c.find_library('i386') 86 elif host_machine.cpu_family() == 'x86_64' 87 extra_libs += c.find_library('x86_64') 88 elif host_machine.cpu_family() == 'alpha' # TODO 89 extra_libs += c.find_library('alpha') 90 endif 91elif host_machine.system() == 'sunos' 92 extra_libs += c.find_library('devinfo') 93endif 94 95if host_machine.system() == 'netbsd' 96 _prefix = '' 97 if c.check_header('machine/sysarch.h') 98 _prefix = ''' 99 #include <sys/types.h> 100 #include <machine/sysarch.h> 101 ''' 102 endif 103 104 if c.check_header('machine/mtrr.h', prefix : _prefix) 105 config.set('HAVE_MTRR', 1) 106 endif 107elif c.check_header('asm/mtrr.h') 108 config.set('HAVE_MTRR', 1) 109endif 110 111foreach h : ['err.h', 'stdint.h', 'string.h', 'strings.h', 'inttypes.h'] 112 if c.check_header(h) 113 config.set('HAVE_' + h.to_upper().underscorify(), 1) 114 endif 115endforeach 116 117config_h = configure_file( 118 configuration : config, 119 output : 'config.h', 120) 121add_project_arguments('-DHAVE_CONFIG_H', language : ['c']) 122 123install_headers('include/pciaccess.h') 124inc_include = include_directories('.', 'include') 125 126subdir('src') 127subdir('scanpci') 128subdir('man') 129 130pkg = import('pkgconfig') 131pkg.generate( 132 libpciaccess, 133 description : 'Library providing generic access to the PCI bus and devices', 134) 135