1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
2
"http://www.w3.org/TR/html4/strict.dtd">
6
Autoconf Macro: ax_enable_builddir_uname
8
<link rel="stylesheet" type="text/css" href="autoconf-archive.css">
11
<table summary="web navigation" style="width:100%;">
14
<td style="width:25%;" align="center" valign="top">
16
"http://autoconf-archive.cryp.to/ax_enable_builddir_uname.m4">Download M4
19
<td style="width:25%;" align="center" valign="top">
21
"http://git.cryp.to/autoconf-archive?a=history;f=ax_enable_builddir_uname.m4">
24
<td style="width:25%;" align="center" valign="top">
25
<a href="macros-by-category.html">Category Index</a>
27
<td style="width:25%;" align="center" valign="top">
28
<form method="get" action="http://www.google.com/search">
30
<input name="sitesearch" value="autoconf-archive.cryp.to" type=
31
"hidden"><a href="http://www.google.com/">Search</a>: <input name="q"
32
size="10" maxlength="255" type="text">
41
ax_enable_builddir_uname
47
Use <a href="ax_enable_builddir.html">AX_ENABLE_BUILDDIR</a> in combination
48
with AC_CANONICAL_HOST.
53
<p class="indent" style="white-space:nowrap;">
54
<code>AX_ENABLE_BUILDDIR_UNAME [(dirstring-or-command
55
[,Makefile.mk])]</code>
62
If the current configure was run within the srcdir then we move all
63
configure-files into a subdir and let the configure steps continue there.
64
We provide an option --disable-builddir to suppress the move into a
71
$1 = $build (defaults to `uname -msr`.d)
76
This macro must be called before AM_INIT_AUTOMAKE. It creates a default
77
toplevel srcdir Makefile from the information found in the created toplevel
78
builddir Makefile. It just copies the variables and rule-targets, each
79
extended with a default rule-execution that recurses into the build
80
directory of the current "BUILD". You can override the auto-dection through
81
`uname -msr | tr " /" "__"`.d at build-time of course, as in
84
make BUILD=i386-mingw-cross
87
After the default has been created, additional rules can be appended that
88
will not just recurse into the subdirectories and only ever exist in the
89
srcdir toplevel makefile - these parts are read from the $2 = Makefile.mk
93
The automatic rules are usually scanning the toplevel Makefile for lines
94
like '#### $build |$builddir' to recognize the place where to recurse into.
95
Usually, the last one is the only one used. However, almost all targets
96
have an additional "*-all" rule which makes the script to recurse into
97
_all_ variants of the current BUILD (!!) setting. The "-all" suffix can be
98
overriden for the macro as well.
101
A special rule is only given for things like "dist" that will copy the
102
tarball from the builddir to the sourcedir (or $(PUB)) for reason of
110
Guido U. Draheim <guidod@gmx.de>
122
<pre class="m4source">
123
AC_DEFUN([AX_ENABLE_BUILDDIR_UNAME],[
124
AC_REQUIRE([AC_CANONICAL_HOST])[]dnl
125
AC_REQUIRE([AX_CONFIGURE_ARGS])[]dnl
126
AC_BEFORE([$0],[AM_INIT_AUTOMAKE])dnl
127
AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
128
AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
130
AC_ARG_ENABLE([builddir], AC_HELP_STRING(
131
[--disable-builddir],[disable automatic build in subdir of sources])
132
,[SUB="$enableval"], [SUB="yes"])
133
if test ".$ac_srcdir_defaulted" != ".no" ; then
134
if test ".$srcdir" = ".." ; then
135
if test -f config.status ; then
136
AC_MSG_NOTICE(toplevel srcdir already configured... skipping subdir build)
138
test ".$SUB" = "." && SUB="."
139
test ".$SUB" = ".no" && SUB="."
140
test ".$BUILD" = "." && BUILD=`uname -msr | tr " /" "__"`.d
141
test ".$SUB" = ".yes" && SUB="m4_ifval([$1], [$1],[$BUILD])"
142
if test ".$SUB" != ".." ; then # we know where to go and
144
echo __.$SUB.__ > $SUB/conftest.tmp
146
if grep __.$SUB.__ conftest.tmp >/dev/null 2>/dev/null ; then
148
AC_MSG_RESULT([continue configure in default builddir "./$SUB"])
150
AC_MSG_ERROR([could not change to default builddir "./$SUB"])
152
srcdir=`echo "$SUB" |
153
sed -e 's,^\./,,;s,[[^/]]$,&/,;s,[[^/]]*/,../,g;s,[[/]]$,,;'`
154
# going to restart from subdirectory location
155
test -f $srcdir/config.log && mv $srcdir/config.log .
156
test -f $srcdir/confdefs.h && mv $srcdir/confdefs.h .
157
test -f $srcdir/conftest.log && mv $srcdir/conftest.log .
158
test -f $srcdir/$cache_file && mv $srcdir/$cache_file .
159
AC_MSG_RESULT(....exec $SHELL "$srcdir/[$]0" "--srcdir=$srcdir" "--enable-builddir=$SUB" $ac_configure_args)
160
case "[$]0" in # restart
161
[/\\]*) eval $SHELL "'[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
162
*) eval $SHELL "'$srcdir/[$]0'" "'--srcdir=$srcdir'" "'--enable-builddir=$SUB'" $ac_configure_args ;;
167
dnl ac_path_prog uses "set dummy" to override $@ which would defeat the "exec"
168
AC_PATH_PROG(SED,gsed sed, sed)
169
AS_VAR_POPDEF([SED])dnl
170
AS_VAR_POPDEF([SUB])dnl
171
AC_CONFIG_COMMANDS([buildir],[dnl .............. config.status ..............
172
AS_VAR_PUSHDEF([SUB],[ax_enable_builddir])dnl
173
AS_VAR_PUSHDEF([TOP],[top_srcdir])dnl
174
AS_VAR_PUSHDEF([SRC],[ac_top_srcdir])dnl
175
AS_VAR_PUSHDEF([SED],[ax_enable_builddir_sed])dnl
176
pushdef([END],[Makefile.mk])dnl
177
SRC="$ax_enable_builddir_srcdir"
178
if test ".$SUB" = "." ; then
179
if test -f "$TOP/Makefile" ; then
180
AC_MSG_NOTICE([skipping TOP/Makefile - left untouched])
182
AC_MSG_NOTICE([skipping TOP/Makefile - not created])
185
AC_MSG_NOTICE([create TOP/Makefile guessed from local Makefile])
186
x='`' ; cat >$tmp/conftemp.sed <<_EOF
203
s/^srcdir *=.*/srcdir = ./
204
s/^top_srcdir *=.*/top_srcdir = ./
210
/^.*[[=]]/!s%\$% ; (cd \$(BUILD) \\&\\& \$(ISNOTSRCDIR) \\&\\& \$(MAKE) "\$\@") || exit ; \$(MAKE) done "RULE=\$\@"%
212
test ".$USE_MAINTAINER_MODE" = ".no" || \
213
cp "$tmp/conftemp.sed" "$SRC/makefile.sed~" ## DEBUGGING
214
echo 'BUILD=`uname -msr | tr " /" "__"`.d' >$SRC/Makefile
215
echo 'ISNOTSRCDIR=test ! -f configure' >>$SRC/Makefile
216
$SED -f $tmp/conftemp.sed Makefile >>$SRC/Makefile
217
echo 'done: ;@ if grep "$(RULE)-done .*:" Makefile > /dev/null; then dnl
218
echo $(MAKE) $(RULE)-done ; $(MAKE) $(RULE)-done ; else true ; fi' dnl
219
>> $SRC/Makefile
220
if test -f "$SRC/m4_ifval([$2],[$2],[END])" ; then
221
AC_MSG_NOTICE([extend TOP/Makefile with TOP/m4_ifval([$2],[$2],[END])])
222
cat $SRC/END >>$SRC/Makefile
224
AC_MSG_NOTICE([make uses BUILD=$SUB (on $ax_enable_builddir_host:)])
227
AS_VAR_POPDEF([SED])dnl
228
AS_VAR_POPDEF([SRC])dnl
229
AS_VAR_POPDEF([TOP])dnl
230
AS_VAR_POPDEF([SUB])dnl
232
ax_enable_builddir_srcdir="$srcdir" # $srcdir
233
ax_enable_builddir_host="$HOST" # $HOST / $host
234
ax_enable_builddir_version="$VERSION" # $VERSION
235
ax_enable_builddir_package="$PACKAGE" # $PACKAGE
236
ax_enable_builddir_sed="$ax_enable_builddir_sed" # $SED
237
ax_enable_builddir="$ax_enable_builddir" # $SUB
246
<span style="white-space:nowrap;">Copyright © 2008 Guido U. Draheim
247
<guidod@gmx.de></span>
249
This program is free software; you can redistribute it and/or modify it
250
under the terms of the GNU General Public License as published by the Free
251
Software Foundation; either version 2 of the License, or (at your option)
255
This program is distributed in the hope that it will be useful, but WITHOUT
256
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
257
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
261
You should have received a copy of the GNU General Public License along
262
with this program. If not, see <<a href=
263
"http://www.gnu.org/licenses/">http://www.gnu.org/licenses/</a>>.
266
As a special exception, the respective Autoconf Macro's copyright owner
267
gives unlimited permission to copy, distribute and modify the configure
268
scripts that are the output of Autoconf when processing the Macro. You need
269
not follow the terms of the GNU General Public License when using or
270
distributing such scripts, even though portions of the text of the Macro
271
appear in them. The GNU General Public License (GPL) does govern all other
272
use of the material that constitutes the Autoconf Macro.
275
This special exception to the GPL applies to versions of the Autoconf Macro
276
released by the Autoconf Macro Archive. When you make and distribute a
277
modified version of the Autoconf Macro, you may extend this special
278
exception to the GPL to apply to your modified version as well.