aboutsummaryrefslogtreecommitdiffhomepage
path: root/meson.build
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2024-12-03 21:03:38 -0600
committerCalvin Rose <calsrose@gmail.com>2024-12-03 21:05:37 -0600
commit5b79b48ae02f5a4c95a8fa671a13bf37d63e37ed (patch)
treecc09bb07342005120cad031b01fc70273dbb88e7 /meson.build
parentMerge pull request #1526 from sogaiu/master (diff)
Address #1524 - fix meson cross compilation linking.
In the cross compilation case, we need to resolve our dependencies on libc twice, once for the build machine and once for the target machine. This includes pthreads, -libc, and android-spawn.
Diffstat (limited to 'meson.build')
-rw-r--r--meson.build27
1 files changed, 19 insertions, 8 deletions
diff --git a/meson.build b/meson.build
index f17e8a59..0e829057 100644
--- a/meson.build
+++ b/meson.build
@@ -26,8 +26,17 @@ project('janet', 'c',
janet_path = join_paths(get_option('prefix'), get_option('libdir'), 'janet')
header_path = join_paths(get_option('prefix'), get_option('includedir'), 'janet')
-# Link math library on all systems
+# Compilers
cc = meson.get_compiler('c')
+native_cc = meson.get_compiler('c', native : true)
+
+# Native deps
+native_m_dep = native_cc.find_library('m', required : false)
+native_dl_dep = native_cc.find_library('dl', required : false)
+native_android_spawn_dep = native_cc.find_library('android-spawn', required : false)
+native_thread_dep = dependency('threads', native : true)
+
+# Deps
m_dep = cc.find_library('m', required : false)
dl_dep = cc.find_library('dl', required : false)
android_spawn_dep = cc.find_library('android-spawn', required : false)
@@ -164,11 +173,18 @@ mainclient_src = [
'src/mainclient/shell.c'
]
+janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
+janet_native_dependencies = [native_m_dep, native_dl_dep, native_android_spawn_dep]
+if not get_option('single_threaded')
+ janet_dependencies += thread_dep
+ janet_native_dependencies += native_thread_dep
+endif
+
# Build boot binary
janet_boot = executable('janet-boot', core_src, boot_src,
include_directories : incdir,
c_args : '-DJANET_BOOTSTRAP',
- dependencies : [m_dep, dl_dep, thread_dep, android_spawn_dep],
+ dependencies : janet_native_dependencies,
native : true)
# Build janet.c
@@ -181,11 +197,6 @@ janetc = custom_target('janetc',
'JANET_PATH', janet_path
])
-janet_dependencies = [m_dep, dl_dep, android_spawn_dep]
-if not get_option('single_threaded')
- janet_dependencies += thread_dep
-endif
-
# Allow building with no shared library
if cc.has_argument('-fvisibility=hidden')
lib_cflags = ['-fvisibility=hidden']
@@ -231,7 +242,7 @@ if meson.is_cross_build()
endif
janet_nativeclient = executable('janet-native', janetc, mainclient_src,
include_directories : incdir,
- dependencies : janet_dependencies,
+ dependencies : janet_native_dependencies,
c_args : extra_native_cflags,
native : true)
else