diff --git a/meson.build b/meson.build index 2fabd0a3..2a813b74 100644 --- a/meson.build +++ b/meson.build @@ -35,7 +35,15 @@ else required: get_option('tls')) endif -if host_machine.system() == 'darwin' and get_option('darwin-arch-sanity-check') +darwin_arch_sanity_check = get_option('darwin-arch-sanity-check') +if host_machine.system() == 'darwin' and darwin_arch_sanity_check + darwin_arch_sanity_check_env = run_command('sh', '-c', 'printf %s "$ZOITECHAT_DARWIN_ARCH_SANITY_CHECK"', check: false).stdout().strip().to_lower() + if ['0', 'false', 'no', 'off'].contains(darwin_arch_sanity_check_env) + darwin_arch_sanity_check = false + endif +endif + +if host_machine.system() == 'darwin' and darwin_arch_sanity_check cflags_env = run_command('sh', '-c', 'printf %s "$CFLAGS"', check: false).stdout().strip() ldflags_env = run_command('sh', '-c', 'printf %s "$LDFLAGS"', check: false).stdout().strip() pkgconfig_glib = run_command('pkg-config', '--libs-only-L', 'glib-2.0', check: false) @@ -46,7 +54,7 @@ if host_machine.system() == 'darwin' and get_option('darwin-arch-sanity-check') if targeting_x86_64 and using_arm_homebrew error('Detected x86_64 build flags (-arch x86_64) while pkg-config resolves glib from /opt/homebrew (arm64). ' + 'Use arm64 build flags with /opt/homebrew, or run an x86_64/Rosetta environment with an x86_64 dependency stack (typically /usr/local). ' + - 'To bypass this safety check, configure with -Ddarwin-arch-sanity-check=false.') + 'To bypass this safety check, configure with -Ddarwin-arch-sanity-check=false or set ZOITECHAT_DARWIN_ARCH_SANITY_CHECK=0.') endif endif