1
dnl dolt, a replacement for libtool
2
dnl Copyright © 2007-2008 Josh Triplett <josh@freedesktop.org>
3
dnl Copying and distribution of this file, with or without modification,
4
dnl are permitted in any medium without royalty provided the copyright
5
dnl notice and this notice are preserved.
7
dnl To use dolt, invoke the DOLT macro immediately after the libtool macros.
8
dnl Optionally, copy this file into acinclude.m4, to avoid the need to have it
9
dnl installed when running autoconf on your project.
12
AC_REQUIRE([AC_CANONICAL_HOST])
13
# dolt, a replacement for libtool
14
# Josh Triplett <josh@freedesktop.org>
15
AC_PATH_PROG(DOLT_BASH, bash)
16
AC_MSG_CHECKING([if dolt supports this host])
18
if test x$DOLT_BASH = x; then
21
if test x$GCC != xyes; then
25
i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*) ;;
26
amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*) ;;
27
*) dolt_supported=no ;;
29
if test x$dolt_supported = xno ; then
30
AC_MSG_RESULT([no, falling back to libtool])
31
LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
32
LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
34
AC_MSG_RESULT([yes, replacing libtool])
36
dnl Start writing out doltcompile.
37
cat <<__DOLTCOMPILE__EOF__ >doltcompile
40
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
42
for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
43
if test x"${args@<:@$arg@:>@}" = x-o ; then
48
if test x$objarg = x ; then
49
echo 'Error: no -o on compiler command line' 1>&2
52
lo="${args@<:@$objarg@:>@}"
54
if test x"$lo" = x"$obj" ; then
55
echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
61
dnl Write out shared compilation code.
62
if test x$enable_shared = xyes; then
63
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
64
libobjdir="${obj%$objbase}.libs"
65
if test ! -d "$libobjdir" ; then
66
mkdir_out="$(mkdir "$libobjdir" 2>&1)"
68
if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
69
echo "$mkdir_out" 1>&2
73
pic_object="$libobjdir/$objbase.o"
74
args@<:@$objarg@:>@="$pic_object"
75
"${args@<:@@@:>@}" -fPIC -DPIC || exit $?
79
dnl Write out static compilation code.
80
dnl Avoid duplicate compiler output if also building shared objects.
81
if test x$enable_static = xyes; then
82
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
83
non_pic_object="$obj.o"
84
args@<:@$objarg@:>@="$non_pic_object"
86
if test x$enable_shared = xyes; then
87
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
88
"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
91
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
92
"${args@<:@@@:>@}" || exit $?
97
dnl Write out the code to write the .lo file.
98
dnl The second line of the .lo file must match "^# Generated by .*libtool"
99
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
101
echo "# $lo - a libtool object file"
102
echo "# Generated by doltcompile, not libtool"
105
if test x$enable_shared = xyes; then
106
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
107
echo "pic_object='$pic_object'"
110
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
115
if test x$enable_static = xyes; then
116
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
117
echo "non_pic_object='$non_pic_object'"
120
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
121
echo non_pic_object=none
125
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
129
dnl Done writing out doltcompile; substitute it for libtool compilation.
131
LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
132
LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
135
AC_SUBST(LTCXXCOMPILE)