| 1 |
# Copyright 2019 Endless OS Foundation LLC |
| 2 |
# Copyright 2019 Collabora Ltd. |
| 3 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
|
| 5 |
project( |
| 6 |
'libglnx', |
| 7 |
'c', |
| 8 |
default_options : [ |
| 9 |
'c_std=gnu99', |
| 10 |
'warning_level=2', |
| 11 |
], |
| 12 |
) |
| 13 |
|
| 14 |
add_project_arguments('-D_GNU_SOURCE', language: 'c') |
| 15 |
add_project_arguments('-Wno-unused-local-typedefs', language: 'c') |
| 16 |
|
| 17 |
# We are intentionally using non-ISO features in this (sub)project, |
| 18 |
# even if a parent project wants to use pedantic warnings |
| 19 |
add_project_arguments('-Wno-pedantic', language: 'c') |
| 20 |
add_project_arguments('-Wno-variadic-macros', language: 'c') |
| 21 |
|
| 22 |
cc = meson.get_compiler('c') |
| 23 |
|
| 24 |
|
| 25 |
check_functions = [ |
| 26 |
'renameat2', |
| 27 |
'memfd_create', |
| 28 |
'copy_file_range', |
| 29 |
] |
| 30 |
conf = configuration_data() |
| 31 |
foreach check_function : check_functions |
| 32 |
have_it = cc.compiles(''' |
| 33 |
#include <sys/types.h> |
| 34 |
#include <unistd.h> |
| 35 |
#include <stdio.h> |
| 36 |
#include <sys/mount.h> |
| 37 |
#include <fcntl.h> |
| 38 |
#include <sched.h> |
| 39 |
#include <linux/loop.h> |
| 40 |
#include <linux/random.h> |
| 41 |
#include <sys/mman.h> |
| 42 |
|
| 43 |
void func (void) { |
| 44 |
(void) ''' + check_function + '''; |
| 45 |
} |
| 46 |
''', |
| 47 |
args : '-D_GNU_SOURCE', |
| 48 |
name : check_function + '() is declared', |
| 49 |
) |
| 50 |
conf.set10('HAVE_DECL_' + check_function.underscorify().to_upper(), have_it) |
| 51 |
endforeach |
| 52 |
|
| 53 |
check_functions = [ |
| 54 |
'close_range', |
| 55 |
] |
| 56 |
foreach check_function : check_functions |
| 57 |
if cc.has_function(check_function) |
| 58 |
conf.set('HAVE_' + check_function.underscorify().to_upper(), 1) |
| 59 |
endif |
| 60 |
endforeach |
| 61 |
|
| 62 |
config_h = configure_file( |
| 63 |
output : 'libglnx-config.h', |
| 64 |
configuration : conf, |
| 65 |
) |
| 66 |
|
| 67 |
libglnx_deps = [ |
| 68 |
dependency('gio-2.0'), |
| 69 |
dependency('gio-unix-2.0'), |
| 70 |
] |
| 71 |
libglnx_inc = include_directories('.') |
| 72 |
libglnx_sources = [ |
| 73 |
'glnx-backport-autocleanups.h', |
| 74 |
'glnx-backport-autoptr.h', |
| 75 |
'glnx-backport-testutils.c', |
| 76 |
'glnx-backport-testutils.h', |
| 77 |
'glnx-backports.c', |
| 78 |
'glnx-backports.h', |
| 79 |
'glnx-chase.c', |
| 80 |
'glnx-chase.h', |
| 81 |
'glnx-console.c', |
| 82 |
'glnx-console.h', |
| 83 |
'glnx-dirfd.c', |
| 84 |
'glnx-dirfd.h', |
| 85 |
'glnx-errors.c', |
| 86 |
'glnx-errors.h', |
| 87 |
'glnx-fdio.c', |
| 88 |
'glnx-fdio.h', |
| 89 |
'glnx-local-alloc.c', |
| 90 |
'glnx-local-alloc.h', |
| 91 |
'glnx-lockfile.c', |
| 92 |
'glnx-lockfile.h', |
| 93 |
'glnx-macros.h', |
| 94 |
'glnx-missing.h', |
| 95 |
'glnx-missing-syscall.h', |
| 96 |
'glnx-shutil.c', |
| 97 |
'glnx-shutil.h', |
| 98 |
'glnx-xattrs.c', |
| 99 |
'glnx-xattrs.h', |
| 100 |
'libglnx.h', |
| 101 |
] |
| 102 |
|
| 103 |
libglnx = static_library('glnx', |
| 104 |
libglnx_sources, |
| 105 |
dependencies : libglnx_deps, |
| 106 |
gnu_symbol_visibility : 'hidden', |
| 107 |
include_directories : libglnx_inc, |
| 108 |
install : false) |
| 109 |
libglnx_dep = declare_dependency( |
| 110 |
dependencies : libglnx_deps, |
| 111 |
include_directories : libglnx_inc, |
| 112 |
link_with : libglnx) |
| 113 |
|
| 114 |
subdir('tests') |
| 115 |
|