From: Bruce Richardson <bruce.richardson@intel.com>
Date: Thu, 31 Aug 2017 10:36:43 +0000 (+0100)
Subject: build: add option to version libs using DPDK version
X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7b67398e60d738ca8125e566e9fa28f3db735b3c;p=dpdk.git

build: add option to version libs using DPDK version

Normally, each library has it's own version number based on the ABI.
Add an option to have all libs just use the DPDK version number as the
.so version.

Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
Reviewed-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Keith Wiles <keith.wiles@intel.com>
Acked-by: Luca Boccassi <luca.boccassi@gmail.com>
---

diff --git a/drivers/meson.build b/drivers/meson.build
index b4abc32f73..ee3bb473e6 100644
--- a/drivers/meson.build
+++ b/drivers/meson.build
@@ -97,6 +97,16 @@ foreach class:driver_classes
 						depends: [pmdinfogen, tmp_lib])
 			endforeach
 
+			if get_option('per_library_versions')
+				lib_version = '@0@.1'.format(version)
+				so_version = '@0@'.format(version)
+			else
+				pver = meson.project_version().split('.')
+				lib_version = '@0@.@1@'.format(pver.get(0),
+						pver.get(1))
+				so_version = lib_version
+			endif
+
 			# now build the driver itself, and add to the drivers list
 			lib_name = driver_name_fmt.format(name)
 			version_map = '@0@/@1@/@2@_version.map'.format(
@@ -110,7 +120,8 @@ foreach class:driver_classes
 				c_args: cflags,
 				link_args: '-Wl,--version-script=' + version_map,
 				link_depends: version_map,
-				version: '@0@.1'.format(version),
+				version: lib_version,
+				soversion: so_version,
 				install: true,
 				install_dir: driver_install_path)
 
diff --git a/lib/librte_eal/bsdapp/eal/meson.build b/lib/librte_eal/bsdapp/eal/meson.build
index 2bd62dd198..28ea4f3451 100644
--- a/lib/librte_eal/bsdapp/eal/meson.build
+++ b/lib/librte_eal/bsdapp/eal/meson.build
@@ -43,10 +43,20 @@ sources = ['eal_alarm.c',
 eal_extra_link_arg = '-lexecinfo'
 
 eal_inc += include_directories('../../../librte_compat')
+if get_option('per_library_versions')
+	lib_version = '@0@.1'.format(version)
+	so_version = '@0@'.format(version)
+else
+	pver = meson.project_version().split('.')
+	lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+	so_version = lib_version
+endif
+
 eal_lib = library('rte_eal', sources, eal_common_sources, eal_common_arch_sources,
 			dependencies: dependency('threads'),
 			include_directories : eal_inc,
-			version: '@0@.1'.format(version),
+			version: lib_version,
+			soversion: so_version,
 			c_args: ['-D_GNU_SOURCE', '-DALLOW_EXPERIMENTAL_API'],
 			link_depends: version_map,
 			link_args: [eal_extra_link_arg,
diff --git a/lib/librte_eal/linuxapp/eal/meson.build b/lib/librte_eal/linuxapp/eal/meson.build
index cb1b8fe51f..d4cdf3f394 100644
--- a/lib/librte_eal/linuxapp/eal/meson.build
+++ b/lib/librte_eal/linuxapp/eal/meson.build
@@ -48,10 +48,20 @@ sources = ['eal_alarm.c',
 
 eal_extra_link_arg = '-ldl'
 
+if get_option('per_library_versions')
+	lib_version = '@0@.1'.format(version)
+	so_version = '@0@'.format(version)
+else
+	pver = meson.project_version().split('.')
+	lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+	so_version = lib_version
+endif
+
 eal_lib = library('rte_eal', sources, eal_common_sources, eal_common_arch_sources,
 			dependencies: dependency('threads'),
 			include_directories : eal_inc,
-			version: '@0@.1'.format(version),
+			version: lib_version,
+			soversion: so_version,
 			c_args: ['-D_GNU_SOURCE', '-DALLOW_EXPERIMENTAL_API'],
 			link_depends: version_map,
 			link_args: [eal_extra_link_arg,
diff --git a/lib/meson.build b/lib/meson.build
index a4f5f28b15..0d4ec0daa1 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -86,6 +86,15 @@ foreach l:libraries
 			cflags += '-DALLOW_EXPERIMENTAL_API'
 		endif
 
+		if get_option('per_library_versions')
+			lib_version = '@0@.1'.format(version)
+			so_version = '@0@'.format(version)
+		else
+			pver = meson.project_version().split('.')
+			lib_version = '@0@.@1@'.format(pver.get(0), pver.get(1))
+			so_version = lib_version
+		endif
+
 		version_map = '@0@/@1@/rte_@2@_version.map'.format(
 				meson.current_source_dir(), dir_name, name)
 		libname = 'rte_' + name
@@ -97,7 +106,8 @@ foreach l:libraries
 				include_directories: include_directories(dir_name),
 				link_args: '-Wl,--version-script=' + version_map,
 				link_depends: version_map,
-				version: '@0@.1'.format(version),
+				version: lib_version,
+				soversion: so_version,
 				install: true)
 		dep = declare_dependency(link_with: lib,
 				include_directories: include_directories(dir_name),
diff --git a/meson_options.txt b/meson_options.txt
index 9c45b81596..636226ce8e 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -6,3 +6,4 @@ option('allow_invalid_socket_id', type: 'boolean', value: false,
 	description: 'allow out-of-range NUMA socket id\'s for platforms that don\'t report the value correctly')
 option('enable_kmods', type: 'boolean', value: true, description: 'build kernel modules')
 option('kernel_dir', type: 'string', value: '', description: 'path to the kernel for building kernel modules')
+option('per_library_versions', type: 'boolean', value: true, description: 'true: each lib gets its own version number, false: DPDK version used for each lib')