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*)
30
pic_options='-fno-common'
36
if test x$dolt_supported = xno ; then
37
AC_MSG_RESULT([no, falling back to libtool])
38
LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
39
LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
41
AC_MSG_RESULT([yes, replacing libtool])
43
dnl Start writing out doltcompile.
44
cat <<__DOLTCOMPILE__EOF__ >doltcompile
47
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
49
for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
50
if test x"${args@<:@$arg@:>@}" = x-o ; then
55
if test x$objarg = x ; then
56
echo 'Error: no -o on compiler command line' 1>&2
59
lo="${args@<:@$objarg@:>@}"
61
if test x"$lo" = x"$obj" ; then
62
echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
68
dnl Write out shared compilation code.
69
if test x$enable_shared = xyes; then
70
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
71
libobjdir="${obj%$objbase}.libs"
72
if test ! -d "$libobjdir" ; then
73
mkdir_out="$(mkdir "$libobjdir" 2>&1)"
75
if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
76
echo "$mkdir_out" 1>&2
80
pic_object="$libobjdir/$objbase.o"
81
args@<:@$objarg@:>@="$pic_object"
83
cat <<__DOLTCOMPILE__EOF__ >>doltcompile
84
"\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
88
dnl Write out static compilation code.
89
dnl Avoid duplicate compiler output if also building shared objects.
90
if test x$enable_static = xyes; then
91
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
92
non_pic_object="$obj.o"
93
args@<:@$objarg@:>@="$non_pic_object"
95
if test x$enable_shared = xyes; then
96
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
97
"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
100
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
101
"${args@<:@@@:>@}" || exit $?
106
dnl Write out the code to write the .lo file.
107
dnl The second line of the .lo file must match "^# Generated by .*libtool"
108
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
110
echo "# $lo - a libtool object file"
111
echo "# Generated by doltcompile, not libtool"
114
if test x$enable_shared = xyes; then
115
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
116
echo "pic_object='.libs/${objbase}.o'"
119
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
124
if test x$enable_static = xyes; then
125
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
126
echo "non_pic_object='${objbase}.o'"
129
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
130
echo non_pic_object=none
134
cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
138
dnl Done writing out doltcompile; substitute it for libtool compilation.
140
LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
141
LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
143
dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
144
dnl a target, so write out a libtool wrapper to handle that case.
145
dnl Note that doltlibtool does not handle inferred tags or option arguments
146
dnl without '=', because automake does not use them.
147
cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
150
cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
151
top_builddir_slash="${0%%doltlibtool}"
152
: ${top_builddir_slash:=./}
156
for arg in "$[]@"; do
158
--mode=compile) modeok=true ;;
159
--tag=CC|--tag=CXX) tagok=true ;;
160
*) args@<:@${#args[@]}@:>@="$arg" ;;
163
if $modeok && $tagok ; then
164
. ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
166
exec ${top_builddir_slash}libtool "$[]@"
170
dnl Done writing out doltlibtool; substitute it for libtool.
172
LIBTOOL='$(top_builddir)/doltlibtool'
175
AC_SUBST(LTCXXCOMPILE)