Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 182 lines (170 sloc) 5.495 kb
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
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
958603a @vargaz 2009-05-08 Zoltan Varga <vargaz@gmail.com>
vargaz authored
25 i?86-*-linux*|x86_64-*-linux*|powerpc-*-linux*|powerpc64-*-linux* \
a5adb1b @vargaz 2009-09-08 Zoltan Varga <vargaz@gmail.com>
vargaz authored
26 |amd64-*-freebsd*|i?86-*-freebsd*|ia64-*-freebsd*|arm*-*-linux*|sparc*-*-linux*|mips*-*-linux*)
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
27 pic_options='-fPIC'
28 ;;
a7422ba @vargaz 2009-11-12 Zoltan Varga <vargaz@gmail.com>
vargaz authored
29 ?86-pc-cygwin*|i?86-pc-cygwin*)
ab2b9ae @vargaz 2009-11-04 Zoltan Varga <vargaz@gmail.com>
vargaz authored
30 pic_options='-DDLL_EXPORT'
31 ;;
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
32 i?86-apple-darwin*)
33 pic_options='-fno-common'
34 ;;
35 *)
36 dolt_supported=no
37 ;;
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
38 esac
39 if test x$dolt_supported = xno ; then
40 AC_MSG_RESULT([no, falling back to libtool])
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
41 LTCOMPILE='$(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(COMPILE)'
42 LTCXXCOMPILE='$(LIBTOOL) --tag=CXX $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CXXCOMPILE)'
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
43 else
44 AC_MSG_RESULT([yes, replacing libtool])
45
46 dnl Start writing out doltcompile.
47 cat <<__DOLTCOMPILE__EOF__ >doltcompile
48 #!$DOLT_BASH
49 __DOLTCOMPILE__EOF__
50 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
51 args=("$[]@")
52 for ((arg=0; arg<${#args@<:@@@:>@}; arg++)) ; do
53 if test x"${args@<:@$arg@:>@}" = x-o ; then
54 objarg=$((arg+1))
55 break
56 fi
57 done
58 if test x$objarg = x ; then
59 echo 'Error: no -o on compiler command line' 1>&2
60 exit 1
61 fi
62 lo="${args@<:@$objarg@:>@}"
63 obj="${lo%.lo}"
64 if test x"$lo" = x"$obj" ; then
65 echo "Error: libtool object file name \"$lo\" does not end in .lo" 1>&2
66 exit 1
67 fi
68 objbase="${obj##*/}"
69 __DOLTCOMPILE__EOF__
70
71 dnl Write out shared compilation code.
72 if test x$enable_shared = xyes; then
73 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
74 libobjdir="${obj%$objbase}.libs"
75 if test ! -d "$libobjdir" ; then
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
76 mkdir_out="$(mkdir "$libobjdir" 2>&1)"
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
77 mkdir_ret=$?
78 if test "$mkdir_ret" -ne 0 && test ! -d "$libobjdir" ; then
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
79 echo "$mkdir_out" 1>&2
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
80 exit $mkdir_ret
81 fi
82 fi
83 pic_object="$libobjdir/$objbase.o"
84 args@<:@$objarg@:>@="$pic_object"
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
85 __DOLTCOMPILE__EOF__
86 cat <<__DOLTCOMPILE__EOF__ >>doltcompile
87 "\${args@<:@@@:>@}" $pic_options -DPIC || exit \$?
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
88 __DOLTCOMPILE__EOF__
89 fi
90
91 dnl Write out static compilation code.
92 dnl Avoid duplicate compiler output if also building shared objects.
93 if test x$enable_static = xyes; then
94 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
95 non_pic_object="$obj.o"
96 args@<:@$objarg@:>@="$non_pic_object"
97 __DOLTCOMPILE__EOF__
98 if test x$enable_shared = xyes; then
99 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
100 "${args@<:@@@:>@}" >/dev/null 2>&1 || exit $?
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
101 __DOLTCOMPILE__EOF__
102 else
103 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
104 "${args@<:@@@:>@}" || exit $?
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
105 __DOLTCOMPILE__EOF__
106 fi
107 fi
108
109 dnl Write out the code to write the .lo file.
110 dnl The second line of the .lo file must match "^# Generated by .*libtool"
111 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
112 {
113 echo "# $lo - a libtool object file"
114 echo "# Generated by doltcompile, not libtool"
115 __DOLTCOMPILE__EOF__
116
117 if test x$enable_shared = xyes; then
118 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
119 echo "pic_object='.libs/${objbase}.o'"
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
120 __DOLTCOMPILE__EOF__
121 else
122 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
123 echo pic_object=none
124 __DOLTCOMPILE__EOF__
125 fi
126
127 if test x$enable_static = xyes; then
128 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
129 echo "non_pic_object='${objbase}.o'"
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
130 __DOLTCOMPILE__EOF__
131 else
132 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
133 echo non_pic_object=none
134 __DOLTCOMPILE__EOF__
135 fi
136
137 cat <<'__DOLTCOMPILE__EOF__' >>doltcompile
138 } > "$lo"
139 __DOLTCOMPILE__EOF__
140
141 dnl Done writing out doltcompile; substitute it for libtool compilation.
142 chmod +x doltcompile
143 LTCOMPILE='$(top_builddir)/doltcompile $(COMPILE)'
144 LTCXXCOMPILE='$(top_builddir)/doltcompile $(CXXCOMPILE)'
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
145
146 dnl automake ignores LTCOMPILE and LTCXXCOMPILE when it has separate CFLAGS for
147 dnl a target, so write out a libtool wrapper to handle that case.
148 dnl Note that doltlibtool does not handle inferred tags or option arguments
149 dnl without '=', because automake does not use them.
150 cat <<__DOLTLIBTOOL__EOF__ > doltlibtool
151 #!$DOLT_BASH
152 __DOLTLIBTOOL__EOF__
153 cat <<'__DOLTLIBTOOL__EOF__' >>doltlibtool
154 top_builddir_slash="${0%%doltlibtool}"
155 : ${top_builddir_slash:=./}
5d71fee Disable DOLT by default and bring back the configure flag
Alp Toker authored
156 args=()
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
157 modeok=false
158 tagok=false
159 for arg in "$[]@"; do
160 case "$arg" in
161 --mode=compile) modeok=true ;;
162 --tag=CC|--tag=CXX) tagok=true ;;
4878071 @vargaz 2008-07-06 Zoltan Varga <vargaz@gmail.com>
vargaz authored
163 --quiet) ;;
e49ff7f 2008-06-30 Alp Toker <alp@nuanti.com>
Alp Toker authored
164 *) args@<:@${#args[@]}@:>@="$arg" ;;
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
165 esac
166 done
167 if $modeok && $tagok ; then
168 . ${top_builddir_slash}doltcompile "${args@<:@@@:>@}"
169 else
170 exec ${top_builddir_slash}libtool "$[]@"
171 fi
172 __DOLTLIBTOOL__EOF__
173
174 dnl Done writing out doltlibtool; substitute it for libtool.
175 chmod +x doltlibtool
176 LIBTOOL='$(top_builddir)/doltlibtool'
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
177 fi
ff5f33b 2008-06-26 Alp Toker <alp@nuanti.com>
Alp Toker authored
178 AC_SUBST(LTCOMPILE)
179 AC_SUBST(LTCXXCOMPILE)
2313910 @vargaz 2008-05-21 Zoltan Varga <vargaz@gmail.com>
vargaz authored
180 # end dolt
181 ])
Something went wrong with that request. Please try again.