summaryrefslogtreecommitdiff
path: root/meson.build
blob: a163e99403525704a56ac87a1ada636fd8911d88 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Copyright 2019 Endless OS Foundation LLC
# Copyright 2019 Collabora Ltd.
# SPDX-License-Identifier: LGPL-2.1-or-later

project(
  'libglnx',
  'c',
  default_options : [
    'c_std=gnu99',
    'warning_level=2',
  ],
)

add_project_arguments('-D_GNU_SOURCE', language: 'c')
add_project_arguments('-Wno-unused-local-typedefs', language: 'c')

# We are intentionally using non-ISO features in this (sub)project,
# even if a parent project wants to use pedantic warnings
add_project_arguments('-Wno-pedantic', language: 'c')
add_project_arguments('-Wno-variadic-macros', language: 'c')

cc = meson.get_compiler('c')


check_functions = [
  'renameat2',
  'memfd_create',
  'copy_file_range',
]
conf = configuration_data()
foreach check_function : check_functions
  have_it = cc.compiles('''
    #include <sys/types.h>
    #include <unistd.h>
    #include <stdio.h>
    #include <sys/mount.h>
    #include <fcntl.h>
    #include <sched.h>
    #include <linux/loop.h>
    #include <linux/random.h>
    #include <sys/mman.h>

    int func (void) {
      (void) ''' + check_function + ''';
    }
    ''',
    args : '-D_GNU_SOURCE',
    name : check_function + '() is declared',
  )
  conf.set10('HAVE_DECL_' + check_function.underscorify().to_upper(), have_it)
endforeach
config_h = configure_file(
  output : 'libglnx-config.h',
  configuration : conf,
)

libglnx_deps = [
  dependency('gio-2.0'),
  dependency('gio-unix-2.0'),
]
libglnx_inc = include_directories('.')
libglnx_sources = [
  'glnx-backport-autocleanups.h',
  'glnx-backport-autoptr.h',
  'glnx-backport-testutils.c',
  'glnx-backport-testutils.h',
  'glnx-backports.c',
  'glnx-backports.h',
  'glnx-console.c',
  'glnx-console.h',
  'glnx-dirfd.c',
  'glnx-dirfd.h',
  'glnx-errors.c',
  'glnx-errors.h',
  'glnx-fdio.c',
  'glnx-fdio.h',
  'glnx-local-alloc.c',
  'glnx-local-alloc.h',
  'glnx-lockfile.c',
  'glnx-lockfile.h',
  'glnx-macros.h',
  'glnx-missing.h',
  'glnx-missing-syscall.h',
  'glnx-shutil.c',
  'glnx-shutil.h',
  'glnx-xattrs.c',
  'glnx-xattrs.h',
  'libglnx.h',
]

libglnx = static_library('glnx',
  libglnx_sources,
  dependencies : libglnx_deps,
  gnu_symbol_visibility : 'hidden',
  include_directories : libglnx_inc,
  install : false)
libglnx_dep = declare_dependency(
  dependencies : libglnx_deps,
  include_directories : libglnx_inc,
  link_with : libglnx)

subdir('tests')