]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
meson: Rework configuration variables
authorStéphane Graber <stgraber@ubuntu.com>
Thu, 2 Jun 2022 20:37:45 +0000 (16:37 -0400)
committerStéphane Graber <stgraber@ubuntu.com>
Thu, 2 Jun 2022 20:50:00 +0000 (16:50 -0400)
Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
hooks/meson.build
meson.build
src/include/meson.build
src/lxc/cmd/meson.build
src/lxc/tools/include/meson.build
templates/meson.build

index 45eb178738ff21319f1f2cb456816f43f3bddd25..15cd0f8cf5918f890e3ac827310f5ad573786255 100644 (file)
@@ -25,12 +25,8 @@ hook_programs = configure_file(
     output: 'dhclient-script')
 install_data(join_paths(project_build_root, 'hooks/dhclient-script'), install_dir: lxchookdir)
 
-dhclient_config_data = configuration_data()
-dhclient_config_data.set_quoted('LXCHOOKDIR', lxchookdir)
-dhclient_config_data.set_quoted('SYSCONFDIR', sysconfdir)
-
 hook_programs = configure_file(
-    configuration: dhclient_config_data,
+    configuration: conf,
     input: 'dhclient.in',
     output: 'dhclient')
 install_data(join_paths(project_build_root, 'hooks/dhclient'), install_dir: lxchookdir)
index ec8163d6c8fadfbfce7e826d160cc138b38f8fd8..b07a5a19f45c295c1defa008177a903b81b46676 100644 (file)
@@ -4,7 +4,7 @@
 project(
     'lxc',
     'c',
-    version: '4.0.0',
+    version: '4.0.0-devel',
     license: 'LGPLv2+',
     default_options: [
         'b_lto=true',
@@ -23,29 +23,18 @@ pkgconfig = import('pkgconfig')
 pkgconfig_libs = []
 
 # Version.
+liblxc_version = '1.7.0'
 version_data = configuration_data()
 version_data.set('LXC_VERSION_MAJOR', '4')
 version_data.set('LXC_VERSION_MINOR', '0')
-version_data.set('LXC_VERSION_MICRO', '7')
-version_data.set('LXC_ABI', '4.0.7')
+version_data.set('LXC_VERSION_MICRO', '0')
+version_data.set('LXC_ABI', liblxc_version)
 version_data.set('LXC_DEVEL', '1')
-version_data.set('LXC_VERSION', '4.0.7-devel')
-liblxc_version = '1.7.0'
-
-# Configuration options.
-conf = configuration_data()
-conf.set_quoted('PROJECT', meson.project_name())
-conf.set_quoted('PROJECT_URL', 'https://linuxcontainers.org/lxc/')
-conf.set_quoted('PROJECT_VERSION', meson.project_version())
-conf.set_quoted('PACKAGE_VERSION', meson.project_version())
-conf.set('_GNU_SOURCE', true)
-conf.set('_FILE_OFFSET_BITS', 64)
-conf.set('__STDC_FORMAT_MACROS', true)
+version_data.set('LXC_VERSION', meson.project_version())
 
+# Path handling.
 project_source_root = meson.current_source_dir()
 project_build_root = meson.current_build_dir()
-
-# Path handling.
 prefixdir = get_option('prefix')
 
 apparmorcachedir = get_option('apparmor-cache-path')
@@ -90,30 +79,40 @@ lxc_user_network_conf = join_paths(sysconfdir, user_network_conf_opt)
 lxc_user_network_db = join_paths(runtimepath, user_network_db_opt)
 pam_security = join_paths(libdir, 'security')
 
-conf.set_quoted('BINDIR', bindir)
-conf.set_quoted('DATADIR', datadir)
-conf.set_quoted('DOCDIR', docdir)
-conf.set_quoted('INCLUDEDIR', includedir)
-conf.set_quoted('LIBDIR', libdir)
-conf.set_quoted('LIBEXECDIR', libexecdir)
-conf.set_quoted('LOCALSTATEDIR', localstatedir)
-conf.set_quoted('RUNTIME_PATH', runtimepath)
-conf.set_quoted('SBINDIR', sbindir)
-conf.set_quoted('SYSCONFDIR', sysconfdir)
-
-conf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
-conf.set_quoted('LOGPATH', lxclogpath)
-conf.set_quoted('LXCBINHOOKDIR', lxchookbindir)
-conf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
-conf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
-conf.set_quoted('LXCHOOKDIR', lxchookdir)
-conf.set_quoted('LXCINITDIR', libexecdir)
-conf.set_quoted('LXCPATH', lxcpath)
-conf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
-conf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
-conf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
-conf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
-conf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
+# Configuration options.
+srcconf = configuration_data()
+srcconf.set('_GNU_SOURCE', true)
+srcconf.set('_FILE_OFFSET_BITS', 64)
+srcconf.set('__STDC_FORMAT_MACROS', true)
+srcconf.set_quoted('APPARMOR_CACHE_DIR', lxcapparmorcachedir)
+srcconf.set_quoted('LIBEXECDIR', libexecdir)
+srcconf.set_quoted('LOGPATH', lxclogpath)
+srcconf.set_quoted('LXC_DEFAULT_CONFIG', lxcdefaultconfig)
+srcconf.set_quoted('LXC_GLOBAL_CONF', lxcglobalconfig)
+srcconf.set_quoted('LXCINITDIR', libexecdir)
+srcconf.set_quoted('LXCPATH', lxcpath)
+srcconf.set_quoted('LXCROOTFSMOUNT', lxcrootfsmount)
+srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
+srcconf.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
+srcconf.set_quoted('LXCTEMPLATEDIR', lxctemplatedir)
+srcconf.set_quoted('LXC_USERNIC_CONF', lxc_user_network_conf)
+srcconf.set_quoted('LXC_USERNIC_DB', lxc_user_network_db)
+srcconf.set_quoted('RUNTIME_PATH', runtimepath)
+srcconf.set_quoted('SBINDIR', sbindir)
+
+conf = configuration_data()
+conf.set('BINDIR', bindir)
+conf.set('LIBEXECDIR', libexecdir)
+conf.set('LOCALSTATEDIR', localstatedir)
+conf.set('LXC_GLOBAL_CONF', lxcglobalconfig)
+conf.set('LXCHOOKDIR', lxchookdir)
+conf.set('LXCINITDIR', libexecdir)
+conf.set('LXCROOTFSMOUNT', lxcrootfsmount)
+conf.set('LXCTEMPLATECONFIG', lxctemplateconfdir)
+conf.set('LXCTEMPLATEDIR', lxctemplatedir)
+conf.set('PACKAGE_VERSION', meson.project_version())
+conf.set('RUNTIME_PATH', runtimepath)
+conf.set('SYSCONFDIR', sysconfdir)
 
 # Set sysconfdir
 fs = import('fs')
@@ -137,7 +136,7 @@ want_mans = get_option('man')
 want_tests = get_option('tests')
 want_tools = get_option('tools')
 
-conf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
+srcconf.set_quoted('DEFAULT_CGROUP_PATTERN', cgrouppattern)
 
 dummy_config_data = configuration_data()
 dummy_config_data.set_quoted('DUMMY_VARIABLE', '1')
@@ -205,7 +204,7 @@ if want_io_uring
         error('liburing version does not support IORING_POLL_ADD_MULTI')
     endif
 
-    conf.set10('HAVE_LIBURING', true)
+    srcconf.set10('HAVE_LIBURING', true)
 endif
 
 ## Time EPOCH.
@@ -218,12 +217,10 @@ if time_epoch == '' and git.found() and run_command('test', '-e', '.git', check:
     latest_tag = run_command(git, 'describe', '--abbrev=0', '--tags', check: true).stdout().strip()
     time_epoch = run_command(git, 'log', '--no-show-signature', '-1', '--format=%at', latest_tag, check: true).stdout()
 else
-    # Fallback to current epoch
+    # Fallback to current epoch.
     time_epoch = run_command(date, '+%s', check: true).stdout()
 endif
 generate_date = run_command(date, '--utc', '--date=@' + time_epoch, '+%Y-%m-%d', check: true).stdout().strip()
-time_epoch = time_epoch.to_int()
-conf.set('TIME_EPOCH', time_epoch)
 
 ## Manpages.
 sgml2man = find_program('docbook2X2man', 'docbook2x-man', 'db2x_docbook2man', 'docbook2man', 'docbook-to-man', required: want_mans)
@@ -254,21 +251,21 @@ threads = dependency('threads')
 
 ## Seccomp.
 libseccomp = dependency('libseccomp')
-conf.set10('HAVE_SECCOMP', libseccomp.found())
+srcconf.set10('HAVE_SECCOMP', libseccomp.found())
 pkgconfig_libs += libseccomp
 if libseccomp.found()
     if libseccomp.version().version_compare('>=2.5.0')
         # https://github.com/seccomp/libseccomp/commit/dead12bc788b259b148cc4d93b970ef0bd602b1a
-        conf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
+        srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', true)
     else
-        conf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
+        srcconf.set10('HAVE_DECL_SECCOMP_NOTIFY_FD', false)
     endif
 
     if libseccomp.version().version_compare('>=2.0.0')
         # https://github.com/seccomp/libseccomp/commit/6220c8c0fc479d97b6d3e3166a4e46fbfe25a3c0
-        conf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
+        srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', true)
     else
-        conf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
+        srcconf.set10('HAVE_DECL_SECCOMP_SYSCALL_RESOLVE_NAME_ARCH', false)
     endif
 
     seccomp_headers = '''
@@ -283,25 +280,25 @@ if libseccomp.found()
 
         # We get -1 if the size cannot be determined
         if cc.sizeof(decl, prefix: seccomp_headers, args: '-D_GNU_SOURCE') > 0
-            conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
+            srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
         else
-            conf.set10('HAVE_' + decl.underscorify().to_upper(), false)
+            srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
         endif
     endforeach
 endif
 
 ## SELinux.
 libselinux = dependency('libselinux', required: false)
-conf.set10('HAVE_SELINUX', libselinux.found())
+srcconf.set10('HAVE_SELINUX', libselinux.found())
 pkgconfig_libs += libselinux
 
 ## AppArmor.
 libapparmor = dependency('libapparmor', required: false)
-conf.set10('HAVE_APPARMOR', libapparmor.found())
+srcconf.set10('HAVE_APPARMOR', libapparmor.found())
 
 ## OpenSSL.
 libopenssl = dependency('openssl', required: false)
-conf.set10('HAVE_OPENSSL', libopenssl.found())
+srcconf.set10('HAVE_OPENSSL', libopenssl.found())
 pkgconfig_libs += libopenssl
 
 ## Libcap..
@@ -310,7 +307,7 @@ if not libcap.found()
     # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
     libcap = cc.find_library('cap', required: false)
 endif
-conf.set10('HAVE_LIBCAP', libcap.found())
+srcconf.set10('HAVE_LIBCAP', libcap.found())
 pkgconfig_libs += libcap
 
 libcap_static = dependency('libcap', required: false, static: true)
@@ -318,19 +315,19 @@ if not libcap_static.found()
     # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
     libcap_static = cc.find_library('cap', required: false, static: true)
 endif
-conf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
+srcconf.set10('HAVE_STATIC_LIBCAP', libcap_static.found())
 
 ## PAM.
 pam = cc.find_library('pam', has_headers: 'security/pam_modules.h', required: want_pam_cgroup)
-conf.set10('HAVE_PAM', pam.found())
+srcconf.set10('HAVE_PAM', pam.found())
 pkgconfig_libs += pam
 
 ## Others.
 have = cc.has_function('strchrnul', prefix: '#include <string.h>', args: '-D_GNU_SOURCE')
-conf.set10('HAVE_STRCHRNUL', have)
+srcconf.set10('HAVE_STRCHRNUL', have)
 
 have = cc.has_function('openpty', prefix: '#include <pty.h>', args: '-D_GNU_SOURCE')
-conf.set10('HAVE_OPENPTY', have)
+srcconf.set10('HAVE_OPENPTY', have)
 
 ## Compiler attributes.
 foreach ccattr: [
@@ -339,7 +336,7 @@ foreach ccattr: [
     'returns_nonnull',
 ]
 
-    conf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
+    srcconf.set10('HAVE_COMPILER_ATTR_' + ccattr.underscorify().to_upper(), cc.has_function_attribute(ccattr))
 endforeach
 
 ## Syscalls.
@@ -392,7 +389,7 @@ foreach tuple: [
     else
         ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
         ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
-        cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
+        cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
     endif
 
     if cond
@@ -422,9 +419,9 @@ foreach decl: [
 
     # We get -1 if the size cannot be determined
     if cc.sizeof(decl, prefix: decl_headers, args: '-D_GNU_SOURCE') > 0
-        conf.set10('HAVE_' + decl.underscorify().to_upper(), true)
+        srcconf.set10('HAVE_' + decl.underscorify().to_upper(), true)
     else
-        conf.set10('HAVE_' + decl.underscorify().to_upper(), false)
+        srcconf.set10('HAVE_' + decl.underscorify().to_upper(), false)
     endif
 endforeach
 
@@ -444,7 +441,7 @@ foreach tuple: [
     else
         ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
         ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
-        cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
+        cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
     endif
 
     if cond
@@ -521,7 +518,7 @@ foreach ident: [
 ]
 
     have = cc.has_function(ident[0], prefix: ident[1], args: '-D_GNU_SOURCE')
-    conf.set10('HAVE_' + ident[0].to_upper(), have)
+    srcconf.set10('HAVE_' + ident[0].to_upper(), have)
 endforeach
 
 found_headers = []
@@ -535,14 +532,14 @@ foreach tuple: [
     ['pty.h'],
     ['utmpx.h'],
 ]
-    conf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
+    srcconf.set10('HAVE_' + tuple[0].underscorify().to_upper(), cc.has_header(tuple[0]))
 
     if tuple.length() >= 2
         cond = tuple[1]
     else
         ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
         ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
-        cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
+        cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
     endif
 
     if cond
@@ -571,7 +568,7 @@ foreach tuple: [
     else
         ident1 = 'HAVE_' + tuple[0].underscorify().to_upper()
         ident2 = 'ENABLE_' + tuple[0].underscorify().to_upper()
-        cond = conf.get(ident1, 0) == 1 or conf.get(ident2, 0) == 1
+        cond = srcconf.get(ident1, 0) == 1 or srcconf.get(ident2, 0) == 1
     endif
 
     if cond
@@ -584,7 +581,7 @@ endforeach
 # Generate config.h
 config_h = configure_file(
         output: 'config.h',
-        configuration: conf)
+        configuration: srcconf)
 
 add_project_arguments('-include', 'config.h', language: 'c')
 
index 3165b95f4bc271dfa2622226dbf0b1c22bf4f99a..a4a0e2ebfbb0dc9915388c2d60c4c8000e41cb47 100644 (file)
@@ -8,50 +8,50 @@ netns_ifaddrs_sources = files(
     'netns_ifaddrs.c',
     'netns_ifaddrs.h')
 
-if conf.get('HAVE_GETLINE') == 0
+if srcconf.get('HAVE_GETLINE') == 0
     include_sources += files(
         'getline.c',
         'getline.h')
 endif
 
-if conf.get('HAVE_FEXECVE') == 0
+if srcconf.get('HAVE_FEXECVE') == 0
     include_sources += files(
         'fexecve.c',
         'fexecve.h')
 endif
 
 
-if conf.get('HAVE_GETGRGID_R') == 0
+if srcconf.get('HAVE_GETGRGID_R') == 0
     include_sources += files(
         'getgrgid_r.c',
         'getgrgid_r.h')
 endif
 
-if conf.get('HAVE_HASMNTOPT') == 0 or conf.get('HAVE_SETMNTENT') == 0 or conf.get('HAVE_ENDMNTENT') == 0
+if srcconf.get('HAVE_HASMNTOPT') == 0 or srcconf.get('HAVE_SETMNTENT') == 0 or srcconf.get('HAVE_ENDMNTENT') == 0
     include_sources += files(
         'lxcmntent.c',
         'lxcmntent.h')
 endif
 
-if conf.get('HAVE_STRLCPY') == 0
+if srcconf.get('HAVE_STRLCPY') == 0
     include_sources += files(
         'strlcpy.c',
         'strlcpy.h')
 endif
 
-if conf.get('HAVE_STRLCAT') == 0
+if srcconf.get('HAVE_STRLCAT') == 0
     include_sources += files(
         'strlcat.c',
         'strlcat.h')
 endif
 
-if conf.get('HAVE_STRCHRNUL') == 0
+if srcconf.get('HAVE_STRCHRNUL') == 0
     include_sources += files(
         'strchrnul.c',
         'strchrnul.h')
 endif
 
-if conf.get('HAVE_OPENPTY') == 0
+if srcconf.get('HAVE_OPENPTY') == 0
     include_sources += files(
         'openpty.c',
         'openpty.h')
index 2dc927bfc08c50cb9e317d498dd0a57c72e87d94..82ceab7c1b515da6e6bdf2fc88b3afd1e0e9851d 100644 (file)
@@ -159,15 +159,12 @@ cmd_lxc_checkconfig = configure_file(
     output: 'lxc-checkconfig')
 install_data(join_paths(project_build_root, 'src/lxc/cmd/lxc-checkconfig'), install_dir: bindir)
 
-cmd_lxc_update_config_data = configuration_data()
 cmd_lxc_update_config = configure_file(
     configuration: dummy_config_data,
     input: 'lxc-update-config.in',
     output: 'lxc-update-config')
 install_data(join_paths(project_build_root, 'src/lxc/cmd/lxc-update-config'), install_dir: bindir)
 
-cmd_lxc_update_config_data = configuration_data()
-
 cmd_programs += executable(
     'init.lxc.static',
     cmd_lxc_init_sources,
index 1274e51e793c1eb8e494b8332d09e5f551c96689..7555bc3aa293a6a275db1b51b850c6bc963ec3ba 100644 (file)
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
-if conf.get('HAVE_GETSUBOPT') == 0
+if srcconf.get('HAVE_GETSUBOPT') == 0
     include_sources += files(
         'getsubopt.c',
         'getsubopt.h')
index 53148b10c851e391fb3d75bf03e885699ff8b03e..83b43765f69c765a67eaedaf97121e56832cbf9a 100644 (file)
@@ -1,34 +1,28 @@
 # SPDX-License-Identifier: LGPL-2.1-or-later
 
 template_scripts = configure_file(
-    configuration: dummy_config_data,
+    configuration: conf,
     input: 'lxc-busybox.in',
     output: 'lxc-busybox',
     install: true,
     install_dir: lxctemplatedir)
 
-template_config_data = configuration_data()
-template_config_data.set_quoted('LXCHOOKDIR', lxchookdir)
-template_config_data.set_quoted('LXCTEMPLATECONFIG', lxctemplateconfdir)
-template_config_data.set_quoted('LOCALSTATEDIR', localstatedir)
-template_config_data.set_quoted('PACKAGE_VERSION', meson.project_version())
-
 template_scripts = configure_file(
-    configuration: template_config_data,
+    configuration: conf,
     input: 'lxc-download.in',
     output: 'lxc-download',
     install: true,
     install_dir: lxctemplatedir)
 
 template_scripts = configure_file(
-    configuration: template_config_data,
+    configuration: conf,
     input: 'lxc-local.in',
     output: 'lxc-local',
     install: true,
     install_dir: lxctemplatedir)
 
 template_scripts = configure_file(
-    configuration: template_config_data,
+    configuration: conf,
     input: 'lxc-oci.in',
     output: 'lxc-oci',
     install: true,