]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
meson: use library() and rely on user settings
authorKlaus Jensen <k.jensen@samsung.com>
Mon, 18 Oct 2021 21:00:10 +0000 (23:00 +0200)
committerKlaus Jensen <k.jensen@samsung.com>
Mon, 18 Oct 2021 21:15:26 +0000 (23:15 +0200)
There is no need to have both _static and _shared targets. Just use
library(). Project using libnvme as a subproject can now just set

  default_options: ['default_library=static']

in the subproject statement to choose the library version.

For pkgconfig, simplify and let the module figure out Libs and Requires.
This has the effect of removing Requires and making it a
Requires.private so we don't require libnvme consumers to link with
libuuid and json-c (unless they specifically needs to use it like
test/test.c).

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
examples/meson.build
meson.build
pynvme/meson.build
src/meson.build
test/meson.build

index 0ed97d001e49f22dcd897fcd9567d481af542f18..0bf911d59753c1b40dd6db349c892ae5ceb839f9 100644 (file)
@@ -8,18 +8,18 @@
 executable(
     'telemetry-listen',
     ['telemetry-listen.c'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir)
 
 executable(
     'display-columnar',
     ['display-columnar.c'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir)
 
 executable(
     'discover-loop',
     ['discover-loop.c'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir)
 
index 271c48a90e3f27e9b4d1b6c3a80a1741ada29649..fc72ff5fbf650010bf27aed616b0998cb717d6f9 100644 (file)
@@ -187,18 +187,6 @@ configure_file(
     configuration: substs,
 )
 
-################################################################################
-pkg = import('pkgconfig')
-pkg.generate(
-    filebase: meson.project_name(),
-    name: meson.project_name(),
-    version: meson.project_version(),
-    description: 'Manage "libnvme" subsystem devices (Non-volatile Memory Express)',
-    url: 'http://github.com/linux-nvme/libnvme/',
-    libraries: ['-L${libdir}', '-lnvme'],
-    requires: [libuuid, libjson],
-)
-
 ################################################################################
 add_project_arguments(['-fomit-frame-pointer', '-D_GNU_SOURCE', '-include', 'config.h'], language : 'c')
 incdir = include_directories(['.', 'ccan', 'src'])
index 846e8e342165f474cd2c47fe2acd8a5ffc63f295..5e9c96d45046a117b1bdecfebf357f1dcb485b3d 100644 (file)
@@ -22,7 +22,7 @@ if swig.found()
         pymod_swig[1],
         dependencies : python3.dependency(),
         include_directories: incdir,
-        link_with: libnvme_static,
+        link_with: libnvme,
         install: true,
         subdir: 'libnvme',
     )
index 15949c950ad9c0f6b7ab4e1c9987dc83e09fea13..c5673325bffbe9ff7bbe51c1a9dac5faf4acf49a 100644 (file)
@@ -29,7 +29,7 @@ source_dir = meson.current_source_dir()
 mapfile = 'libnvme.map'
 version_script_arg = join_paths(source_dir, mapfile)
 
-libnvme_shared = shared_library(
+libnvme = library(
     'nvme', # produces libnvme.so
     sources,
     version: meson.project_version(),
@@ -41,24 +41,18 @@ libnvme_shared = shared_library(
     install: true,
 )
 
-libnvme_static = static_library(
-    'nvme', # produces libnvme.a
-    sources,
-    link_args: ['-Wl,--version-script=' + version_script_arg],
-    dependencies: deps,
-    link_depends: mapfile,
-    include_directories: incdir,
-    install : false
+pkg = import('pkgconfig')
+pkg.generate(libnvme,
+  filebase: meson.project_name(),
+  name: meson.project_name(),
+  version: meson.project_version(),
+  description: 'Manage "libnvme" subsystem devices (Non-volatile Memory Express)',
+  url: 'http://github.com/linux-nvme/libnvme/',
 )
 
-libnvme_shared_dep = declare_dependency(
+libnvme_dep = declare_dependency(
     include_directories: incdir,
-    link_with: libnvme_shared,
-)
-
-libnvme_static_dep = declare_dependency(
-    include_directories: incdir,
-    link_with: libnvme_static,
+    link_with: libnvme,
 )
 
 mode = ['rw-r--r--', 0, 0]
@@ -75,6 +69,3 @@ install_headers([
     subdir: 'nvme',
     install_mode: mode,
 )
-
-
-
index 61be2ccfc9678f75b8e3edd45531f5971376e575..e89d877831826290724514cdf00891d1bc97b0fe 100644 (file)
@@ -8,28 +8,29 @@
 main = executable(
     'main-test',
     ['test.c'],
-    link_with: libnvme_static,
+    dependencies: libuuid,
+    link_with: libnvme,
     include_directories: incdir
 )
 
 cpp = executable(
     'test-cpp',
     ['cpp.cc'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir
 )
 
 register = executable(
     'test-register',
     ['register.c'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir
 )
 
 zns = executable(
     'test-zns',
     ['zns.c'],
-    link_with: libnvme_static,
+    link_with: libnvme,
     include_directories: incdir
 )