]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
meson: actually #define HAVE_ASPRINTF
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 18 Feb 2020 19:03:14 +0000 (20:03 +0100)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 18 Feb 2020 19:08:17 +0000 (20:08 +0100)
I believe this should now correctly enable the code iff it's needed.

This commits and the parent will probably be no-op in practice.
I believe distros commonly do use fortification by default,
and I'm not aware of any platform with kresd and without asprintf().

I considered using `conf_data.set()` in meson, but that would require
us modifying contrib/ccan/asprintf/asprintf.h to include kresconfig.h,
and that seemed weird.

meson.build

index a839eb2375cd53228423de204fa3fc2eae837efb..c6099a402246e9c44bbbd8b4faa925dad861ba5a 100644 (file)
@@ -87,6 +87,9 @@ message('--- optional dependencies ---')
 capng = dependency('libcap-ng', required: false)
 openssl = dependency('openssl', required: false)
 
+have_asprintf = meson.get_compiler('c').has_function('asprintf',
+  prefix: '#define _GNU_SOURCE\n#include <stdio.h>')
+
 ### sendmmsg
 has_sendmmsg = meson.get_compiler('c').has_function('sendmmsg',
   prefix: '#define _GNU_SOURCE\n#include <sys/socket.h>')
@@ -111,6 +114,7 @@ add_project_arguments(
   '-Wtype-limits',
   '-Wshadow',
   '-fvisibility=hidden',
+  '-DHAVE_ASPRINTF=' + have_asprintf.to_int().to_string(),
   language: 'c',
 )