summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2017-04-18 14:51:25 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2017-04-28 23:12:52 +0100
commit4b9da5c9b375e69010b0e7a72e5716cd04e8110b (patch)
treea0db3136c6f512c505231c8819e8c83c4f49c2fe
parentf20d23a3aaf5647e081a4c50df031fb15a54fe3a (diff)
downloadgtk+-4b9da5c9b375e69010b0e7a72e5716cd04e8110b.tar.gz
build: Use the appropriate linker flags
We need to check if the linker flags we use are available, depending on the platform, and we need to ensure that the shared library is versioned appropriately.
-rw-r--r--gtk/meson.build5
-rw-r--r--meson.build17
2 files changed, 20 insertions, 2 deletions
diff --git a/gtk/meson.build b/gtk/meson.build
index 392895c822..f8bf7d55f1 100644
--- a/gtk/meson.build
+++ b/gtk/meson.build
@@ -876,12 +876,13 @@ endforeach
# Library
libgtk = shared_library('gtk-4',
+ soversion: gtk_soversion,
sources: [typefuncs, gtk_sources, gtkmarshal_h, gtkprivatetypebuiltins_h],
c_args: gtk_cargs + common_cflags,
include_directories: [confinc, gdkinc, gtkinc],
dependencies: gtk_deps + [libgdk_dep, libgsk_dep],
link_with: [libgdk, libgsk, included_input_modules],
- link_args: ['-Bsymbolic'],
+ link_args: common_ldflags,
install: true)
libgtk_dep = declare_dependency(
@@ -889,7 +890,7 @@ libgtk_dep = declare_dependency(
include_directories: [confinc, gtkinc],
dependencies: gtk_deps + [libgdk_dep, libgsk_dep],
link_with: libgtk,
- link_args: ['-Bsymbolic'])
+ link_args: common_ldflags)
# Installed tools
diff --git a/meson.build b/meson.build
index 34ba0fb59c..da5505ef27 100644
--- a/meson.build
+++ b/meson.build
@@ -68,6 +68,8 @@ gtk_binary_version = '4.0.0'
gtk_binary_age = 100 * gtk_minor_version + gtk_micro_version
+gtk_soversion = '0.@0@.@1@'.format(gtk_binary_age - gtk_interface_age, gtk_interface_age)
+
gtk_api_version = '4.0'
x11_enabled = get_option('enable-x11-backend')
@@ -272,6 +274,21 @@ if get_option('default_library') != 'static'
endif
endif
+common_ldflags = []
+
+if host_machine.system() == 'linux'
+ foreach ldflag: [ '-Wl,-Bsymbolic', '-Wl,-z,relro', '-Wl,-z,now', ]
+ if cc.has_argument(ldflag)
+ common_ldflags += [ ldflag ]
+ endif
+ endforeach
+endif
+
+# Maintain compatibility with autotools
+if host_machine.system() == 'darwin'
+ common_ldflags += [ '-compatibility_version=1', '-current_version=1.0', ]
+endif
+
confinc = include_directories('.')
gdkinc = include_directories('gdk')
gtkinc = include_directories('gtk')