From: Lennart Poettering Date: Mon, 25 Dec 2017 11:01:14 +0000 (+0100) Subject: meson: use "args" for setting _GNU_SOURCE when checking for functions X-Git-Tag: v237~179^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=85db59b794d1ca7f16ea816c916bb4472958cc1b;p=platform%2Fupstream%2Fsystemd.git meson: use "args" for setting _GNU_SOURCE when checking for functions This reworks how we set _GNU_SOURCE when checking for the availability of functions: 1. We set it for most of the functions we look for. After all we set it for our entire built anyway, and it's usually how Linux-specific definitions in glibc are protected these days. Given that we usually have checks for such modern stuff only anyway, let's just blanket enable it. 2. Use "args" instead of "prefix" to set the macro. This is what is suggested in the meson docs, hence let's do it. --- diff --git a/meson.build b/meson.build index f3a65b3..eda9e38 100644 --- a/meson.build +++ b/meson.build @@ -454,33 +454,29 @@ foreach ident : ['secure_getenv', '__secure_getenv'] endforeach foreach ident : [ - ['memfd_create', '''#define _GNU_SOURCE - #include '''], + ['memfd_create', '''#include '''], ['gettid', '''#include '''], ['pivot_root', '''#include '''], # no known header declares pivot_root - ['name_to_handle_at', '''#define _GNU_SOURCE - #include + ['name_to_handle_at', '''#include #include #include '''], - ['setns', '''#define _GNU_SOURCE - #include '''], + ['setns', '''#include '''], ['renameat2', '''#include '''], ['kcmp', '''#include '''], ['keyctl', '''#include #include '''], - ['copy_file_range', '''#define _GNU_SOURCE - #include + ['copy_file_range', '''#include #include '''], ['bpf', '''#include #include '''], ['explicit_bzero' , '''#include '''], ] - have = cc.has_function(ident[0], prefix : ident[1]) + have = cc.has_function(ident[0], prefix : ident[1], args : '-D_GNU_SOURCE') conf.set10('HAVE_' + ident[0].to_upper(), have) endforeach -if cc.has_function('getrandom', prefix : '''#include ''') +if cc.has_function('getrandom', prefix : '''#include ''', args : '-D_GNU_SOURCE') conf.set10('USE_SYS_RANDOM_H', true) conf.set10('HAVE_GETRANDOM', true) else