]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - meson.build
meson: also search for libcap directly
[thirdparty/systemd.git] / meson.build
index a4c93de21af01753c0fac1ba3894c957d58468d4..c412aff91f23361cd8bd6c1c774587131d5538ec 100644 (file)
@@ -7,7 +7,7 @@ project('systemd', 'c',
                 'sysconfdir=/etc',
                 'localstatedir=/var',
         ],
-        meson_version : '>= 0.39.1',
+        meson_version : '>= 0.40',
        )
 
 # We need the same data in three different formats, ugh!
@@ -222,6 +222,7 @@ substs.set('RC_LOCAL_SCRIPT_PATH_STOP',                       get_option('halt-l
 
 cc = meson.get_compiler('c')
 pkgconfig = import('pkgconfig')
+check_compilation_sh = find_program('tools/meson-check-compilation.sh')
 
 foreach arg : ['-Wundef',
                '-Wlogical-op',
@@ -276,8 +277,7 @@ if cc.compiles('
            struct timespec now;
            return 0;
    }
-')
-        # TODO: message?
+', name : '-Werror=shadow with local shadowing')
         add_project_arguments('-Werror=shadow', language : 'c')
 endif
 
@@ -285,12 +285,15 @@ if cc.get_id() == 'clang'
         foreach arg : ['-Wno-typedef-redefinition',
                        '-Wno-gnu-variable-sized-type-not-at-end',
                       ]
-                if cc.has_argument(arg)
+                if cc.has_argument(arg,
+                                   name : '@0@ is supported'.format(arg))
                         add_project_arguments(arg, language : 'c')
                 endif
         endforeach
 endif
 
+link_test_c = files('tools/meson-link-test.c')
+
 # --as-needed and --no-undefined are provided by meson by default,
 # run mesonconf to see what is enabled
 foreach arg : ['-Wl,-z,relro',
@@ -298,11 +301,36 @@ foreach arg : ['-Wl,-z,relro',
                '-pie',
                '-Wl,-fuse-ld=gold',
               ]
-        if cc.has_argument(arg)
+
+        have = run_command(check_compilation_sh,
+                           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
                 add_project_link_arguments(arg, language : 'c')
         endif
 endforeach
 
+if get_option('buildtype') != 'debug'
+        foreach arg : ['-ffunction-sections',
+                       '-fdata-sections']
+                if cc.has_argument(arg,
+                                   name : '@0@ is supported'.format(arg))
+                        add_project_arguments(arg, language : 'c')
+                endif
+        endforeach
+
+        foreach arg : ['-Wl,--gc-sections']
+                have = run_command(check_compilation_sh,
+                                   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
+                        add_project_link_arguments(arg, language : 'c')
+                endif
+        endforeach
+endif
+
 cpp = ' '.join(cc.cmd_array()) + ' -E'
 
 #####################################################################
@@ -346,6 +374,7 @@ foreach decl : [['IFLA_INET6_ADDR_GEN_MODE',         'linux/if_link.h'],
                 ['IFLA_VLAN_PROTOCOL',               'linux/if_link.h'],
                 ['IFLA_VXLAN_REMCSUM_NOPARTIAL',     'linux/if_link.h'],
                 ['IFLA_VXLAN_GPE',                   'linux/if_link.h'],
+                ['IFLA_GENEVE_LABEL',                'linux/if_link.h'],
                 # if_tunnel.h is buggy and cannot be included on its own
                 ['IFLA_VTI_REMOTE',                  'linux/if_tunnel.h', '#include <net/if.h>'],
                 ['IFLA_IPTUN_ENCAP_DPORT',           'linux/if_tunnel.h', '#include <net/if.h>'],
@@ -407,14 +436,13 @@ endif
 sed = find_program('sed')
 grep = find_program('grep')
 awk = find_program('awk')
-m4 = find_program('/usr/bin/m4')
+m4 = find_program('m4')
 stat = find_program('stat')
 git = find_program('git', required : false)
 etags = find_program('etags', required : false)
 
 meson_make_symlink = meson.source_root() + '/tools/meson-make-symlink.sh'
 mkdir_p = 'mkdir -p $DESTDIR/@0@'
-check_compilation_sh = find_program('tools/meson-check-compilation.sh')
 test_efi_create_disk_sh = find_program('test/test-efi-create-disk.sh')
 splash_bmp = files('test/splash.bmp')
 
@@ -527,7 +555,7 @@ endif
 system_uid_max = system_uid_max.to_int()
 conf.set('SYSTEM_UID_MAX', system_uid_max)
 substs.set('systemuidmax', system_uid_max)
-message('Maximum system UID is @0@'.format(system_uid_max))
+message('maximum system UID is @0@'.format(system_uid_max))
 
 conf.set_quoted('NOBODY_USER_NAME', get_option('nobody-user'))
 conf.set_quoted('NOBODY_GROUP_NAME', get_option('nobody-group'))
@@ -542,7 +570,7 @@ endif
 system_gid_max = system_gid_max.to_int()
 conf.set('SYSTEM_GID_MAX', system_gid_max)
 substs.set('systemgidmax', system_gid_max)
-message('Maximum system GID is @0@'.format(system_gid_max))
+message('maximum system GID is @0@'.format(system_gid_max))
 
 tty_gid = get_option('tty-gid')
 conf.set('TTY_GID', tty_gid)
@@ -586,7 +614,12 @@ libm = cc.find_library('m')
 libdl = cc.find_library('dl')
 libcrypt = cc.find_library('crypt')
 
-libcap = dependency('libcap')
+libcap = dependency('libcap', required : false)
+if not libcap.found()
+        # Compat with Ubuntu 14.04 which ships libcap w/o .pc file
+        libcap = cc.find_library('cap')
+endif
+
 libmount = dependency('mount',
                       version : '>= 2.27')
 
@@ -627,18 +660,6 @@ else
         libapparmor = []
 endif
 
-want_smack = get_option('smack')
-if want_smack != 'false'
-        libsmack = dependency('libsmack',
-                              required : want_smack == 'true')
-        if libsmack.found()
-                conf.set('HAVE_SMACK', 1)
-                m4_defines += ['-DHAVE_SMACK']
-        endif
-else
-        libsmack = []
-endif
-
 smack_run_label = get_option('smack-run-label')
 if smack_run_label != ''
         conf.set_quoted('SMACK_RUN_LABEL', smack_run_label)
@@ -971,7 +992,9 @@ foreach pair : [['utmp',          'HAVE_UTMP'],
                 ['rfkill',        'ENABLE_RFKILL'],
                 ['ldconfig',      'ENABLE_LDCONFIG'],
                 ['efi',           'ENABLE_EFI'],
+                ['tpm',           'SD_BOOT_LOG_TPM'],
                 ['ima',           'HAVE_IMA'],
+                ['smack',         'HAVE_SMACK'],
                ]
 
         if get_option(pair[0])
@@ -1008,6 +1031,8 @@ if get_option('efi')
 
         conf.set('ENABLE_EFI', 1)
         conf.set_quoted('EFI_MACHINE_TYPE_NAME', EFI_MACHINE_TYPE_NAME)
+
+        conf.set('SD_TPM_PCR', get_option('tpm-pcrindex').to_int())
 endif
 
 #####################################################################
@@ -2314,3 +2339,22 @@ if git.found()
                 'git-contrib',
                 command : [meson_git_contrib_sh])
 endif
+
+if git.found()
+        git_head = run_command(
+                git,
+                ['--git-dir=@0@/.git'.format(meson.source_root()),
+                 'rev-parse', 'HEAD']).stdout().strip()
+        git_head_short = run_command(
+                git,
+                ['--git-dir=@0@/.git'.format(meson.source_root()),
+                 'rev-parse', '--short=7', 'HEAD']).stdout().strip()
+
+        run_target(
+                'git-snapshot',
+                command : ['git', 'archive',
+                           '-o', '@0@/systemd-@1@.tar.gz'.format(meson.source_root(),
+                                                                 git_head_short),
+                           '--prefix', 'systemd-@0@/'.format(git_head),
+                           'HEAD'])
+endif