]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - meson.build
journalctl: drop format_journal_url() if gcrypt is not used
[thirdparty/systemd.git] / meson.build
index 8083cf655bceec7de6816b5e5f81684dfdbcb20d..5cfc24c2d6d5b47331d5c9a906245e9cfc679143 100644 (file)
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: LGPL-2.1+
 
 project('systemd', 'c',
-        version : '246',
+        version : '247',
         license : 'LGPLv2+',
         default_options: [
                 'c_std=gnu99',
@@ -13,7 +13,7 @@ project('systemd', 'c',
         meson_version : '>= 0.46',
        )
 
-libsystemd_version = '0.29.0'
+libsystemd_version = '0.30.0'
 libudev_version = '1.7.0'
 
 # We need the same data in two different formats, ugh!
@@ -38,8 +38,8 @@ relative_source_path = run_command('realpath',
                                    project_source_root).stdout().strip()
 conf.set_quoted('RELATIVE_SOURCE_PATH', relative_source_path)
 
-conf.set10('DEVELOPER_MODE', get_option('mode') == 'developer',
-           description : 'enable additional checks only suitable in development')
+conf.set('BUILD_MODE', 'BUILD_MODE_' + get_option('mode').to_upper(),
+         description : 'tailor build to development or release builds')
 
 want_ossfuzz = get_option('oss-fuzz')
 want_libfuzzer = get_option('llvm-fuzz')
@@ -299,6 +299,7 @@ substs.set('CERTIFICATEROOT',                                 get_option('certif
 substs.set('RANDOM_SEED',                                     join_paths(randomseeddir, 'random-seed'))
 substs.set('SYSTEM_SYSVINIT_PATH',                            sysvinit_path)
 substs.set('SYSTEM_SYSVRCND_PATH',                            sysvrcnd_path)
+substs.set('SYSTEMD_TEST_DATA',                               join_paths(testsdir, 'testdata'))
 substs.set('RC_LOCAL_PATH',                                   get_option('rc-local'))
 substs.set('MEMORY_ACCOUNTING_DEFAULT',                       memory_accounting_default ? 'yes' : 'no')
 substs.set('STATUS_UNIT_FORMAT_DEFAULT',                      status_unit_format_default)
@@ -531,6 +532,8 @@ foreach ident : [
                                  #include <unistd.h>
                                  #include <signal.h>
                                  #include <sys/wait.h>'''],
+        ['mallinfo',          '''#include <malloc.h>'''],
+        ['close_range',       '''#include <unistd.h>'''],
 ]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE')
@@ -694,35 +697,31 @@ if time_epoch == -1
 endif
 conf.set('TIME_EPOCH', time_epoch)
 
-system_uid_max = get_option('system-uid-max')
-if system_uid_max == -1
-        system_uid_max = run_command(
-                awk,
-                '/^\s*SYS_UID_MAX\s+/ { uid=$2 } END { print uid }',
-                '/etc/login.defs').stdout().strip()
-        if system_uid_max == ''
-                system_uid_max = 999
-        else
-                system_uid_max = system_uid_max.to_int()
+foreach tuple : [['system-alloc-uid-min', 'SYS_UID_MIN', 1],  # Also see login.defs(5).
+                 ['system-uid-max',       'SYS_UID_MAX', 999],
+                 ['system-alloc-gid-min', 'SYS_GID_MIN', 1],
+                 ['system-gid-max',       'SYS_GID_MAX', 999]]
+        v = get_option(tuple[0])
+        if v == -1
+                v = run_command(
+                        awk,
+                        '/^\s*@0@\s+/ { uid=$2 } END { print uid }'.format(tuple[1]),
+                        '/etc/login.defs').stdout().strip()
+                if v == ''
+                        v = tuple[2]
+                else
+                        v = v.to_int()
+                endif
         endif
+        conf.set(tuple[0].underscorify().to_upper(), v)
+        substs.set(tuple[0].underscorify().to_upper(), v)
+endforeach
+if conf.get('SYSTEM_ALLOC_UID_MIN') >= conf.get('SYSTEM_UID_MAX')
+        error('Invalid uid allocation range')
 endif
-conf.set('SYSTEM_UID_MAX', system_uid_max)
-substs.set('systemuidmax', system_uid_max)
-
-system_gid_max = get_option('system-gid-max')
-if system_gid_max == -1
-        system_gid_max = run_command(
-                awk,
-                '/^\s*SYS_GID_MAX\s+/ { gid=$2 } END { print gid }',
-                '/etc/login.defs').stdout().strip()
-        if system_gid_max == ''
-                system_gid_max = 999
-        else
-                system_gid_max = system_gid_max.to_int()
-        endif
+if conf.get('SYSTEM_ALLOC_GID_MIN') >= conf.get('SYSTEM_GID_MAX')
+        error('Invalid gid allocation range')
 endif
-conf.set('SYSTEM_GID_MAX', system_gid_max)
-substs.set('systemgidmax', system_gid_max)
 
 dynamic_uid_min = get_option('dynamic-uid-min')
 dynamic_uid_max = get_option('dynamic-uid-max')
@@ -884,8 +883,9 @@ libcrypt = cc.find_library('crypt')
 
 crypt_header = conf.get('HAVE_CRYPT_H') == 1 ? '''#include <crypt.h>''' : '''#include <unistd.h>'''
 foreach ident : [
-        ['crypt_ra',          crypt_header],
-        ['crypt_gensalt_ra',  crypt_header]]
+        ['crypt_ra',               crypt_header],
+        ['crypt_preferred_method', crypt_header],
+        ['crypt_gensalt_ra',       crypt_header]]
 
         have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE',
                                dependencies : libcrypt)
@@ -1412,6 +1412,18 @@ conf.set10('ENABLE_HOMED', have)
 have = have and conf.get('HAVE_PAM') == 1
 conf.set10('ENABLE_PAM_HOME', have)
 
+have = get_option('oomd')
+if have == 'auto'
+        have = get_option('mode') == 'developer'
+else
+        have = have == 'true'
+        if have and get_option('mode') != 'developer'
+                error('oomd is not available in release mode (yet)')
+        endif
+endif
+conf.set10('ENABLE_OOMD', have)
+substs.set10('ENABLE_OOMD', have)
+
 want_remote = get_option('remote')
 if want_remote != 'false'
         have_deps = [conf.get('HAVE_MICROHTTPD') == 1,
@@ -1470,8 +1482,11 @@ foreach term : ['analyze',
         have = get_option(term)
         name = 'ENABLE_' + term.underscorify().to_upper()
         conf.set10(name, have)
+        substs.set10(name, have)
 endforeach
 
+enable_sysusers = conf.get('ENABLE_SYSUSERS') == 1
+
 foreach tuple : [['nss-mymachines', 'machined'],
                  ['nss-resolve',    'resolve']]
         want = get_option(tuple[0])
@@ -1546,21 +1561,11 @@ meson_apply_m4 = find_program('tools/meson-apply-m4.sh')
 
 includes = include_directories('src/basic',
                                'src/boot',
+                               'src/core',
                                'src/home',
-                               'src/shared',
-                               'src/systemd',
                                'src/journal',
                                'src/journal-remote',
-                               'src/nspawn',
-                               'src/resolve',
-                               'src/timesync',
-                               'src/time-wait-sync',
-                               'src/login',
-                               'src/udev',
-                               'src/libudev',
-                               'src/core',
-                               'src/shutdown',
-                               'src/xdg-autostart-generator',
+                               'src/libsystemd-network',
                                'src/libsystemd/sd-bus',
                                'src/libsystemd/sd-device',
                                'src/libsystemd/sd-event',
@@ -1569,7 +1574,17 @@ includes = include_directories('src/basic',
                                'src/libsystemd/sd-netlink',
                                'src/libsystemd/sd-network',
                                'src/libsystemd/sd-resolve',
-                               'src/libsystemd-network',
+                               'src/libudev',
+                               'src/login',
+                               'src/nspawn',
+                               'src/resolve',
+                               'src/shared',
+                               'src/shutdown',
+                               'src/systemd',
+                               'src/time-wait-sync',
+                               'src/timesync',
+                               'src/udev',
+                               'src/xdg-autostart-generator',
                                '.')
 
 add_project_arguments('-include', 'config.h', language : 'c')
@@ -1668,6 +1683,7 @@ subdir('src/analyze')
 subdir('src/journal-remote')
 subdir('src/coredump')
 subdir('src/pstore')
+subdir('src/oom')
 subdir('src/hostname')
 subdir('src/import')
 subdir('src/partition')
@@ -2104,9 +2120,77 @@ endif
 
 public_programs += executable(
         'systemctl',
+        'src/systemctl/systemctl-add-dependency.c',
+        'src/systemctl/systemctl-add-dependency.h',
+        'src/systemctl/systemctl-cancel-job.c',
+        'src/systemctl/systemctl-cancel-job.h',
+        'src/systemctl/systemctl-clean-or-freeze.c',
+        'src/systemctl/systemctl-clean-or-freeze.h',
+        'src/systemctl/systemctl-compat-halt.c',
+        'src/systemctl/systemctl-compat-halt.h',
+        'src/systemctl/systemctl-compat-runlevel.c',
+        'src/systemctl/systemctl-compat-runlevel.h',
+        'src/systemctl/systemctl-compat-shutdown.c',
+        'src/systemctl/systemctl-compat-shutdown.h',
+        'src/systemctl/systemctl-compat-telinit.c',
+        'src/systemctl/systemctl-compat-telinit.h',
+        'src/systemctl/systemctl-daemon-reload.c',
+        'src/systemctl/systemctl-daemon-reload.h',
+        'src/systemctl/systemctl-edit.c',
+        'src/systemctl/systemctl-edit.h',
+        'src/systemctl/systemctl-enable.c',
+        'src/systemctl/systemctl-enable.h',
+        'src/systemctl/systemctl-is-active.c',
+        'src/systemctl/systemctl-is-active.h',
+        'src/systemctl/systemctl-is-enabled.c',
+        'src/systemctl/systemctl-is-enabled.h',
+        'src/systemctl/systemctl-is-system-running.c',
+        'src/systemctl/systemctl-is-system-running.h',
+        'src/systemctl/systemctl-kill.c',
+        'src/systemctl/systemctl-kill.h',
+        'src/systemctl/systemctl-list-dependencies.c',
+        'src/systemctl/systemctl-list-dependencies.h',
+        'src/systemctl/systemctl-list-jobs.c',
+        'src/systemctl/systemctl-list-jobs.h',
+        'src/systemctl/systemctl-list-machines.c',
+        'src/systemctl/systemctl-list-machines.h',
+        'src/systemctl/systemctl-list-unit-files.c',
+        'src/systemctl/systemctl-list-unit-files.h',
+        'src/systemctl/systemctl-list-units.c',
+        'src/systemctl/systemctl-list-units.h',
+        'src/systemctl/systemctl-log-setting.c',
+        'src/systemctl/systemctl-log-setting.h',
+        'src/systemctl/systemctl-logind.c',
+        'src/systemctl/systemctl-logind.h',
+        'src/systemctl/systemctl-preset-all.c',
+        'src/systemctl/systemctl-preset-all.h',
+        'src/systemctl/systemctl-reset-failed.c',
+        'src/systemctl/systemctl-reset-failed.h',
+        'src/systemctl/systemctl-service-watchdogs.c',
+        'src/systemctl/systemctl-service-watchdogs.h',
+        'src/systemctl/systemctl-set-default.c',
+        'src/systemctl/systemctl-set-default.h',
+        'src/systemctl/systemctl-set-environment.c',
+        'src/systemctl/systemctl-set-environment.h',
+        'src/systemctl/systemctl-set-property.c',
+        'src/systemctl/systemctl-set-property.h',
+        'src/systemctl/systemctl-show.c',
+        'src/systemctl/systemctl-show.h',
+        'src/systemctl/systemctl-start-special.c',
+        'src/systemctl/systemctl-start-special.h',
+        'src/systemctl/systemctl-start-unit.c',
+        'src/systemctl/systemctl-start-unit.h',
+        'src/systemctl/systemctl-switch-root.c',
+        'src/systemctl/systemctl-switch-root.h',
+        'src/systemctl/systemctl-sysv-compat.c',
+        'src/systemctl/systemctl-sysv-compat.h',
+        'src/systemctl/systemctl-trivial-method.c',
+        'src/systemctl/systemctl-trivial-method.h',
+        'src/systemctl/systemctl-util.c',
+        'src/systemctl/systemctl-util.c',
+        'src/systemctl/systemctl-util.h',
         'src/systemctl/systemctl.c',
-        'src/systemctl/sysv-compat.h',
-        'src/systemctl/sysv-compat.c',
+        'src/systemctl/systemctl.h',
         include_directories : includes,
         link_with : systemctl_link_with,
         dependencies : [threads,
@@ -2659,6 +2743,27 @@ if conf.get('ENABLE_PSTORE') == 1
                 install_dir : rootlibexecdir)
 endif
 
+if conf.get('ENABLE_OOMD') == 1
+        executable('systemd-oomd',
+                   systemd_oomd_sources,
+                   include_directories : includes,
+                   link_with : [libshared],
+                   dependencies : [],
+                   install_rpath : rootlibexecdir,
+                   install : true,
+                   install_dir : rootlibexecdir)
+
+        public_programs += executable(
+                   'oomctl',
+                   oomctl_sources,
+                   include_directories : includes,
+                   link_with : [libshared],
+                   dependencies : [],
+                   install_rpath : rootlibexecdir,
+                   install : true,
+                   install_dir : rootbindir)
+endif
+
 if conf.get('ENABLE_BINFMT') == 1
         public_programs += executable(
                 'systemd-binfmt',
@@ -2966,8 +3071,8 @@ public_programs += executable(
         install_rpath : rootlibexecdir,
         install : true)
 
-if conf.get('ENABLE_SYSUSERS') == 1
-        public_programs += executable(
+if enable_sysusers
+        exe = executable(
                 'systemd-sysusers',
                 'src/sysusers/sysusers.c',
                 include_directories : includes,
@@ -2975,12 +3080,21 @@ if conf.get('ENABLE_SYSUSERS') == 1
                 install_rpath : rootlibexecdir,
                 install : true,
                 install_dir : rootbindir)
+        public_programs += exe
+
+        if want_tests != 'false'
+                test('test-sysusers',
+                     test_sysusers_sh,
+                     # https://github.com/mesonbuild/meson/issues/2681
+                     args : exe.full_path())
+        endif
 
         if have_standalone_binaries
-                public_programs += executable(
+                exe = executable(
                         'systemd-sysusers.standalone',
                         'src/sysusers/sysusers.c',
                         include_directories : includes,
+                        c_args : '-DSTANDALONE',
                         link_with : [libshared_static,
                                      libbasic,
                                      libbasic_gcrypt,
@@ -2988,6 +3102,14 @@ if conf.get('ENABLE_SYSUSERS') == 1
                                      libjournal_client],
                         install : true,
                         install_dir : rootbindir)
+                public_programs += exe
+
+                if want_tests != 'false'
+                        test('test-sysusers.standalone',
+                             test_sysusers_sh,
+                             # https://github.com/mesonbuild/meson/issues/2681
+                             args : exe.full_path())
+                endif
         endif
 endif
 
@@ -3015,6 +3137,7 @@ if conf.get('ENABLE_TMPFILES') == 1
                         'systemd-tmpfiles.standalone',
                         systemd_tmpfiles_sources,
                         include_directories : includes,
+                        c_args : '-DSTANDALONE',
                         link_with : [libshared_static,
                                      libbasic,
                                      libbasic_gcrypt,
@@ -3215,6 +3338,7 @@ foreach tuple : tests
         type = tuple.length() >= 5 ? tuple[4] : ''
         defs = tuple.length() >= 6 ? tuple[5] : []
         incs = tuple.length() >= 7 ? tuple[6] : includes
+        parallel = tuple.length() >= 8 ? tuple[7] : true
         timeout = 30
 
         name = sources[0].split('/')[-1].split('.')[0]
@@ -3539,12 +3663,12 @@ status = [
                                                               get_option('debug-tty')),
         'TTY GID:                           @0@'.format(tty_gid),
         'users GID:                         @0@'.format(substs.get('USERS_GID')),
-        'maximum system UID:                @0@'.format(system_uid_max),
-        'maximum system GID:                @0@'.format(system_gid_max),
-        'minimum dynamic UID:               @0@'.format(dynamic_uid_min),
-        'maximum dynamic UID:               @0@'.format(dynamic_uid_max),
-        'minimum container UID base:        @0@'.format(container_uid_base_min),
-        'maximum container UID base:        @0@'.format(container_uid_base_max),
+        'system UIDs:                       <=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_UID_MAX'),
+                                                                        conf.get('SYSTEM_ALLOC_UID_MIN')),
+        'system GIDs:                       <=@0@ (alloc >=@1@)'.format(conf.get('SYSTEM_GID_MAX'),
+                                                                        conf.get('SYSTEM_ALLOC_GID_MIN')),
+        'dynamic UIDs:                      @0@–@1@'.format(dynamic_uid_min, dynamic_uid_max),
+        'container UID bases:               @0@–@1@'.format(container_uid_base_min, container_uid_base_max),
         '/dev/kvm access mode:              @0@'.format(get_option('dev-kvm-mode')),
         'render group access mode:          @0@'.format(get_option('group-render-mode')),
         'certificate root directory:        @0@'.format(get_option('certificate-root')),
@@ -3661,6 +3785,7 @@ foreach tuple : [
         ['DNS-over-TLS(openssl)', conf.get('DNS_OVER_TLS_USE_OPENSSL') == 1],
         ['coredump'],
         ['pstore'],
+        ['oomd'],
         ['polkit'],
         ['legacy pkla',      install_polkit_pkla],
         ['efi'],