]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - meson.build
journal: losen restrictions on journal file suffix (#8013)
[thirdparty/systemd.git] / meson.build
index 924274de630af0d1c3b28dc24d2987efdedb6a5f..d808c41c2053170a20eb48786719eb9ecd85d2bf 100644 (file)
@@ -16,7 +16,7 @@
 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
 
 project('systemd', 'c',
-        version : '236',
+        version : '237',
         license : 'LGPLv2+',
         default_options: [
                 'c_std=gnu99',
@@ -27,8 +27,8 @@ project('systemd', 'c',
         meson_version : '>= 0.41',
        )
 
-libsystemd_version = '0.20.0'
-libudev_version = '1.6.8'
+libsystemd_version = '0.21.0'
+libudev_version = '1.6.9'
 
 # We need the same data in three different formats, ugh!
 # Also, for hysterical reasons, we use different variable
@@ -260,10 +260,25 @@ cc = meson.get_compiler('c')
 pkgconfig = import('pkgconfig')
 check_compilation_sh = find_program('tools/meson-check-compilation.sh')
 
-cxx = find_program('c++', required : false)
-if cxx.found()
-        #  Used only for tests
-        add_languages('cpp')
+if get_option('tests') != 'false'
+        cxx = find_program('c++', required : false)
+        if cxx.found()
+                #  Used only for tests
+                add_languages('cpp')
+        endif
+endif
+
+want_ossfuzz = get_option('oss-fuzz')
+want_libfuzzer = get_option('llvm-fuzz')
+fuzzer_build = want_ossfuzz or want_libfuzzer
+if want_ossfuzz and want_libfuzzer
+        error('only one of oss-fuzz and llvm-fuzz can be specified')
+endif
+if want_libfuzzer
+        fuzzing_engine = meson.get_compiler('cpp').find_library('Fuzzer')
+endif
+if want_ossfuzz
+        fuzzing_engine = meson.get_compiler('cpp').find_library('FuzzingEngine')
 endif
 
 foreach arg : ['-Wextra',
@@ -300,7 +315,6 @@ foreach arg : ['-Wextra',
                '-fvisibility=hidden',
                '-fstack-protector',
                '-fstack-protector-strong',
-               '-fPIE',
                '--param=ssp-buffer-size=4',
               ]
         if cc.has_argument(arg)
@@ -308,6 +322,14 @@ foreach arg : ['-Wextra',
         endif
 endforeach
 
+# the oss-fuzz fuzzers are not built with -fPIE, so don't
+# enable it when we are linking against them
+if not fuzzer_build
+        if cc.has_argument('-fPIE')
+              add_project_arguments('-fPIE', language : 'c')
+        endif
+endif
+
 # "negative" arguments: gcc on purpose does not return an error for "-Wno-"
 # arguments, just emits a warnings. So test for the "positive" version instead.
 foreach arg : ['unused-parameter',
@@ -358,7 +380,7 @@ foreach arg : ['-Wl,-z,relro',
                            cc.cmd_array(), '-x', 'c', arg,
                            '-include', link_test_c).returncode() == 0
         message('Linking with @0@ supported: @1@'.format(arg, have ? 'yes' : 'no'))
-        if have
+        if have and (arg != '-pie' or not fuzzer_build)
                 add_project_link_arguments(arg, language : 'c')
         endif
 endforeach
@@ -567,7 +589,8 @@ conf.set('GPERF_LEN_TYPE', gperf_len_type,
 if not cc.has_header('sys/capability.h')
         error('POSIX caps headers not found')
 endif
-foreach header : ['linux/btrfs.h',
+foreach header : ['crypt.h',
+                  'linux/btrfs.h',
                   'linux/memfd.h',
                   'linux/vm_sockets.h',
                   'sys/auxv.h',
@@ -765,10 +788,11 @@ if not libcap.found()
 endif
 
 libmount = dependency('mount',
-                      version : '>= 2.30')
+                      version : '>= 2.30',
+                      required : not fuzzer_build)
 
 want_seccomp = get_option('seccomp')
-if want_seccomp != 'false'
+if want_seccomp != 'false' and not fuzzer_build
         libseccomp = dependency('libseccomp',
                                 version : '>= 2.3.1',
                                 required : want_seccomp == 'true')
@@ -781,7 +805,7 @@ conf.set10('HAVE_SECCOMP', have)
 m4_defines += have ? ['-DHAVE_SECCOMP'] : []
 
 want_selinux = get_option('selinux')
-if want_selinux != 'false'
+if want_selinux != 'false' and not fuzzer_build
         libselinux = dependency('libselinux',
                                 version : '>= 2.1.9',
                                 required : want_selinux == 'true')
@@ -794,7 +818,7 @@ conf.set10('HAVE_SELINUX', have)
 m4_defines += have ? ['-DHAVE_SELINUX'] : []
 
 want_apparmor = get_option('apparmor')
-if want_apparmor != 'false'
+if want_apparmor != 'false' and not fuzzer_build
         libapparmor = dependency('libapparmor',
                                  required : want_apparmor == 'true')
         have = libapparmor.found()
@@ -814,7 +838,7 @@ endif
 want_polkit = get_option('polkit')
 install_polkit = false
 install_polkit_pkla = false
-if want_polkit != 'false'
+if want_polkit != 'false' and not fuzzer_build
         install_polkit = true
 
         libpolkit = dependency('polkit-gobject-1',
@@ -827,7 +851,7 @@ endif
 conf.set10('ENABLE_POLKIT', install_polkit)
 
 want_acl = get_option('acl')
-if want_acl != 'false'
+if want_acl != 'false' and not fuzzer_build
         libacl = cc.find_library('acl', required : want_acl == 'true')
         have = libacl.found()
 else
@@ -838,7 +862,7 @@ conf.set10('HAVE_ACL', have)
 m4_defines += have ? ['-DHAVE_ACL'] : []
 
 want_audit = get_option('audit')
-if want_audit != 'false'
+if want_audit != 'false' and not fuzzer_build
         libaudit = dependency('audit', required : want_audit == 'true')
         have = libaudit.found()
 else
@@ -848,7 +872,7 @@ endif
 conf.set10('HAVE_AUDIT', have)
 
 want_blkid = get_option('blkid')
-if want_blkid != 'false'
+if want_blkid != 'false' and not fuzzer_build
         libblkid = dependency('blkid', required : want_blkid == 'true')
         have = libblkid.found()
 else
@@ -858,7 +882,7 @@ endif
 conf.set10('HAVE_BLKID', have)
 
 want_kmod = get_option('kmod')
-if want_kmod != 'false'
+if want_kmod != 'false' and not fuzzer_build
         libkmod = dependency('libkmod',
                              version : '>= 15',
                              required : want_kmod == 'true')
@@ -870,7 +894,7 @@ endif
 conf.set10('HAVE_KMOD', have)
 
 want_pam = get_option('pam')
-if want_pam != 'false'
+if want_pam != 'false' and not fuzzer_build
         libpam = cc.find_library('pam', required : want_pam == 'true')
         libpam_misc = cc.find_library('pam_misc', required : want_pam == 'true')
         have = libpam.found() and libpam_misc.found()
@@ -883,7 +907,7 @@ conf.set10('HAVE_PAM', have)
 m4_defines += have ? ['-DHAVE_PAM'] : []
 
 want_microhttpd = get_option('microhttpd')
-if want_microhttpd != 'false'
+if want_microhttpd != 'false' and not fuzzer_build
         libmicrohttpd = dependency('libmicrohttpd',
                                    version : '>= 0.9.33',
                                    required : want_microhttpd == 'true')
@@ -896,7 +920,7 @@ conf.set10('HAVE_MICROHTTPD', have)
 m4_defines += have ? ['-DHAVE_MICROHTTPD'] : []
 
 want_libcryptsetup = get_option('libcryptsetup')
-if want_libcryptsetup != 'false'
+if want_libcryptsetup != 'false' and not fuzzer_build
         libcryptsetup = dependency('libcryptsetup',
                                    version : '>= 1.6.0',
                                    required : want_libcryptsetup == 'true')
@@ -908,7 +932,7 @@ endif
 conf.set10('HAVE_LIBCRYPTSETUP', have)
 
 want_libcurl = get_option('libcurl')
-if want_libcurl != 'false'
+if want_libcurl != 'false' and not fuzzer_build
         libcurl = dependency('libcurl',
                              version : '>= 7.32.0',
                              required : want_libcurl == 'true')
@@ -926,7 +950,7 @@ if want_libidn == 'true' and want_libidn2 == 'true'
         error('libidn and libidn2 cannot be requested simultaneously')
 endif
 
-if want_libidn != 'false' and want_libidn2 != 'true'
+if want_libidn != 'false' and want_libidn2 != 'true' and not fuzzer_build
         libidn = dependency('libidn',
                             required : want_libidn == 'true')
         have = libidn.found()
@@ -936,7 +960,7 @@ else
 endif
 conf.set10('HAVE_LIBIDN', have)
 m4_defines += have ? ['-DHAVE_LIBIDN'] : []
-if not have and want_libidn2 != 'false'
+if not have and want_libidn2 != 'false' and not fuzzer_build
         # libidn is used for both libidn and libidn2 objects
         libidn = dependency('libidn2',
                             required : want_libidn2 == 'true')
@@ -948,7 +972,7 @@ conf.set10('HAVE_LIBIDN2', have)
 m4_defines += have ? ['-DHAVE_LIBIDN2'] : []
 
 want_libiptc = get_option('libiptc')
-if want_libiptc != 'false'
+if want_libiptc != 'false' and not fuzzer_build
         libiptc = dependency('libiptc',
                              required : want_libiptc == 'true')
         have = libiptc.found()
@@ -960,7 +984,7 @@ conf.set10('HAVE_LIBIPTC', have)
 m4_defines += have ? ['-DHAVE_LIBIPTC'] : []
 
 want_qrencode = get_option('qrencode')
-if want_qrencode != 'false'
+if want_qrencode != 'false' and not fuzzer_build
         libqrencode = dependency('libqrencode',
                                  required : want_qrencode == 'true')
         have = libqrencode.found()
@@ -971,7 +995,7 @@ endif
 conf.set10('HAVE_QRENCODE', have)
 
 want_gcrypt = get_option('gcrypt')
-if want_gcrypt != 'false'
+if want_gcrypt != 'false' and not fuzzer_build
         libgcrypt = cc.find_library('gcrypt', required : want_gcrypt == 'true')
         libgpg_error = cc.find_library('gpg-error', required : want_gcrypt == 'true')
         have = libgcrypt.found() and libgpg_error.found()
@@ -986,7 +1010,7 @@ endif
 conf.set10('HAVE_GCRYPT', have)
 
 want_gnutls = get_option('gnutls')
-if want_gnutls != 'false'
+if want_gnutls != 'false' and not fuzzer_build
         libgnutls = dependency('gnutls',
                                version : '>= 3.1.4',
                                required : want_gnutls == 'true')
@@ -998,7 +1022,7 @@ endif
 conf.set10('HAVE_GNUTLS', have)
 
 want_elfutils = get_option('elfutils')
-if want_elfutils != 'false'
+if want_elfutils != 'false' and not fuzzer_build
         libdw = dependency('libdw',
                            required : want_elfutils == 'true')
         have = libdw.found()
@@ -1009,7 +1033,7 @@ endif
 conf.set10('HAVE_ELFUTILS', have)
 
 want_zlib = get_option('zlib')
-if want_zlib != 'false'
+if want_zlib != 'false' and not fuzzer_build
         libz = dependency('zlib',
                           required : want_zlib == 'true')
         have = libz.found()
@@ -1020,7 +1044,7 @@ endif
 conf.set10('HAVE_ZLIB', have)
 
 want_bzip2 = get_option('bzip2')
-if want_bzip2 != 'false'
+if want_bzip2 != 'false' and not fuzzer_build
         libbzip2 = cc.find_library('bz2',
                                    required : want_bzip2 == 'true')
         have = libbzip2.found()
@@ -1031,7 +1055,7 @@ endif
 conf.set10('HAVE_BZIP2', have)
 
 want_xz = get_option('xz')
-if want_xz != 'false'
+if want_xz != 'false' and not fuzzer_build
         libxz = dependency('liblzma',
                            required : want_xz == 'true')
         have = libxz.found()
@@ -1042,7 +1066,7 @@ endif
 conf.set10('HAVE_XZ', have)
 
 want_lz4 = get_option('lz4')
-if want_lz4 != 'false'
+if want_lz4 != 'false' and not fuzzer_build
         liblz4 = dependency('liblz4',
                             required : want_lz4 == 'true')
         have = liblz4.found()
@@ -1053,7 +1077,7 @@ endif
 conf.set10('HAVE_LZ4', have)
 
 want_xkbcommon = get_option('xkbcommon')
-if want_xkbcommon != 'false'
+if want_xkbcommon != 'false' and not fuzzer_build
         libxkbcommon = dependency('xkbcommon',
                                   version : '>= 0.3.0',
                                   required : want_xkbcommon == 'true')
@@ -1065,7 +1089,7 @@ endif
 conf.set10('HAVE_XKBCOMMON', have)
 
 want_glib = get_option('glib')
-if want_glib != 'false'
+if want_glib != 'false' and not fuzzer_build
         libglib =    dependency('glib-2.0',
                                 version : '>= 2.22.0',
                                 required : want_glib == 'true')
@@ -1084,7 +1108,7 @@ endif
 conf.set10('HAVE_GLIB', have)
 
 want_dbus = get_option('dbus')
-if want_dbus != 'false'
+if want_dbus != 'false' and not fuzzer_build
         libdbus = dependency('dbus-1',
                              version : '>= 1.3.2',
                              required : want_dbus == 'true')
@@ -1096,6 +1120,9 @@ endif
 conf.set10('HAVE_DBUS', have)
 
 default_dnssec = get_option('default-dnssec')
+if fuzzer_build
+        default_dnssec = 'no'
+endif
 if default_dnssec != 'no' and conf.get('HAVE_GCRYPT') == 0
         message('default-dnssec cannot be set to yes or allow-downgrade when gcrypt is disabled. Setting default-dnssec to no.')
         default_dnssec = 'no'
@@ -1176,6 +1203,7 @@ endforeach
 want_tests = get_option('tests')
 install_tests = get_option('install-tests')
 tests = []
+fuzzers = []
 
 conf.set10('SYSTEMD_SLOW_TESTS_DEFAULT', get_option('slow-tests'))
 
@@ -1301,6 +1329,7 @@ subdir('src/vconsole')
 subdir('src/boot/efi')
 
 subdir('src/test')
+subdir('src/fuzz')
 subdir('rules')
 subdir('test')
 
@@ -2404,8 +2433,9 @@ foreach tuple : tests
                 timeout = type.split('=')[1].to_int()
                 type = ''
         endif
-
-        if condition == '' or conf.get(condition) == 1
+        if want_tests == 'false'
+                message('Not compiling @0@ because tests is set to false'.format(name))
+        elif condition == '' or conf.get(condition) == 1
                 exe = executable(
                         name,
                         sources,
@@ -2454,6 +2484,39 @@ test('test-libudev-sym',
 
 ############################################################
 
+fuzzer_exes = []
+
+foreach tuple : fuzzers
+        sources = tuple[0]
+        link_with = tuple[1].length() > 0 ? tuple[1] : [libshared]
+        dependencies = tuple[2]
+        defs = tuple.length() >= 4 ? tuple[3] : []
+        incs = tuple.length() >= 5 ? tuple[4] : includes
+
+        if fuzzer_build
+                dependencies += fuzzing_engine
+        else
+                sources += 'src/fuzz/fuzz-main.c'
+        endif
+
+        name = sources[0].split('/')[-1].split('.')[0]
+
+        fuzzer_exes += executable(
+                name,
+                sources,
+                include_directories : [incs, include_directories('src/fuzz')],
+                link_with : link_with,
+                dependencies : dependencies,
+                c_args : defs,
+                install : false)
+endforeach
+
+run_target('fuzzers',
+        depends : fuzzer_exes,
+        command : ['true'])
+
+############################################################
+
 make_directive_index_py = find_program('tools/make-directive-index.py')
 make_man_index_py = find_program('tools/make-man-index.py')
 xml_helper_py = find_program('tools/xml_helper.py')