- version_map = '@0@/@1@/rte_@2@_version.map'.format(
- meson.current_source_dir(), dir_name, name)
- libname = 'rte_' + name
- 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: lib_version,
- soversion: so_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
+ if allow_experimental_apis
+ cflags += '-DALLOW_EXPERIMENTAL_API'
+ endif
+
+ if get_option('per_library_versions')
+ lib_version = '@0@.1'.format(version)
+ so_version = '@0@'.format(version)
+ else
+ lib_version = major_version
+ so_version = major_version
+ 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(link_with: static_lib,
+ include_directories: includes,
+ dependencies: static_deps)
+
+ # then use pre-build objects to build shared lib
+ sources = []
+ objs += static_lib.extract_all_objects(recursive: false)
+ version_map = '@0@/@1@/rte_@2@_version.map'.format(
+ meson.current_source_dir(), dir_name, name)
+ exports = []
+ implib = dir_name + '.dll.a'
+ if is_windows
+ exports = '@0@/@1@/rte_@2@_exports.def'.format(
+ meson.current_source_dir(), dir_name, name)
+ lk_args = ['-Wl,/def:' + exports, '-Wl,/implib:lib\\' + implib]
+ else
+ lk_args = ['-Wl,--version-script=' + version_map]
+ endif
+ shared_lib = shared_library(libname,
+ sources,
+ objects: objs,
+ c_args: cflags,
+ dependencies: shared_deps,
+ include_directories: includes,
+ link_args: lk_args,
+ link_depends: [version_map, exports],
+ version: lib_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_' + libname, shared_dep)
+ set_variable('static_' + libname, static_dep)
+ endif # if build