summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Gilcher <florian.gilcher@asquera.de>2014-03-27 09:50:30 +0100
committerDavid Herrmann <dh.herrmann@gmail.com>2014-03-27 12:20:52 +0100
commitf850123e8987517a0048d9de0974b758e2f30bee (patch)
treef5f903211b31e0595d76a9f96d32acd5846da313
parent6d1cc890183fb6a433f4683aba98cdc8d6fe8549 (diff)
build: support darwin targets
Mac OS X now uses the llvm linker, so our --gc-sections logic is not supported. Furthermore, linker-scripts aren't supported either. Add GNU-ld and Darwin detection and drop any GNU-ld specific options if not supported. Dropping --gc-sections and its related options is fine. We will produce bigger binaries, but that's just what you get if you don't support that. On Darwin we try the -dead_stip options instead. They should work sufficiently well. Regarding version-scripts, we still set visibility=hidden by default and require compilers to support __attribute__((__visibility__("public"))). So symbols are correctly exported, but version-information will be lost. Again, that's an issue of the target architecture and we don't care whether they lack useful features. (extended commit-msg and reorder am-conditionals) Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
-rw-r--r--Makefile.am20
-rw-r--r--configure.ac20
2 files changed, 38 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index a484292..10f5994 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,11 +70,22 @@ AM_CFLAGS = \
AM_CPPFLAGS = \
-include $(top_builddir)/config.h \
-I $(srcdir)/src
-AM_LDFLAGS = \
+AM_LDFLAGS =
+
+if BUILD_HAVE_GNU_LD
+AM_LDFLAGS += \
-Wl,--as-needed \
-Wl,--gc-sections \
-Wl,-z,relro \
-Wl,-z,now
+else
+if BUILD_IS_DARWIN
+AM_LDFLAGS += \
+ -Wl,-dead_strip \
+ -Wl,-dead_strip_dylibs \
+ -Wl,-bind_at_load
+endif
+endif
if BUILD_ENABLE_DEBUG
AM_CFLAGS += -g
@@ -137,8 +148,13 @@ EXTRA_libtsm_la_DEPENDENCIES = $(top_srcdir)/docs/libtsm.sym
libtsm_la_LDFLAGS = \
$(AM_LDFLAGS) \
- -version-info $(LIBTSM_CURRENT):$(LIBTSM_REVISION):$(LIBTSM_AGE) \
+ -version-info $(LIBTSM_CURRENT):$(LIBTSM_REVISION):$(LIBTSM_AGE)
+
+if BUILD_HAVE_GNU_LD
+libtsm_la_LDFLAGS += \
-Wl,--version-script="$(top_srcdir)/docs/libtsm.sym"
+endif
+
libtsm_test_la_LDFLAGS = \
$(AM_LDFLAGS)
diff --git a/configure.ac b/configure.ac
index 4373b92..9b4d02f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,25 @@ AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
[test "x$enable_optimizations" = "xyes"])
#
+# Check which linker is used
+#
+
+AM_CONDITIONAL([BUILD_HAVE_GNU_LD],
+ [test "x$with_gnu_ld" = "xyes"])
+
+#
+# Detect darwin targets
+#
+
+case "$host_os" in
+ darwin*)
+ $is_darwin = "xyes";;
+esac
+
+AM_CONDITIONAL([BUILD_IS_DARWIN],
+ [test "x$is_darwin" = "xyes"])
+
+#
# Makefile vars
# After everything is configured, we create all makefiles.
#
@@ -137,6 +156,7 @@ AC_MSG_NOTICE([Build configuration:
exec-prefix: $exec_prefix
libdir: $libdir
includedir: $includedir
+ host-os: $host_os
Miscellaneous Options:
debug: $enable_debug