~ubuntu-branches/ubuntu/karmic/xorg-server/karmic-proposed

1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
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.
6
dnl
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.
10
11
AC_DEFUN([DOLT], [
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])
17
dolt_supported=yes
18
if test x$DOLT_BASH = x; then
19
    dolt_supported=no
20
fi
21
if test x$GCC != xyes; then
22
    dolt_supported=no
23
fi
24
case $host in
25
i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux* \
26
|amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*)
27
    pic_options='-fPIC'
28
    ;;
29
i?86-apple-darwin*)
30
    pic_options='-fno-common'
31
    ;;
32
*)
33
    dolt_supported=no
34
    ;;
35
esac
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)'
40
else
41
    AC_MSG_RESULT([yes, replacing libtool])
42
43
dnl Start writing out doltcompile.
44
    cat <<__DOLTCOMPILE__EOF__ >doltcompile
45
#!$DOLT_BASH
46
__DOLTCOMPILE__EOF__
47
    cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
48
args=("$[]@")
49
for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
50
    if test x"${args@<:@$arg@:>@}" = x-o ; then
51
        objarg=$((arg+1))
52
        break
53
    fi
54
done
55
if test x$objarg = x ; then
56
    echo 'Error: no -o on compiler command line' 1>&2
57
    exit 1
58
fi
59
lo="${args@<:@$objarg@:>@}"
60
obj="${lo%.lo}"
61
if test x"$lo" = x"$obj" ; then
62
    echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
63
    exit 1
64
fi
65
objbase="${obj##*/}"
66
__DOLTCOMPILE__EOF__
67
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)"
74
    mkdir_ret=$?
75
    if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
76
	echo "$mkdir_out" 1>&2
77
        exit $mkdir_ret
78
    fi
79
fi
80
pic_object="$libobjdir/$objbase.o"
81
args@<:@$objarg@:>@="$pic_object"
82
__DOLTCOMPILE__EOF__
83
    cat <<__DOLTCOMPILE__EOF__ >>doltcompile
84
"\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
85
__DOLTCOMPILE__EOF__
86
    fi
87
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"
94
__DOLTCOMPILE__EOF__
95
        if test x$enable_shared = xyes; then
96
            cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
97
"${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
98
__DOLTCOMPILE__EOF__
99
        else
100
            cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
101
"${args@<:@@@:>@}" || exit $?
102
__DOLTCOMPILE__EOF__
103
        fi
104
    fi
105
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
109
{
110
echo "# $lo - a libtool object file"
111
echo "# Generated by doltcompile, not libtool"
112
__DOLTCOMPILE__EOF__
113
114
    if test x$enable_shared = xyes; then
115
        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
116
echo "pic_object='.libs/${objbase}.o'"
117
__DOLTCOMPILE__EOF__
118
    else
119
        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
120
echo pic_object=none
121
__DOLTCOMPILE__EOF__
122
    fi
123
124
    if test x$enable_static = xyes; then
125
        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
126
echo "non_pic_object='${objbase}.o'"
127
__DOLTCOMPILE__EOF__
128
    else
129
        cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
130
echo non_pic_object=none
131
__DOLTCOMPILE__EOF__
132
    fi
133
134
    cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
135
} > "$lo"
136
__DOLTCOMPILE__EOF__
137
138
dnl Done writing out doltcompile; substitute it for libtool compilation.
139
    chmod +x doltcompile
140
    LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
141
    LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
142
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
148
#!$DOLT_BASH
149
__DOLTLIBTOOL__EOF__
150
    cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
151
top_builddir_slash="${0%%doltlibtool}"
152
: ${top_builddir_slash:=./}
153
args=()
154
modeok=false
155
tagok=false
156
for arg in "$[]@"; do
157
    case "$arg" in
158
        --mode=compile) modeok=true ;;
159
        --tag=CC|--tag=CXX) tagok=true ;;
1.1.21 by Timo Aaltonen
Import upstream version 1.5.99.901
160
        *) args@<:@${#args[@]}@:>@="$arg" ;;
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
161
    esac
162
done
163
if $modeok && $tagok ; then
164
    . ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
165
else
166
    exec ${top_builddir_slash}libtool "$[]@"
167
fi
168
__DOLTLIBTOOL__EOF__
169
170
dnl Done writing out doltlibtool; substitute it for libtool.
171
    chmod +x doltlibtool
172
    LIBTOOL='$(top_builddir)/doltlibtool'
173
fi
174
AC_SUBST(LTCOMPILE)
175
AC_SUBST(LTCXXCOMPILE)
176
# end dolt
177
])
178
179
# ===========================================================================
180
#             http://autoconf-archive.cryp.to/ac_define_dir.html
181
# ===========================================================================
1.1.7 by Timo Aaltonen
Import upstream version 1.4
182
#
183
# SYNOPSIS
184
#
185
#   AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
186
#
187
# DESCRIPTION
188
#
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
189
#   This macro sets VARNAME to the expansion of the DIR variable, taking
190
#   care of fixing up ${prefix} and such.
1.1.7 by Timo Aaltonen
Import upstream version 1.4
191
#
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
192
#   VARNAME is then offered as both an output variable and a C preprocessor
193
#   symbol.
1.1.7 by Timo Aaltonen
Import upstream version 1.4
194
#
195
#   Example:
196
#
197
#      AC_DEFINE_DIR([DATADIR], [datadir], [Where data are placed to.])
198
#
199
# LAST MODIFICATION
200
#
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
201
#   2008-04-12
1.1.7 by Timo Aaltonen
Import upstream version 1.4
202
#
203
# COPYLEFT
204
#
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
205
#   Copyright (c) 2008 Stepan Kasal <kasal@ucw.cz>
206
#   Copyright (c) 2008 Andreas Schwab <schwab@suse.de>
207
#   Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de>
208
#   Copyright (c) 2008 Alexandre Oliva
1.1.7 by Timo Aaltonen
Import upstream version 1.4
209
#
1.1.20 by Timo Aaltonen
Import upstream version 1.5.99.3
210
#   Copying and distribution of this file, with or without modification, are
211
#   permitted in any medium without royalty provided the copyright notice
212
#   and this notice are preserved.
1.1.7 by Timo Aaltonen
Import upstream version 1.4
213
1 by Daniel Stone
Import upstream version 0.99.3
214
AC_DEFUN([AC_DEFINE_DIR], [
215
  prefix_NONE=
216
  exec_prefix_NONE=
217
  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
218
  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
1.1.5 by Sebastien Bacher
Import upstream version 1.2.0
219
dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
220
dnl refers to ${prefix}.  Thus we have to use `eval' twice.
1 by Daniel Stone
Import upstream version 0.99.3
221
  eval ac_define_dir="\"[$]$2\""
1.1.5 by Sebastien Bacher
Import upstream version 1.2.0
222
  eval ac_define_dir="\"$ac_define_dir\""
1 by Daniel Stone
Import upstream version 0.99.3
223
  AC_SUBST($1, "$ac_define_dir")
224
  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
225
  test "$prefix_NONE" && prefix=NONE
226
  test "$exec_prefix_NONE" && exec_prefix=NONE
227
])