Add libtool-ldflags. Define toolexeclibdir for non-GCC builds.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204
diff --git a/ChangeLog b/ChangeLog
index 37d415a..2eeb805 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2013-02-07 Anthony Green <green@moxielogic.com>
+
+ * Makefile.am (EXTRA_DIST): Add libtool-ldflags.
+ * Makefile.in: Rebuilt.
+ * libtool-ldflags: New file.
+
2013-02-07 Daniel Schepler <dschepler@gmail.com>
* configure.ac: Correctly identify x32 systems as 64-bit.
diff --git a/Makefile.am b/Makefile.am
index 6f669ca..a7cd18f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -2,6 +2,8 @@
AUTOMAKE_OPTIONS = foreign subdir-objects
+ACLOCAL_AMFLAGS = -I m4
+
SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
@@ -40,7 +42,8 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
generate-ios-source-and-headers.py \
generate-osx-source-and-headers.py \
- libffi.xcodeproj/project.pbxproj src/arm/trampoline.S
+ libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
+ libtool-ldflags
info_TEXINFOS = doc/libffi.texi
diff --git a/Makefile.in b/Makefile.in
index f426300..1ef91f8 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -460,6 +460,7 @@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@
top_srcdir = @top_srcdir@
AUTOMAKE_OPTIONS = foreign subdir-objects
+ACLOCAL_AMFLAGS = -I m4
SUBDIRS = include testsuite man
EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
src/aarch64/ffi.c src/aarch64/ffitarget.h \
@@ -497,7 +498,8 @@ EXTRA_DIST = LICENSE ChangeLog.v1 ChangeLog.libgcj configure.host \
m4/ltversion.m4 src/arm/gentramp.sh src/debug.c msvcc.sh \
generate-ios-source-and-headers.py \
generate-osx-source-and-headers.py \
- libffi.xcodeproj/project.pbxproj src/arm/trampoline.S
+ libffi.xcodeproj/project.pbxproj src/arm/trampoline.S \
+ libtool-ldflags
info_TEXINFOS = doc/libffi.texi
diff --git a/configure b/configure
index d9f23a3..c3b0074 100755
--- a/configure
+++ b/configure
@@ -14828,9 +14828,11 @@ if test "x$GCC" = "xyes"; then
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
esac
-
+else
+ toolexeclibdir='$(libdir)'
fi
+
ac_config_commands="$ac_config_commands include"
ac_config_commands="$ac_config_commands src"
diff --git a/configure.ac b/configure.ac
index 4a37d0b..c20fdd8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -543,8 +543,10 @@ if test "x$GCC" = "xyes"; then
*) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
esac
AC_SUBST(toolexecdir)
- AC_SUBST(toolexeclibdir)
+else
+ toolexeclibdir='$(libdir)'
fi
+AC_SUBST(toolexeclibdir)
AC_CONFIG_COMMANDS(include, [test -d include || mkdir include])
AC_CONFIG_COMMANDS(src, [
diff --git a/libtool-ldflags b/libtool-ldflags
new file mode 100755
index 0000000..e32e37b
--- /dev/null
+++ b/libtool-ldflags
@@ -0,0 +1,106 @@
+#! /bin/sh
+
+# Script to translate LDFLAGS into a form suitable for use with libtool.
+
+# Copyright (C) 2005 Free Software Foundation, Inc.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+# Contributed by CodeSourcery, LLC.
+
+# This script is designed to be used from a Makefile that uses libtool
+# to build libraries as follows:
+#
+# LTLDFLAGS = $(shell libtool-ldflags $(LDFLAGS))
+#
+# Then, use (LTLDFLAGS) in place of $(LDFLAGS) in your link line.
+
+# The output of the script. This string is built up as we process the
+# arguments.
+result=
+prev_arg=
+
+for arg
+do
+ case $arg in
+ -f*|--*)
+ # Libtool does not ascribe any special meaning options
+ # that begin with -f or with a double-dash. So, it will
+ # think these options are linker options, and prefix them
+ # with "-Wl,". Then, the compiler driver will ignore the
+ # options. So, we prefix these options with -Xcompiler to
+ # make clear to libtool that they are in fact compiler
+ # options.
+ case $prev_arg in
+ -Xpreprocessor|-Xcompiler|-Xlinker)
+ # This option is already prefixed; don't prefix it again.
+ ;;
+ *)
+ result="$result -Xcompiler"
+ ;;
+ esac
+ ;;
+ *)
+ # We do not want to add -Xcompiler to other options because
+ # that would prevent libtool itself from recognizing them.
+ ;;
+ esac
+ prev_arg=$arg
+
+ # If $(LDFLAGS) is (say):
+ # a "b'c d" e
+ # then the user expects that:
+ # $(LD) $(LDFLAGS)
+ # will pass three arguments to $(LD):
+ # 1) a
+ # 2) b'c d
+ # 3) e
+ # We must ensure, therefore, that the arguments are appropriately
+ # quoted so that using:
+ # libtool --mode=link ... $(LTLDFLAGS)
+ # will result in the same number of arguments being passed to
+ # libtool. In other words, when this script was invoked, the shell
+ # removed one level of quoting, present in $(LDFLAGS); we have to put
+ # it back.
+
+ # Quote any embedded single quotes.
+ case $arg in
+ *"'"*)
+ # The following command creates the script:
+ # 1s,^X,,;s|'|'"'"'|g
+ # which removes a leading X, and then quotes and embedded single
+ # quotes.
+ sed_script="1s,^X,,;s|'|'\"'\"'|g"
+ # Add a leading "X" so that if $arg starts with a dash,
+ # the echo command will not try to interpret the argument
+ # as a command-line option.
+ arg="X$arg"
+ # Generate the quoted string.
+ quoted_arg=`echo "$arg" | sed -e "$sed_script"`
+ ;;
+ *)
+ quoted_arg=$arg
+ ;;
+ esac
+ # Surround the entire argument with single quotes.
+ quoted_arg="'"$quoted_arg"'"
+
+ # Add it to the string.
+ result="$result $quoted_arg"
+done
+
+# Output the string we have built up.
+echo "$result"