[kmscon-devel] [PATCH] Check for GNU ld

Florian Gilcher florian.gilcher at asquera.de
Thu Mar 27 01:50:30 PDT 2014


Some flags that are GNU ld-only are used.

Use OS X flags on OS X.
---
 Makefile.am  | 20 ++++++++++++++++++++
 configure.ac | 23 +++++++++++++++++++++++
 2 files changed, 43 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index a484292..683a1c4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -70,11 +70,24 @@ AM_CFLAGS = \
 AM_CPPFLAGS = \
 	-include $(top_builddir)/config.h \
 	-I $(srcdir)/src
+
+if BUILD_HAVE_GNU_LD
 AM_LDFLAGS = \
 	-Wl,--as-needed \
 	-Wl,--gc-sections \
 	-Wl,-z,relro \
 	-Wl,-z,now
+else
+if BUILD_HAVE_DARWIN
+AM_LDFLAGS = \
+	-Wl,-dead_strip \
+	-Wl,-dead_strip_dylibs \
+	-Wl,-bind_at_load
+endif
+if BUILD_HAVE_UNKNOWN_OS
+AM_LDFLAGS = # Let's try anyways
+endif
+endif
 
 if BUILD_ENABLE_DEBUG
 AM_CFLAGS += -g
@@ -135,10 +148,17 @@ libtsm_test_la_LIBADD = libshl.la
 
 EXTRA_libtsm_la_DEPENDENCIES = $(top_srcdir)/docs/libtsm.sym
 
+if BUILD_HAVE_GNU_LD
 libtsm_la_LDFLAGS = \
 	$(AM_LDFLAGS) \
 	-version-info $(LIBTSM_CURRENT):$(LIBTSM_REVISION):$(LIBTSM_AGE) \
 	-Wl,--version-script="$(top_srcdir)/docs/libtsm.sym"
+else
+libtsm_la_LDFLAGS = \
+	$(AM_LDFLAGS) \
+	-version-info $(LIBTSM_CURRENT):$(LIBTSM_REVISION):$(LIBTSM_AGE)
+endif
+
 libtsm_test_la_LDFLAGS = \
 	$(AM_LDFLAGS)
 
diff --git a/configure.ac b/configure.ac
index 4373b92..31638a7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -117,6 +117,29 @@ AM_CONDITIONAL([BUILD_ENABLE_OPTIMIZATIONS],
                [test "x$enable_optimizations" = "xyes"])
 
 #
+# Check whether the linker we are linking with is GNU ld.
+#
+# Also, check for the operating system to decide on linker
+# flags later on.
+#
+
+AM_CONDITIONAL([BUILD_HAVE_GNU_LD],
+               [test "x$with_gnu_ld" = "xyes"])
+
+case "$host_os" in
+  darwin*)
+    $with_darwin = "xyes";;
+  *)
+    $with_unknown_os = "xyes";;
+esac
+
+AM_CONDITIONAL([BUILD_HAVE_DARWIN],
+               [test "x$with_darwin" = "xyes"])
+
+AM_CONDITIONAL([BUILD_HAVE_UNKNOWN_OS],
+               [test "x$with_unknown_os" = "xyes"])
+
+#
 # Makefile vars
 # After everything is configured, we create all makefiles.
 #
-- 
1.8.5.2 (Apple Git-48)



More information about the kmscon-devel mailing list