OSDN Git Service

Android: update CleanSpec.mk
[android-x86/external-libdrm.git] / meson.build
index c7245dd..fc02f55 100644 (file)
@@ -21,7 +21,7 @@
 project(
   'libdrm',
   ['c'],
-  version : '2.4.89',
+  version : '2.4.100',
   license : 'MIT',
   meson_version : '>= 0.43',
   default_options : ['buildtype=debugoptimized', 'c_std=gnu99'],
@@ -29,16 +29,13 @@ project(
 
 pkg = import('pkgconfig')
 
-with_udev = get_option('udev')
+config = configuration_data()
+
+config.set10('UDEV', get_option('udev'))
 with_freedreno_kgsl = get_option('freedreno-kgsl')
 with_install_tests = get_option('install-test-programs')
-with_cairo_tests = get_option('cairo-tests')
-with_valgrind = get_option('valgrind')
-
-config = configuration_data()
 
-# TODO: openbsd is guess, the others are correct
-if ['freebsd', 'dragonfly', 'netbsd', 'openbsd'].contains(host_machine.system())
+if ['freebsd', 'dragonfly', 'netbsd'].contains(host_machine.system())
   dep_pthread_stubs = dependency('pthread-stubs', version : '>= 0.4')
 else
   dep_pthread_stubs = []
@@ -51,6 +48,7 @@ cc = meson.get_compiler('c')
 intel_atomics = false
 lib_atomics = false
 
+dep_atomic_ops = dependency('atomic_ops', required : false)
 if cc.compiles('''
     int atomic_add(int *i) { return __sync_add_and_fetch (i, 1); }
     int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
@@ -58,7 +56,8 @@ if cc.compiles('''
     name : 'Intel Atomics')
   intel_atomics = true
   with_atomics = true
-elif cc.has_header('atomic_ops.h')
+  dep_atomic_ops = []
+elif dep_atomic_ops.found()
   lib_atomics = true
   with_atomics = true
 elif cc.has_function('atomic_cas_uint')
@@ -158,7 +157,7 @@ if _vc4 != 'false'
   with_vc4 = _vc4 == 'true' or ['arm', 'aarch64'].contains(host_machine.cpu_family())
 endif
 
-# XXX: Aparently only freebsd and dragonfly bsd actually need this (and
+# XXX: Apparently only freebsd and dragonfly bsd actually need this (and
 # gnu/kfreebsd), not openbsd and netbsd
 with_libkms = false
 _libkms = get_option('libkms')
@@ -166,13 +165,6 @@ if _libkms != 'false'
   with_libkms = _libkms == 'true' or ['linux', 'freebsd', 'dragonfly'].contains(host_machine.system())
 endif
 
-if with_udev
-  dep_udev = dependency('udev')
-  config.set10('UDEV', true)
-else
-  dep_udev = []
-endif
-
 # Among others FreeBSD does not have a separate dl library.
 if not cc.has_function('dlsym')
   dep_dl = cc.find_library('dl', required : with_nouveau)
@@ -187,28 +179,32 @@ else
   dep_rt = []
 endif
 dep_m = cc.find_library('m', required : false)
-if cc.has_header('sys/sysctl.h')
-  config.set10('HAVE_SYS_SYSCTL_H', true)
-endif
-if cc.has_header('sys/select.h')
-  config.set10('HAVE_SYS_SELECT_H', true)
-endif
-if cc.has_header_symbol('sys/sysmacros.h', 'major')
+# From Niclas Zeising:
+# FreeBSD requires sys/types.h for sys/sysctl.h, add it as part of the
+# includes when checking for headers.
+foreach header : ['sys/sysctl.h', 'sys/select.h', 'alloca.h']
+  config.set('HAVE_' + header.underscorify().to_upper(),
+    cc.compiles('#include <sys/types.h>\n#include <@0@>'.format(header), name : '@0@ works'.format(header)))
+endforeach
+if (cc.has_header_symbol('sys/sysmacros.h', 'major') and
+  cc.has_header_symbol('sys/sysmacros.h', 'minor') and
+  cc.has_header_symbol('sys/sysmacros.h', 'makedev'))
   config.set10('MAJOR_IN_SYSMACROS', true)
-elif cc.has_header_symbol('sys/mkdev.h', 'major')
-  config.set10('MAJOR_IN_MKDEV', true)
 endif
-if cc.has_function('open_memstream')
-  config.set10('HAVE_OPEN_MEMSTREAM', true)
+if (cc.has_header_symbol('sys/mkdev.h', 'major') and
+  cc.has_header_symbol('sys/mkdev.h', 'minor') and
+  cc.has_header_symbol('sys/mkdev.h', 'makedev'))
+  config.set10('MAJOR_IN_MKDEV', true)
 endif
+config.set10('HAVE_OPEN_MEMSTREAM', cc.has_function('open_memstream'))
 
 warn_c_args = []
-foreach a : ['-Wall', '-Wextra', '-Wsign-compare', 
-             '-Werror-implicit-function-declaration', '-Wpointer-arith',
+foreach a : ['-Wall', '-Wextra', '-Wsign-compare', '-Werror=undef',
+             '-Werror=implicit-function-declaration', '-Wpointer-arith',
              '-Wwrite-strings', '-Wstrict-prototypes', '-Wmissing-prototypes',
              '-Wmissing-declarations', '-Wnested-externs', '-Wpacked',
-             '-Wswitch-enum', '-Wmissing-format-attribute', 
-             '-Wstrict-aliasing=2', '-Winit-self', '-Winline', '-Wshadow', 
+             '-Wswitch-enum', '-Wmissing-format-attribute',
+             '-Wstrict-aliasing=2', '-Winit-self', '-Winline', '-Wshadow',
              '-Wdeclaration-after-statement', '-Wold-style-definition']
   if cc.has_argument(a)
     warn_c_args += a
@@ -216,18 +212,35 @@ foreach a : ['-Wall', '-Wextra', '-Wsign-compare',
 endforeach
 # GCC will never error for -Wno-*, so check for -W* then add -Wno-* to the list
 # of options
-foreach a : ['unused-parameter', 'attributes', 'long-long', 
+foreach a : ['unused-parameter', 'attributes', 'long-long',
              'missing-field-initializers']
   if cc.has_argument('-W@0@'.format(a))
     warn_c_args += '-Wno-@0@'.format(a)
   endif
 endforeach
 
+# all c args:
+libdrm_c_args = warn_c_args + ['-fvisibility=hidden']
+
 
 dep_pciaccess = dependency('pciaccess', version : '>= 0.10', required : with_intel)
 dep_cunit = dependency('cunit', version : '>= 2.1', required : false)
-dep_cairo = dependency('cairo', required : with_cairo_tests == 'true')
-dep_valgrind = dependency('valgrind', required : with_valgrind == 'true')
+_cairo_tests = get_option('cairo-tests')
+if _cairo_tests != 'false'
+  dep_cairo = dependency('cairo', required : _cairo_tests == 'true')
+  with_cairo_tests = dep_cairo.found()
+else
+  dep_cairo = []
+  with_cairo_tests = false
+endif
+_valgrind = get_option('valgrind')
+if _valgrind != 'false'
+  dep_valgrind = dependency('valgrind', required : _valgrind == 'true')
+  with_valgrind = dep_valgrind.found()
+else
+  dep_valgrind = []
+  with_valgrind = false
+endif
 
 with_man_pages = get_option('man-pages')
 prog_xslt = find_program('xsltproc', required : with_man_pages == 'true')
@@ -243,38 +256,32 @@ if prog_xslt.found()
 endif
 with_man_pages = with_man_pages != 'false' and prog_xslt.found() and prog_sed.found()
 
-# Used for tets
-prog_bash = find_program('bash')
-
-if cc.compiles('''int foo_hidden(void) __attribute__((visibility(("hidden"))));''',
-               name : 'compiler supports __attribute__(("hidden"))')
-  config.set10('HAVE_VISIBILITY', true)
-endif
+config.set10('HAVE_VISIBILITY',
+  cc.compiles('''int foo_hidden(void) __attribute__((visibility(("hidden"))));''',
+              name : 'compiler supports __attribute__(("hidden"))'))
 
-foreach t : [[with_intel, 'INTEL'], [with_vmwgfx, 'VMWGFX'],
-             [with_nouveau, 'NOUVEAU'],
+foreach t : [
              [with_exynos, 'EXYNOS'],
-             [with_vc4, 'VC4'],
              [with_freedreno_kgsl, 'FREEDRENO_KGSL'],
-             [with_radeon, 'RADEON']]
+             [with_intel, 'INTEL'],
+             [with_nouveau, 'NOUVEAU'],
+             [with_radeon, 'RADEON'],
+             [with_vc4, 'VC4'],
+             [with_vmwgfx, 'VMWGFX'],
+             [with_cairo_tests, 'CAIRO'],
+             [with_valgrind, 'VALGRIND'],
+            ]
   config.set10('HAVE_@0@'.format(t[1]), t[0])
 endforeach
 if with_freedreno_kgsl and not with_freedreno
   error('cannot enable freedreno-kgsl without freedreno support')
 endif
-if dep_cairo.found()
-  config.set10('HAVE_CAIRO', true)
-endif
-if dep_valgrind.found()
-  config.set10('HAVE_VALGRIND', true)
-endif
-
 config.set10('_GNU_SOURCE', true)
 config_file = configure_file(
   configuration : config,
   output : 'config.h',
 )
-add_project_arguments('-DHAVE_CONFIG_H', language : 'c')
+add_project_arguments('-include', 'config.h', language : 'c')
 
 inc_root = include_directories('.')
 inc_drm = include_directories('include/drm')
@@ -287,8 +294,8 @@ libdrm = shared_library(
    ),
    config_file,
   ],
-  c_args : warn_c_args,
-  dependencies : [dep_udev, dep_valgrind, dep_rt, dep_m],
+  c_args : libdrm_c_args,
+  dependencies : [dep_valgrind, dep_rt, dep_m],
   include_directories : inc_drm,
   version : '2.4.0',
   install : true,
@@ -296,7 +303,7 @@ libdrm = shared_library(
 
 ext_libdrm = declare_dependency(
   link_with : libdrm,
-  include_directories : inc_drm,
+  include_directories : [inc_root, inc_drm],
 )
 
 install_headers('libsync.h', 'xf86drm.h', 'xf86drmMode.h')
@@ -304,10 +311,11 @@ install_headers(
   'include/drm/drm.h', 'include/drm/drm_fourcc.h', 'include/drm/drm_mode.h',
   'include/drm/drm_sarea.h', 'include/drm/i915_drm.h',
   'include/drm/mach64_drm.h', 'include/drm/mga_drm.h',
-  'include/drm/nouveau_drm.h', 'include/drm/qxl_drm.h',
-  'include/drm/r128_drm.h', 'include/drm/radeon_drm.h',
-  'include/drm/amdgpu_drm.h', 'include/drm/savage_drm.h',
-  'include/drm/sis_drm.h', 'include/drm/tegra_drm.h', 'include/drm/vc4_drm.h',
+  'include/drm/msm_drm.h', 'include/drm/nouveau_drm.h',
+  'include/drm/qxl_drm.h', 'include/drm/r128_drm.h',
+  'include/drm/radeon_drm.h', 'include/drm/amdgpu_drm.h',
+  'include/drm/savage_drm.h', 'include/drm/sis_drm.h',
+  'include/drm/tegra_drm.h', 'include/drm/vc4_drm.h',
   'include/drm/via_drm.h', 'include/drm/virtgpu_drm.h',
   subdir : 'libdrm',
 )
@@ -322,7 +330,10 @@ pkg.generate(
   version : meson.project_version(),
   description : 'Userspace interface to kernel DRM services',
 )
+
+env_test = environment()
+env_test.set('NM', find_program('nm').path())
+
 if with_libkms
   subdir('libkms')
 endif
@@ -361,3 +372,20 @@ if with_man_pages
 endif
 subdir('data')
 subdir('tests')
+
+message('')
+message('@0@ will be compiled with:'.format(meson.project_name()))
+message('')
+message('  libkms         @0@'.format(with_libkms))
+message('  Intel API      @0@'.format(with_intel))
+message('  vmwgfx API     @0@'.format(with_vmwgfx))
+message('  Radeon API     @0@'.format(with_radeon))
+message('  AMDGPU API     @0@'.format(with_amdgpu))
+message('  Nouveau API    @0@'.format(with_nouveau))
+message('  OMAP API       @0@'.format(with_omap))
+message('  EXYNOS API     @0@'.format(with_exynos))
+message('  Freedreno API  @0@ (kgsl: @1@)'.format(with_freedreno, with_freedreno_kgsl))
+message('  Tegra API      @0@'.format(with_tegra))
+message('  VC4 API        @0@'.format(with_vc4))
+message('  Etnaviv API    @0@'.format(with_etnaviv))
+message('')