From c3cef948b7f029d639cdf068e2db23beae22c83c Mon Sep 17 00:00:00 2001 From: Peng Yi <141570-nerditation@users.noreply.gitlab.gnome.org> Date: Sat, 20 Apr 2024 07:49:01 +0000 Subject: [PATCH 1/3] meson.build replace `cc.compiles()` to `cc.has_function()` to check functions --- meson.build | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index c18c7ae..61559ae 100644 --- a/meson.build +++ b/meson.build @@ -29,7 +29,9 @@ check_functions = [ ] conf = configuration_data() foreach check_function : check_functions - have_it = cc.compiles(''' + have_it = cc.has_function( + check_function, + prefix: ''' #include #include #include @@ -39,13 +41,8 @@ foreach check_function : check_functions #include #include #include - - int func (void) { - (void) ''' + check_function + '''; - } ''', args : '-D_GNU_SOURCE', - name : check_function + '() is declared', ) conf.set10('HAVE_DECL_' + check_function.underscorify().to_upper(), have_it) endforeach -- GitLab From 67e5e5bc721892092a79e81b2baee0663d658c44 Mon Sep 17 00:00:00 2001 From: Peng Yi <141570-nerditation@users.noreply.gitlab.gnome.org> Date: Sat, 20 Apr 2024 17:17:18 +0800 Subject: [PATCH 2/3] separate header files for individual functions according to man pages --- meson.build | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/meson.build b/meson.build index 61559ae..500b09e 100644 --- a/meson.build +++ b/meson.build @@ -23,25 +23,17 @@ cc = meson.get_compiler('c') check_functions = [ - 'renameat2', - 'memfd_create', - 'copy_file_range', + ['renameat2', 'stdio.h'], + ['memfd_create', 'sys/mman.h'], + ['copy_file_range', 'unistd.h'], ] conf = configuration_data() foreach check_function : check_functions + header_file = check_function[1] + check_function = check_function[0] have_it = cc.has_function( check_function, - prefix: ''' - #include - #include - #include - #include - #include - #include - #include - #include - #include - ''', + prefix: '#include <' + header_file + '>', args : '-D_GNU_SOURCE', ) conf.set10('HAVE_DECL_' + check_function.underscorify().to_upper(), have_it) -- GitLab From 507edf552bc0f61bc293f5b2dddf4048bb8106df Mon Sep 17 00:00:00 2001 From: Peng Yi <141570-nerditation@users.noreply.gitlab.gnome.org> Date: Sat, 20 Apr 2024 19:24:09 +0800 Subject: [PATCH 3/3] bare `cc.has_function()` can produces the correct result --- meson.build | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/meson.build b/meson.build index 500b09e..5caef90 100644 --- a/meson.build +++ b/meson.build @@ -23,19 +23,13 @@ cc = meson.get_compiler('c') check_functions = [ - ['renameat2', 'stdio.h'], - ['memfd_create', 'sys/mman.h'], - ['copy_file_range', 'unistd.h'], + 'renameat2', + 'memfd_create', + 'copy_file_range', ] conf = configuration_data() foreach check_function : check_functions - header_file = check_function[1] - check_function = check_function[0] - have_it = cc.has_function( - check_function, - prefix: '#include <' + header_file + '>', - args : '-D_GNU_SOURCE', - ) + have_it = cc.has_function(check_function) conf.set10('HAVE_DECL_' + check_function.underscorify().to_upper(), have_it) endforeach -- GitLab