From 7e0abb26bb901da1a8fc8ed3b2817eeb6d0864a3 Mon Sep 17 00:00:00 2001 From: Jonathan MERCIER Date: Mon, 21 Oct 2019 22:58:23 +0200 Subject: [PATCH 1/2] update meson build to support shared library with --default-library shared --- meson.build | 51 +++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 6 deletions(-) diff --git a/meson.build b/meson.build index 119df37..f553b17 100644 --- a/meson.build +++ b/meson.build @@ -1,5 +1,32 @@ -project('mir-core', 'd', version : '0.3.0', license: 'BSL-1.0') +project('mir-core', 'd', version : '1.0.2', license: 'BSL-1.0') +# Basics option to follow FHS rules +prefix = get_option('prefix') +libdir = join_paths(prefix, get_option('libdir')) +sysconfdir = join_paths(prefix, get_option('sysconfdir')) +includedir = join_paths(prefix, get_option('includedir')) +datadir = join_paths(prefix, get_option('datadir')) +libexecdir = join_paths(prefix, get_option('libexecdir')) + +# semver +version = meson.project_version().split('.') +major_version = version[0].to_int() +minor_version = version[1].to_int() +micro_version = version[2].to_int() + +# base +dc = meson.get_compiler('d') + +# Compiler and linker flags +common_dflags = [] +common_ldflags = [] + +if host_machine.system() == 'linux' + common_ldflags += [ '-Wl,-z,relro', '-Wl,-z,now' ] +endif + + +# Source files mir_core_dir = include_directories('source/') mir_core_src = [ @@ -19,9 +46,16 @@ mir_core_src = [ 'source/mir/utility.d', ] +lib_type = get_option('default_library') +if lib_type == 'shared' + mir_core_soname = 'lib@0@.so.@1@'.format(meson.project_name(), major_version) + common_ldflags += ['-shared', '-soname', mir_core_soname ] +endif + mir_core_lib = library(meson.project_name(), mir_core_src, include_directories: mir_core_dir, + link_args : common_ldflags, install: true, version: meson.project_version(), ) @@ -31,16 +65,20 @@ mir_core_dep = declare_dependency( include_directories: mir_core_dir, ) +# Compat variables for pkgconfig +pkg = import('pkgconfig') +pkg.generate(mir_core_lib, + description: 'Mir Core - Base software building blocks and conventions.', + subdirs: 'd/' + meson.project_name(), + url: 'https://github.com/libmir/mir-core' +) + + install_subdir('source/', strip_directory : true, install_dir: 'include/d/' + meson.project_name(), ) -import('pkgconfig').generate(mir_core_lib, - description: 'Mir Core - Base software building blocks and conventions.', - subdirs: 'd/' + meson.project_name(), -) - if get_option('with_test') mir_core_test_exe = executable(meson.project_name() + '-test', @@ -54,3 +92,4 @@ if get_option('with_test') test(meson.project_name() + '-test', mir_core_test_exe) endif + From c665a5eb2b3ef55578e078aabe32d3e3b875ae95 Mon Sep 17 00:00:00 2001 From: Jonathan MERCIER Date: Tue, 22 Oct 2019 09:56:19 +0200 Subject: [PATCH 2/2] Add -soname linker flag for ldc compiler only --- meson.build | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index f553b17..c5ef461 100644 --- a/meson.build +++ b/meson.build @@ -49,7 +49,12 @@ mir_core_src = [ lib_type = get_option('default_library') if lib_type == 'shared' mir_core_soname = 'lib@0@.so.@1@'.format(meson.project_name(), major_version) - common_ldflags += ['-shared', '-soname', mir_core_soname ] + common_ldflags += ['-shared'] + + if dc.get_id() == 'llvm' + common_ldflags += [ '-soname', mir_core_soname ] + endif + endif mir_core_lib = library(meson.project_name(),