- lib = library(libname,
- sources,
- objects: objs,
- c_args: cflags,
- dependencies: dep_objs,
- include_directories: include_directories(dir_name),
- link_args: '-Wl,--version-script=' + version_map,
- link_depends: version_map,
- version: '@0@.1'.format(version),
- install: true)
- dep = declare_dependency(link_with: lib,
- include_directories: include_directories(dir_name),
- dependencies: dep_objs)
- set_variable('dep_' + libname, dep)
-
- dpdk_libraries = [lib] + dpdk_libraries
- endif
+ includes += include_directories(dir_name)
+
+ if sources.length() == 0
+ # if no C files, just set a dependency on header path
+ shared_dep = declare_dependency(include_directories: includes)
+ static_dep = shared_dep
+ else
+ if is_windows and use_function_versioning
+ message('@0@: Function versioning is not supported by Windows.'
+ .format(name))
+ endif
+
+ if use_function_versioning
+ cflags += '-DRTE_USE_FUNCTION_VERSIONING'
+ endif
+
+ # first build static lib
+ static_lib = static_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: static_deps,
+ include_directories: includes,
+ install: true)
+ static_dep = declare_dependency(
+ include_directories: includes,
+ dependencies: static_deps)
+
+ if not use_function_versioning or is_windows
+ # use pre-build objects to build shared lib
+ sources = []
+ objs += static_lib.extract_all_objects(recursive: false)
+ else
+ # for compat we need to rebuild with
+ # RTE_BUILD_SHARED_LIB defined
+ cflags += '-DRTE_BUILD_SHARED_LIB'
+ endif
+ version_map = '@0@/@1@/rte_@2@_version.map'.format(
+ meson.current_source_dir(), dir_name, name)
+ implib = dir_name + '.dll.a'
+
+ def_file = custom_target(libname + '_def',
+ command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+ input: version_map,
+ output: '@0@_exports.def'.format(libname))
+
+ mingw_map = custom_target(libname + '_mingw',
+ command: [map_to_win_cmd, '@INPUT@', '@OUTPUT@'],
+ input: version_map,
+ output: '@0@_mingw.map'.format(libname))
+
+ if is_ms_linker
+ lk_args = ['-Wl,/def:' + def_file.full_path(),
+ '-Wl,/implib:lib\\' + implib]
+ else
+ if is_windows
+ lk_args = ['-Wl,--version-script=' + mingw_map.full_path()]
+ else
+ lk_args = ['-Wl,--version-script=' + version_map]
+ endif
+ endif
+
+ lk_deps = [version_map, def_file, mingw_map]
+ if not is_windows
+ # on unix systems check the output of the
+ # check-symbols.sh script, using it as a
+ # dependency of the .so build
+ lk_deps += custom_target(name + '.sym_chk',
+ command: [check_symbols,
+ version_map, '@INPUT@'],
+ capture: true,
+ input: static_lib,
+ output: name + '.sym_chk')
+ endif
+
+ shared_lib = shared_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: shared_deps,
+ include_directories: includes,
+ link_args: lk_args,
+ link_depends: lk_deps,
+ version: abi_version,
+ soversion: so_version,
+ install: true)
+ shared_dep = declare_dependency(link_with: shared_lib,
+ include_directories: includes,
+ dependencies: shared_deps)
+
+ dpdk_libraries = [shared_lib] + dpdk_libraries
+ dpdk_static_libraries = [static_lib] + dpdk_static_libraries
+ endif # sources.length() > 0
+
+ set_variable('shared_rte_' + name, shared_dep)
+ set_variable('static_rte_' + name, static_dep)
+ message('lib/@0@: Defining dependency "@1@"'.format(
+ dir_name, name))
+ endif # if build