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 libtool sucks])
17 AC_MSG_RESULT([yup, it does])
18 AC_MSG_CHECKING([if dolt supports this host])
20 if test x$DOLT_BASH = x; then
23 if test x$GCC != xyes; then
27 i?86-*-linux*|x86_64-*-linux*) ;;
28 *) dolt_supported=no ;;
30 if test x$dolt_supported = xno ; then
31 AC_MSG_RESULT([no, falling back to libtool])
33 AC_MSG_RESULT([yes, replacing libtool])
35 dnl Start writing out doltcompile.
36 cat <<__DOLTCOMPILE__EOF__ >doltcompile
39 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
41 for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
42 if test x"${args@<:@$arg@:>@}" = x-o ; then
47 if test x$objarg = x ; then
48 echo 'Error: no -o on compiler command line' 1>&2
51 lo="${args@<:@$objarg@:>@}"
53 if test x"$lo" = x"$obj" ; then
54 echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
60 dnl Write out shared compilation code.
61 if test x$enable_shared = xyes; then
62 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
63 libobjdir="${obj%$objbase}.libs"
64 if test ! -d "$libobjdir" ; then
67 if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
71 pic_object="$libobjdir/$objbase.o"
72 args@<:@$objarg@:>@="$pic_object"
73 "${args@<:@@@:>@}" -fPIC -DPIC
77 dnl Write out static compilation code.
78 dnl Avoid duplicate compiler output if also building shared objects.
79 if test x$enable_static = xyes; then
80 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
81 non_pic_object="$obj.o"
82 args@<:@$objarg@:>@="$non_pic_object"
84 if test x$enable_shared = xyes; then
85 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
86 "${args@<:@@@:>@}" >/dev/null 2>&1
89 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
95 dnl Write out the code to write the .lo file.
96 dnl The second line of the .lo file must match "^# Generated by .*libtool"
97 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
99 echo "# $lo - a libtool object file"
100 echo "# Generated by doltcompile, not libtool"
103 if test x$enable_shared = xyes; then
104 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
105 echo "pic_object='$pic_object'"
108 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
113 if test x$enable_static = xyes; then
114 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
115 echo "non_pic_object='$non_pic_object'"
118 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
119 echo non_pic_object=none
123 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
127 dnl Done writing out doltcompile; substitute it for libtool compilation.
129 LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
131 LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
132 AC_SUBST(LTCXXCOMPILE)