From 893c8fc625ed1d23654593b5b4018065b6f7730f Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Fri, 19 May 2023 15:09:28 +0200 Subject: [PATCH 1/3] Meson using libmagic pkgconfig --- meson.build | 35 +---------------------------------- 1 file changed, 1 insertion(+), 34 deletions(-) diff --git a/meson.build b/meson.build index b1b10144..0f1e43c7 100644 --- a/meson.build +++ b/meson.build @@ -32,40 +32,7 @@ if with_writer thread_dep = dependency('threads') zlib_dep = dependency('zlib', static:static_linkage) gumbo_dep = dependency('gumbo', static:static_linkage) - - magic_include_path = '' - magic_prefix_install = get_option('magic-install-prefix') - if magic_prefix_install == '' - if compiler.has_header('magic.h') - if find_library_in_compiler - magic_lib = compiler.find_library('magic') - else - magic_lib = find_library('magic') - endif - magic_dep = declare_dependency(link_args:['-lmagic']) - else - error('magic.h not found') - endif - else - if not find_library_in_compiler - error('For custom magic_prefix_install you need a meson version >=0.31.0') - endif - magic_include_path = magic_prefix_install + '/include' - magic_include_args = ['-I'+magic_include_path] - if compiler.has_header('magic.h', args:magic_include_args) - magic_include_dir = include_directories(magic_include_path, is_system:true) - magic_lib_path = join_paths(magic_prefix_install, get_option('libdir')) - magic_lib = compiler.find_library('magic', dirs:magic_lib_path, required:false) - if not magic_lib.found() - magic_lib_path = join_paths(magic_prefix_install, 'lib') - magic_lib = compiler.find_library('magic', dirs:magic_lib_path) - endif - magic_link_args = ['-L'+magic_lib_path, '-lmagic'] - magic_dep = declare_dependency(include_directories:magic_include_dir, link_args:magic_link_args) - else - error('magic.h not found') - endif - endif + magic_dep = dependency('libmagic', static:static_linkage) endif subdir('src') From e23dad35df5dd25840ac844799eda4f85b0aee64 Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sun, 21 May 2023 11:32:42 +0200 Subject: [PATCH 2/3] Workflows use now Ubuntu Focal to compile --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57ed0c00..76199388 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -42,10 +42,10 @@ jobs: - win32_dyn include: - target: native_static - image_variant: bionic + image_variant: focal lib_postfix: '/x86_64-linux-gnu' - target: native_dyn - image_variant: bionic + image_variant: focal lib_postfix: '/x86_64-linux-gnu' - target: win32_static image_variant: f35 From 328e2ca475e8268aaf2d0e7cf238dfddd557466e Mon Sep 17 00:00:00 2001 From: Emmanuel Engelhart Date: Sun, 21 May 2023 12:07:32 +0200 Subject: [PATCH 3/3] Reintroduce custom code for Ubuntu 20.04 Focal --- meson.build | 45 ++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0f1e43c7..83dd853b 100644 --- a/meson.build +++ b/meson.build @@ -32,7 +32,50 @@ if with_writer thread_dep = dependency('threads') zlib_dep = dependency('zlib', static:static_linkage) gumbo_dep = dependency('gumbo', static:static_linkage) - magic_dep = dependency('libmagic', static:static_linkage) + magic_dep = dependency('libmagic', static:static_linkage, required:false) + + # libmagic.pc has been introduced in version 5.39 of + # File. Unfortunately Ubuntu 20.04 (Focal) still uses version + # 5.38. Therefore we have to keep this special handling. As + # soon as Ubuntu 20.04 will move forward we will be able to remove + # this custom code. Check https://launchpad.net/ubuntu/+source/file + # and https://bugs.launchpad.net/ubuntu/+source/file/+bug/1951594 + if not magic_dep.found() + magic_include_path = '' + magic_prefix_install = get_option('magic-install-prefix') + if magic_prefix_install == '' + if compiler.has_header('magic.h') + if find_library_in_compiler + magic_lib = compiler.find_library('magic') + else + magic_lib = find_library('magic') + endif + magic_dep = declare_dependency(link_args:['-lmagic']) + else + error('magic.h not found') + endif + else + if not find_library_in_compiler + error('For custom magic_prefix_install you need a meson version >=0.31.0') + endif + magic_include_path = magic_prefix_install + '/include' + magic_include_args = ['-I'+magic_include_path] + if compiler.has_header('magic.h', args:magic_include_args) + magic_include_dir = include_directories(magic_include_path, is_system:true) + magic_lib_path = join_paths(magic_prefix_install, get_option('libdir')) + magic_lib = compiler.find_library('magic', dirs:magic_lib_path, required:false) + if not magic_lib.found() + magic_lib_path = join_paths(magic_prefix_install, 'lib') + magic_lib = compiler.find_library('magic', dirs:magic_lib_path) + endif + magic_link_args = ['-L'+magic_lib_path, '-lmagic'] + magic_dep = declare_dependency(include_directories:magic_include_dir, link_args:magic_link_args) + else + error('magic.h not found') + endif + endif + endif + endif subdir('src')