1project('linker script', 'c') 2 3# Solaris 11.4 ld supports --version-script only when you also specify 4# -z gnu-version-script-compat 5if meson.get_compiler('c').get_linker_id() == 'ld.solaris' 6 add_project_link_arguments('-Wl,-z,gnu-version-script-compat', language: 'C') 7endif 8 9# Static map file 10mapfile = 'bob.map' 11vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) 12 13l = shared_library('bob', 'bob.c', link_args : vflag, link_depends : mapfile) 14e = executable('prog', 'prog.c', link_with : l) 15test('core', e) 16 17# configure_file 18conf = configuration_data() 19conf.set('in', 'bobMcBob') 20m = configure_file( 21 input : 'bob.map.in', 22 output : 'bob-conf.map', 23 configuration : conf, 24) 25vflag = '-Wl,--version-script,@0@'.format(m) 26 27l = shared_library('bob-conf', 'bob.c', link_args : vflag, link_depends : m) 28e = executable('prog-conf', 'prog.c', link_with : l) 29test('core', e) 30 31# custom_target 32python = find_program('python3') 33m = custom_target( 34 'bob-ct.map', 35 command : [python, '@INPUT0@', '@INPUT1@', 'bob-ct.map'], 36 input : ['copy.py', 'bob.map'], 37 output : 'bob-ct.map', 38 depend_files : 'bob.map', 39) 40vflag = '-Wl,--version-script,@0@'.format(m.full_path()) 41 42l = shared_library('bob-ct', ['bob.c', m], link_args : vflag, link_depends : m) 43e = executable('prog-ct', 'prog.c', link_with : l) 44test('core', e) 45 46# File 47mapfile = files('bob.map') 48vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile[0]) 49 50l = shared_library('bob-files', 'bob.c', link_args : vflag, link_depends : mapfile) 51e = executable('prog-files', 'prog.c', link_with : l) 52test('core', e) 53 54subdir('sub') 55 56# With map file in subdir 57mapfile = 'sub/foo.map' 58vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) 59 60l = shared_library('bar', 'bob.c', link_args : vflag, link_depends : mapfile) 61e = executable('prog-bar', 'prog.c', link_with : l) 62test('core', e) 63