| 1 |
project('static dynamic', 'c') |
| 2 |
|
| 3 |
# Solaris does not ship static libraries |
| 4 |
if host_machine.system() == 'sunos' |
| 5 |
has_static = false |
| 6 |
else |
| 7 |
has_static = true |
| 8 |
endif |
| 9 |
|
| 10 |
cc = meson.get_compiler('c') |
| 11 |
|
| 12 |
z_default = cc.find_library('z') |
| 13 |
if has_static |
| 14 |
z_static = cc.find_library('z', static: true) |
| 15 |
endif |
| 16 |
z_dynamic = cc.find_library('z', static: false) |
| 17 |
|
| 18 |
exe_default = executable('main_default', 'main.c', dependencies: [z_default]) |
| 19 |
if has_static |
| 20 |
exe_static = executable('main_static', 'main.c', dependencies: [z_static]) |
| 21 |
endif |
| 22 |
exe_dynamic = executable('main_dynamic', 'main.c', dependencies: [z_dynamic]) |
| 23 |
|
| 24 |
test('test default', exe_default) |
| 25 |
if has_static |
| 26 |
test('test static', exe_static) |
| 27 |
endif |
| 28 |
test('test dynamic', exe_dynamic) |
| 29 |
|
| 30 |
if has_static |
| 31 |
test('verify static linking', find_program('verify_static.py'), |
| 32 |
args: ['--platform=' + host_machine.system(), exe_static.full_path()]) |
| 33 |
endif |
| 34 |
test('verify dynamic linking', find_program('verify_static.py'), |
| 35 |
args: ['--platform=' + host_machine.system(), exe_dynamic.full_path()], |
| 36 |
should_fail: true) |