]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
build: improve meson build 3978/head
authorChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Sep 2021 12:05:24 +0000 (14:05 +0200)
committerChristian Brauner <christian.brauner@ubuntu.com>
Thu, 23 Sep 2021 12:05:24 +0000 (14:05 +0200)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
23 files changed:
hooks/unmount-namespace.c
meson.build
src/include/meson.build
src/include/strlcat.c
src/lxc/af_unix.c
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup2_devices.h
src/lxc/conf.c
src/lxc/confile.c
src/lxc/confile_utils.c
src/lxc/criu.c
src/lxc/log.c
src/lxc/lxccontainer.c
src/lxc/macro.h
src/lxc/process_utils.h
src/lxc/start.c
src/lxc/string_utils.c
src/lxc/string_utils.h
src/lxc/syscall_wrappers.h
src/lxc/tools/include/meson.build [new file with mode: 0644]
src/lxc/tools/meson.build
src/lxc/utils.c
src/lxc/utils.h

index df139e052a444da086b3fefeba4ceea3249fc54d..8721b3536a7c865737b1ba1af0b3d0f4b0876624 100644 (file)
@@ -49,7 +49,7 @@
 #endif
 
 /* Define setns() if missing from the C library */
-#ifndef HAVE_SETNS
+#if !HAVE_SETNS
 static inline int setns(int fd, int nstype)
 {
 #ifdef __NR_setns
index 12d438f485528847db3f48d5d8a992cba4aebc8c..ab1885bcc1944faeb8e9fc852accc38930458b0f 100644 (file)
@@ -206,15 +206,24 @@ foreach ident : [
                                   #include <unistd.h>'''],
         ['close_range',        '''#include <unistd.h>'''],
         ['execveat',           '''#include <unistd.h>'''],
+        ['endmntent',          '''#include <stdio.h>
+                                  #include <mntent.h>'''],
         ['faccessat',          '''#include <fcntl.h>
                                   #include <unistd.h>'''],
         ['fexecve',            '''#include <unistd.h>'''],
+        ['fgetln',             '''#include <stdio.h>'''],
         ['fsconfig',           '''#include <sys/mount.h>'''],
         ['fsmount',            '''#include <sys/mount.h>'''],
         ['fsopen',             '''#include <sys/mount.h>'''],
         ['fspick',             '''#include <sys/mount.h>'''],
+        ['getgrgid_r',          '''#include <sys/types.h>
+                                  #include <grp.h>'''],
+        ['getline',            '''#include <stdio.h>'''],
+        ['getsubopt',          '''#include <stdlib.h>'''],
         ['gettid',             '''#include <sys/types.h>
                                   #include <unistd.h>'''],
+        ['hasmntopt',          '''#include <stdio.h>
+                                  #include <mntent.h>'''],
         ['kcmp',               '''#include <linux/kcmp.h>'''],
         ['keyctl',             '''#include <sys/types.h>
                                   #include <keyutils.h>'''],
@@ -243,19 +252,21 @@ foreach ident : [
         ['renameat2',          '''#include <stdio.h>
                                   #include <fcntl.h>'''],
         ['sethostname',                '''#include <unistd.h>'''],
+        ['setmntent',          '''#include <stdio.h>
+                                  #include <mntent.h>'''],
         ['setns',              '''#include <sched.h>'''],
         ['signalfd',           '''#include <sys/signalfd.h>'''],
         ['statx',              '''#include <sys/types.h>
                                   #include <sys/stat.h>
                                   #include <unistd.h>'''],
+        ['strchrnul',          '''#include <string.h>'''],
         ['strlcat',            '''#include <string.h>'''],
         ['strlcpy',            '''#include <string.h>'''],
         ['unshare',            '''#include <sched.h>'''],
 ]
 
-        if cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
-               conf.set10('HAVE_' + ident[0].to_upper(), true)
-       endif
+        have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
+       conf.set10('HAVE_' + ident[0].to_upper(), have)
 endforeach
 
 sh = find_program('sh')
@@ -335,32 +346,37 @@ if libcap_static.found()
        conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
 endif
 
+have = cc.has_function('strchrnul', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
+conf.set10('HAVE_STRCHRNUL', have)
+
+have = cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
+conf.set10('HAVE_OPENPTY', have)
+
+config_h = configure_file(
+        output : 'config.h',
+        configuration : conf)
+
+add_project_arguments('-include', 'config.h', language : 'c')
+
 basic_includes = include_directories(
+       '.',
        'src',
-       'src/include',
-       '.')
+       'src/include')
 
 liblxc_includes = [basic_includes, include_directories(
         'src/lxc/cgroups',
         'src/lxc/lsm',
         'src/lxc/storage')]
 
-add_project_arguments('-include', 'config.h', language : 'c')
-
-subdir('hooks')
 subdir('src/include')
+subdir('src/lxc/tools/include')
+subdir('hooks')
 subdir('src/lxc')
-subdir('src/lxc/cmd')
-subdir('src/lxc/tools')
-
-config_h = configure_file(
-        output : 'config.h',
-        configuration : conf)
 
 liblxc = shared_library(
         'lxc',
         version : liblxc_version,
-        include_directories : tools_liblxc_includes,
+       include_directories: liblxc_includes,
         link_args : ['-DPIC'],
         c_args : ['-DPIC'],
         link_whole : [liblxc_static],
@@ -381,156 +397,11 @@ liblxc_dep = declare_dependency(
                                libselinux,
                                libapparmor])
 
-public_programs = []
-
-public_programs += executable(
-                'lxc-autostart',
-               tools_lxc_autostart_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-cgroup',
-               tools_lxc_cgroup_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-checkpoint',
-               tools_lxc_checkpoint_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-config',
-               tools_lxc_config_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-console',
-               tools_lxc_console_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-copy',
-               tools_lxc_copy_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-create',
-               tools_lxc_create_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-destroy',
-               tools_lxc_destroy_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-device',
-               tools_lxc_device_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-execute',
-               tools_lxc_execute_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-freeze',
-               tools_lxc_freeze_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-info',
-               tools_lxc_info_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-ls',
-               tools_lxc_ls_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-monitor',
-               tools_lxc_monitor_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-snapshot',
-               tools_lxc_snapshot_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-start',
-               tools_lxc_start_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-stop',
-               tools_lxc_stop_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-top',
-               tools_lxc_top_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-unfreeze',
-               tools_lxc_unfreeze_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-unshare',
-               tools_lxc_unshare_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
-public_programs += executable(
-                'lxc-wait',
-               tools_lxc_wait_sources,
-                include_directories : tools_liblxc_includes,
-               dependencies : liblxc_dep,
-                install : true)
-
 cmd_programs = []
+subdir('src/lxc/cmd')
+
+public_programs = []
+subdir('src/lxc/tools')
 
 cmd_programs += executable(
                'lxc-init',
@@ -564,14 +435,20 @@ missing_syscalls = []
 foreach tuple : [
         ['bpf'],
         ['close_range'],
+        ['endmntent'],
         ['execveat'],
         ['faccessat'],
-        ['fexecve'],
+        ['strchrnul'],
+        ['fgetln'],
         ['fsconfig'],
         ['fsmount'],
         ['fsopen'],
         ['fspick'],
+        ['getgrgid_r'],
+        ['getline'],
+        ['getsubopt'],
         ['gettid'],
+        ['hasmntopt'],
         ['kcmp'],
         ['keyctl'],
         ['memfd_create'],
@@ -587,6 +464,7 @@ foreach tuple : [
         ['prlimit64'],
         ['renameat2'],
         ['sethostname'],
+        ['setmntent'],
         ['setns'],
         ['signalfd'],
         ['statx'],
index 38217bc704b07338e494b89d2d91815de8023e14..390971fa494037b8ec47be3f326134dbeaace6c9 100644 (file)
@@ -8,89 +8,50 @@ netns_ifaddrs_sources = files(
        'netns_ifaddrs.c',
        'netns_ifaddrs.h')
 
-if cc.has_function('getline', prefix : '#include <stdio.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_GETLINE', true)
-else
+if conf.get('HAVE_GETLINE') == 0
        include_sources += files(
                'getline.c',
                'getline.h')
 endif
 
-if cc.has_function('fexecve', prefix : '#include <unistd.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_FEXECVE', true)
-else
+if conf.get('HAVE_FEXECVE') == 0
        include_sources += files(
                'fexecve.c',
                'fexecve.h')
 endif
 
 
-getgr_headers = '''
-#include <sys/types.h>
-#include <grp.h>
-'''
-
-if cc.has_function('getgrgid_r', prefix : getgr_headers, args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_GETGRGID_R', true)
-else
+if conf.get('HAVE_GETGRGID_R') == 0
        include_sources += files(
                'getgrgid_r.c',
                'getgrgid_r.h')
 endif
 
-mntent_headers = '''
-#include <stdio.h>
-#include <mntent.h>
-'''
-
-have_hasmntopt = cc.has_function('hasmntopt', prefix : mntent_headers, args : '-D_GNU_SOURCE')
-if have_hasmntopt
-       conf.set10('HAVE_HASMNTOPT', true)
-endif
-
-have_setmntent = cc.has_function('setmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
-if have_setmntent
-       conf.set10('HAVE_SETMNTENT', true)
-endif
-
-have_endmntent = cc.has_function('endmntent', prefix : mntent_headers, args : '-D_GNU_SOURCE')
-if have_endmntent
-       conf.set10('HAVE_ENDMNTENT', true)
-endif
-
-if have_hasmntopt == false or have_setmntent == false or have_endmntent == false
+if conf.get('HAVE_HASMNTOPT') == 0 or conf.get('HAVE_SETMNTENT') == 0 or conf.get('HAVE_ENDMNTENT') == 0
        include_sources += files(
                'lxcmntent.c',
                'lxcmntent.h')
 endif
 
-if cc.has_function('strlcpy', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_STRLCPY', true)
-else
+if conf.get('HAVE_STRLCPY') == 0
        include_sources += files(
                'strlcpy.c',
                'strlcpy.h')
 endif
 
-if cc.has_function('strlcat', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_STRLCAT', true)
-else
+if conf.get('HAVE_STRLCAT') == 0
        include_sources += files(
                'strlcat.c',
                'strlcat.h')
 endif
 
-if cc.has_function('strchrnul', prefix : '#include <string.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_STRCHRNUL', true)
-else
+if conf.get('HAVE_STRCHRNUL') == 0
        include_sources += files(
                'strchrnul.c',
                'strchrnul.h')
 endif
 
-if cc.has_function('openpty', prefix : '#include <pty.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_OPENPTY', true)
-else
+if conf.get('HAVE_OPENPTY') == 0
        include_sources += files(
                'openpty.c',
                'openpty.h')
index ded647c6f2ae975b6b66d29a2cab144cd9ce7524..823c7494afac8532f2f8b497429b8a3bcae71020 100644 (file)
@@ -23,7 +23,7 @@
 #include <stdint.h>
 #include <string.h>
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index 7dae44c59d90f6dc4d822d483816d045a8fe06d8..97f9ac6760f0fddaa53f5547fa6a41884afd3a8e 100644 (file)
@@ -20,7 +20,7 @@
 #include "process_utils.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index 6a5d9eeabb72141185c1961b5c8945cea8ada222..7ae67e30c72ce4440309e3dc1e976682a29ac73a 100644 (file)
 #include "syscall_wrappers.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
index 4b0fb736277230c298677a7b6ecd616a71e8a246..7979b2262b299006b355651f80f3136b1185f25d 100644 (file)
@@ -28,7 +28,7 @@
 #include "bpf.h"
 #include "bpf_common.h"
 
-#ifndef HAVE_BPF
+#if !HAVE_BPF
 static inline int bpf_lxc(int cmd, union bpf_attr *attr, size_t size)
 {
        return syscall(__NR_bpf, cmd, attr, size);
index aecd942285833fc6b29ebd416f6a286d2994fc83..e645d10be8621446695cb0512a60d264866b3192 100644 (file)
@@ -80,7 +80,7 @@
 #include <sys/capability.h>
 #endif
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
 #include "prlimit.h"
 #endif
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRCHRNUL
+#if !HAVE_STRCHRNUL
 #include "strchrnul.h"
 #endif
 
index f4cb4b5e245641fb05da8aff79ce8d39a3c34052..4a74f8daf42e188df5e036bb360ff24e9132ab26 100644 (file)
 #include "parse.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
index 5534daa418281316781877c5409bb47186ed1ae5..8d0f822f33f935c328d0a3d7e553f882fc786104 100644 (file)
@@ -23,7 +23,7 @@
 #include "parse.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index 3ee736922010297c2dded64238b34ebc7295ed82..c3061ad746038d7db34ec4196f1373e177605365 100644 (file)
@@ -34,7 +34,7 @@
 #include <mntent.h>
 #endif
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index ac3713eccdc460c378424b6808b8703d8370132a..cdd11ff1c084c0cad8bb7f15b702092d0cf38c86 100644 (file)
@@ -24,7 +24,7 @@
 #include "memory_utils.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index ac4b312c0889ed8c2d60f1179a2edab46771214c..96fdb3fd22db68077946e500adca877ada334b08 100644 (file)
@@ -76,7 +76,7 @@
 #include <mntent.h>
 #endif
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "include/strlcpy.h"
 #endif
 
index 9054c326cb734f7c06c4afd41466c7ab400aeae9..c6d41d79efc29dd03abf08c9e1c513a31a0bf990 100644 (file)
@@ -731,7 +731,7 @@ enum {
 #define hweight32(w) __const_hweight32(w)
 #define hweight64(w) __const_hweight64(w)
 
-#ifndef HAVE___ALIGNED_U64
+#if !HAVE___ALIGNED_U64
 #define __aligned_u64 __u64 __attribute__((aligned(8)))
 #endif
 
@@ -739,7 +739,7 @@ enum {
 #define BITS_PER_TYPE(type) (sizeof(type) * 8)
 #define LAST_BIT_PER_TYPE(type) (BITS_PER_TYPE(type) - 1)
 
-#ifndef HAVE_SYS_PERSONALITY_H
+#if !HAVE_SYS_PERSONALITY_H
 #define PER_LINUX      0x0000
 #define PER_LINUX32    0x0008
 #endif
index 2a5032c0328fefb9ba3e1fdee6fe35167be99392..2eb9e5152e4ef12015220c4cac4a6909a52ab7c6 100644 (file)
@@ -254,7 +254,7 @@ __hidden extern pid_t lxc_raw_legacy_clone(unsigned long flags, int *pidfd);
 __hidden extern pid_t lxc_raw_clone_cb(int (*fn)(void *), void *args, unsigned long flags,
                                       int *pidfd);
 
-#ifndef HAVE_EXECVEAT
+#if !HAVE_EXECVEAT
 static inline int execveat(int dirfd, const char *pathname, char *const argv[],
                           char *const envp[], int flags)
 {
index 4eed60a21160501efb413e3d011bc88251510e4a..a9d3d5eadac6cae53a22133bea8e5ee8fccaabb7 100644 (file)
@@ -62,7 +62,7 @@
 #include <sys/capability.h>
 #endif
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
index e2bc9fe48f7183d848c8629a5f42b012dde35027..c14a38dfebe56b5baca7922af1fbea613a9673e8 100644 (file)
 #include "macro.h"
 #include "memory_utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
index 7abbc537f7b805d7aacef3330ea5338b17c8849f..e64a66d0e38e6e42a58f496b8dbed6f5ed0e3b6b 100644 (file)
 #include "initutils.h"
 #include "macro.h"
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRCHRNUL
+#if !HAVE_STRCHRNUL
 #include "strchrnul.h"
 #endif
 
index 10f2fff3481c337738b8c13ae713b556d138902b..f1004d2647f8d2aff08e1568954a76790468a43e 100644 (file)
@@ -54,7 +54,7 @@ static inline long __keyctl(int cmd, unsigned long arg2, unsigned long arg3,
 #define F_SEAL_WRITE 0x0008
 #endif
 
-#ifndef HAVE_MEMFD_CREATE
+#if !HAVE_MEMFD_CREATE
 static inline int memfd_create_lxc(const char *name, unsigned int flags)
 {
        return syscall(__NR_memfd_create, name, flags);
@@ -64,7 +64,7 @@ static inline int memfd_create_lxc(const char *name, unsigned int flags)
 extern int memfd_create(const char *name, unsigned int flags);
 #endif
 
-#ifndef HAVE_PIVOT_ROOT
+#if !HAVE_PIVOT_ROOT
 static inline int pivot_root(const char *new_root, const char *put_old)
 {
        return syscall(__NR_pivot_root, new_root, put_old);
@@ -74,7 +74,7 @@ extern int pivot_root(const char *new_root, const char *put_old);
 #endif
 
 /* Define sethostname() if missing from the C library */
-#ifndef HAVE_SETHOSTNAME
+#if !HAVE_SETHOSTNAME
 static inline int sethostname(const char *name, size_t len)
 {
        return syscall(__NR_sethostname, name, len);
@@ -82,14 +82,14 @@ static inline int sethostname(const char *name, size_t len)
 #endif
 
 /* Define setns() if missing from the C library */
-#ifndef HAVE_SETNS
+#if !HAVE_SETNS
 static inline int setns(int fd, int nstype)
 {
        return syscall(__NR_setns, fd, nstype);
 }
 #endif
 
-#ifndef HAVE_SYS_SIGNALFD_H
+#if !HAVE_SYS_SIGNALFD_H
 struct signalfd_siginfo {
        uint32_t ssi_signo;
        int32_t ssi_errno;
@@ -125,7 +125,7 @@ static inline int signalfd(int fd, const sigset_t *mask, int flags)
 #endif
 
 /* Define unshare() if missing from the C library */
-#ifndef HAVE_UNSHARE
+#if !HAVE_UNSHARE
 static inline int unshare(int flags)
 {
        return syscall(__NR_unshare, flags);
@@ -135,14 +135,14 @@ extern int unshare(int);
 #endif
 
 /* Define faccessat() if missing from the C library */
-#ifndef HAVE_FACCESSAT
+#if !HAVE_FACCESSAT
 static int faccessat(int __fd, const char *__file, int __type, int __flag)
 {
        return syscall(__NR_faccessat, __fd, __file, __type, __flag);
 }
 #endif
 
-#ifndef HAVE_MOVE_MOUNT
+#if !HAVE_MOVE_MOUNT
 static inline int move_mount_lxc(int from_dfd, const char *from_pathname,
                                 int to_dfd, const char *to_pathname,
                                 unsigned int flags)
@@ -156,7 +156,7 @@ extern int move_mount(int from_dfd, const char *from_pathname, int to_dfd,
                      const char *to_pathname, unsigned int flags);
 #endif
 
-#ifndef HAVE_OPEN_TREE
+#if !HAVE_OPEN_TREE
 static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flags)
 {
        return syscall(__NR_open_tree, dfd, filename, flags);
@@ -166,7 +166,7 @@ static inline int open_tree_lxc(int dfd, const char *filename, unsigned int flag
 extern int open_tree(int dfd, const char *filename, unsigned int flags);
 #endif
 
-#ifndef HAVE_FSOPEN
+#if !HAVE_FSOPEN
 static inline int fsopen_lxc(const char *fs_name, unsigned int flags)
 {
        return syscall(__NR_fsopen, fs_name, flags);
@@ -176,7 +176,7 @@ static inline int fsopen_lxc(const char *fs_name, unsigned int flags)
 extern int fsopen(const char *fs_name, unsigned int flags);
 #endif
 
-#ifndef HAVE_FSPICK
+#if !HAVE_FSPICK
 static inline int fspick_lxc(int dfd, const char *path, unsigned int flags)
 {
        return syscall(__NR_fspick, dfd, path, flags);
@@ -186,7 +186,7 @@ static inline int fspick_lxc(int dfd, const char *path, unsigned int flags)
 extern int fspick(int dfd, const char *path, unsigned int flags);
 #endif
 
-#ifndef HAVE_FSCONFIG
+#if !HAVE_FSCONFIG
 static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const void *value, int aux)
 {
        return syscall(__NR_fsconfig, fd, cmd, key, value, aux);
@@ -196,7 +196,7 @@ static inline int fsconfig_lxc(int fd, unsigned int cmd, const char *key, const
 extern int fsconfig(int fd, unsigned int cmd, const char *key, const void *value, int aux);
 #endif
 
-#ifndef HAVE_FSMOUNT
+#if !HAVE_FSMOUNT
 static inline int fsmount_lxc(int fs_fd, unsigned int flags, unsigned int attr_flags)
 {
        return syscall(__NR_fsmount, fs_fd, flags, attr_flags);
@@ -216,7 +216,7 @@ struct lxc_mount_attr {
        __u64 userns_fd;
 };
 
-#ifndef HAVE_MOUNT_SETATTR
+#if !HAVE_MOUNT_SETATTR
 static inline int mount_setattr(int dfd, const char *path, unsigned int flags,
                                struct lxc_mount_attr *attr, size_t size)
 {
@@ -291,7 +291,7 @@ struct lxc_open_how {
 #define PROTECT_OPEN_W (PROTECT_OPEN_W_WITH_TRAILING_SYMLINKS | O_NOFOLLOW)
 #define PROTECT_OPEN_RW (O_CLOEXEC | O_NOCTTY | O_RDWR | O_NOFOLLOW)
 
-#ifndef HAVE_OPENAT2
+#if !HAVE_OPENAT2
 static inline int openat2(int dfd, const char *filename, struct lxc_open_how *how, size_t size)
 {
        return syscall(__NR_openat2, dfd, filename, how, size);
@@ -306,14 +306,14 @@ static inline int openat2(int dfd, const char *filename, struct lxc_open_how *ho
 #define CLOSE_RANGE_CLOEXEC    (1U << 2)
 #endif
 
-#ifndef HAVE_CLOSE_RANGE
+#if !HAVE_CLOSE_RANGE
 static inline int close_range(unsigned int fd, unsigned int max_fd, unsigned int flags)
 {
        return syscall(__NR_close_range, fd, max_fd, flags);
 }
 #endif
 
-#ifndef HAVE_SYS_PERSONALITY_H
+#if !HAVE_SYS_PERSONALITY_H
 static inline int personality(unsigned long persona)
 {
        return syscall(__NR_personality, persona);
diff --git a/src/lxc/tools/include/meson.build b/src/lxc/tools/include/meson.build
new file mode 100644 (file)
index 0000000..f1bb4a5
--- /dev/null
@@ -0,0 +1,7 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+
+if conf.get('HAVE_GETSUBOPT') == 0
+       include_sources += files(
+               'getsubopt.c',
+               'getsubopt.h')
+endif
index 14a5848996d416c7b190b2445d0a518e3c6a77be..3fb8b68a594ce61b85490f378d5d3c5a8a28f6c2 100644 (file)
@@ -6,7 +6,8 @@ tools_liblxc_includes = include_directories(
        '../cgroups',
        '../lsm',
        '../storage',
-       '../../include')
+       '../../include',
+       '../../../')
 
 tools_common_sources = files(
        'arguments.c',
@@ -123,14 +124,6 @@ tools_lxc_config_sources = files(
 tools_lxc_console_sources = files(
        'lxc_console.c') + tools_common_sources
 
-if cc.has_function('getsubopt', prefix : '#include <stdlib.h>', args : '-D_GNU_SOURCE')
-       conf.set10('HAVE_GETSUBOPT', true)
-else
-       include_sources += files(
-               'tools/include/getsubopt.c',
-               'tools/include/getsubopt.h')
-endif
-
 tools_lxc_copy_sources = files(
        'lxc_copy.c') + tools_common_sources
 
@@ -178,3 +171,150 @@ tools_lxc_unshare_sources = files(
 
 tools_lxc_wait_sources = files(
        'lxc_wait.c') + tools_common_sources
+
+public_programs += executable(
+                'lxc-autostart',
+               tools_lxc_autostart_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-cgroup',
+               tools_lxc_cgroup_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-checkpoint',
+               tools_lxc_checkpoint_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-config',
+               tools_lxc_config_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-console',
+               tools_lxc_console_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-copy',
+               tools_lxc_copy_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-create',
+               tools_lxc_create_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-destroy',
+               tools_lxc_destroy_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-device',
+               tools_lxc_device_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-execute',
+               tools_lxc_execute_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-freeze',
+               tools_lxc_freeze_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-info',
+               tools_lxc_info_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-ls',
+               tools_lxc_ls_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-monitor',
+               tools_lxc_monitor_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-snapshot',
+               tools_lxc_snapshot_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-start',
+               tools_lxc_start_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-stop',
+               tools_lxc_stop_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-top',
+               tools_lxc_top_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-unfreeze',
+               tools_lxc_unfreeze_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-unshare',
+               tools_lxc_unshare_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
+
+public_programs += executable(
+                'lxc-wait',
+               tools_lxc_wait_sources,
+                include_directories : tools_liblxc_includes,
+               dependencies : liblxc_dep,
+                install : true)
index aab0dda238d10dcea4178016818ebe4a96ae7339..bc8a2b0c3026bf4cda9bb39ef953a67d50f33eca 100644 (file)
 #include "syscall_wrappers.h"
 #include "utils.h"
 
-#ifndef HAVE_STRLCPY
+#if !HAVE_STRLCPY
 #include "strlcpy.h"
 #endif
 
-#ifndef HAVE_STRLCAT
+#if !HAVE_STRLCAT
 #include "strlcat.h"
 #endif
 
index 51fb8874b8f92589fe6bd64becd3ee5eac41eb12..161555e6f6ca952b523e978a9f3d3495776527a7 100644 (file)
@@ -33,8 +33,8 @@ __hidden extern int mkdir_p(const char *dir, mode_t mode);
 __hidden extern char *get_rundir(void);
 
 /* Define getline() if missing from the C library */
-#ifndef HAVE_GETLINE
-#ifdef HAVE_FGETLN
+#if !HAVE_GETLINE
+#if !HAVE_FGETLN
 #include "getline.h"
 #endif
 #endif