summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2019-03-13 16:22:09 +0000
committerRoss Burton <ross.burton@intel.com>2019-03-14 13:10:32 +0000
commitfc88e56bfc2b09a8fb2b350e76f6425ab0a056d7 (patch)
tree66590c9fea8234d6721400fffa5f786e0ff0ff00
parent3c44026dc4f22a80c05fd11270bd6cf8426f1771 (diff)
downloadglib-fc88e56bfc2b09a8fb2b350e76f6425ab0a056d7.tar.gz
meson: do a build-time check for strlcpy before attempting runtime check
In cross-compilation environments the runtime check isn't possible so it is up to the builder to seed the cross file, but we can definitely state that strlcpy doesn't exist with a build test.
-rw-r--r--meson.build35
1 files changed, 19 insertions, 16 deletions
diff --git a/meson.build b/meson.build
index 52c0ec44a..caf8a571b 100644
--- a/meson.build
+++ b/meson.build
@@ -1859,24 +1859,27 @@ if host_system != 'windows' and get_option('xattr')
endif
endif
-# Test if we have strlcpy/strlcat with a compatible implementation:
-# https://bugzilla.gnome.org/show_bug.cgi?id=53933
-if cc_can_run
- rres = cc.run('''#include <stdlib.h>
- #include <string.h>
- int main() {
- char p[10];
- (void) strlcpy (p, "hi", 10);
- if (strlcat (p, "bye", 0) != 3)
- return 1;
- return 0;
- }''',
- name : 'OpenBSD strlcpy/strlcat')
- if rres.compiled() and rres.returncode() == 0
+# If strlcpy is present (BSD and similar), check that it conforms to the BSD
+# specification. Specifically Solaris 8's strlcpy() does not, see
+# https://bugzilla.gnome.org/show_bug.cgi?id=53933 for further context.
+if cc.has_function('strlcpy')
+ if cc_can_run
+ rres = cc.run('''#include <stdlib.h>
+ #include <string.h>
+ int main() {
+ char p[10];
+ (void) strlcpy (p, "hi", 10);
+ if (strlcat (p, "bye", 0) != 3)
+ return 1;
+ return 0;
+ }''',
+ name : 'OpenBSD strlcpy/strlcat')
+ if rres.compiled() and rres.returncode() == 0
+ glib_conf.set('HAVE_STRLCPY', 1)
+ endif
+ elif meson.get_cross_property('have_strlcpy', false)
glib_conf.set('HAVE_STRLCPY', 1)
endif
-elif meson.get_cross_property('have_strlcpy', false)
- glib_conf.set('HAVE_STRLCPY', 1)
endif
python = import('python').find_installation('python3')