Re: cross-compiling but keeping one target native

2010-05-19 Thread Simon Richter
Hi,

On Mon, May 17, 2010 at 03:37:37PM -0700, Natalie Tasman wrote:

 I've created a separate configure.ac and Makefile.in for the native
 project.  However, when invoking configuration from the top-level
 (cross-compiled) project, AC_CONFIG_SUBDIRS passes various options,
 including directives to use the top-level cache as well as the --host
 cross-compile directive.

Normally I just generate a toplevel Makefile that creates subdirectories
and calls the sub-configure explicitly, but I've always thought of that
as slightly suboptimal. Since I needed it for a work project anyway I
thought I could spend an hour of company time on it.

The attached acinclude.m4 fragment defines

SJR_CONFIG_NATIVE_SUBDIRS(...)

which allows you to list sub-directories, allowed anywhere before the
output bits, and

SJR_OUTPUT_NATIVE_SUBDIRS

which invokes the sub-configure, and should be used after AC_OUTPUT.

 Do you know how to cause the subproject to be ./configured as a truly
 independent project, without passing cached config data as well as options
 from the top level?

I do filter the option list, but most options go through. I think it
might be an idea to map CC_FOR_BUILD to CC etc.

 BTW, the autoconf list bounced me back here :)

Well, they are wrong. :)

   Simon
AC_DEFUN([SJR_CONFIG_NATIVE_SUBDIRS],
[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])]dnl
[AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])]dnl
[m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS],
  _AC_CONFIG_COMPUTE_DEST(], [))])]dnl
[m4_append([_SJR_LIST_NATIVE_SUBDIRS], [$1], [
])]dnl
[AS_LITERAL_IF([$1], [],
   [AC_DIAGNOSE([syntax], [$0: you should use literals])])]dnl
[AC_SUBST([native_subdirs], [$native_subdirs m4_normalize([$1])])])


AC_DEFUN([SJR_OUTPUT_NATIVE_SUBDIRS],
[
if test $no_recursion != yes; then

  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
  # so they do not pile up. Also, set --host to --build
  ac_sub_configure_args=
  ac_prev=
  eval set x $ac_configure_args
  shift
  for ac_arg
  do
case x$ac_prev in
xbuild) ac_arg=--build=$ac_arg; ac_prev= ;;
x) ;;
*) ac_prev=; continue ;;
esac
case $ac_arg in
-cache-file | --cache-file | --cache-fil | --cache-fi \
| --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
  ac_prev=cache_file ;;
-cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
| --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
| --c=*)
  ;;
--config-cache | -C)
  ;;
-srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
  ac_prev=srcdir ;;
-srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
  ;;
-prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
  ac_prev=prefix ;;
-prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
  ;;
--disable-option-checking)
  ;;
--host | --hos | --ho)
  ac_prev=host ;;
--host=* | --hos=* | --ho=*)
  ;;
host_alias=*)
  ;;
--build | --buil | --bui | --bu)
  ac_prev=build ;;
--build=* | --buil=* | --bui=* | --bu=*)
  ac_arg=`AS_ECHO([$ac_arg]) | sed 
s/--bu\(i\(ld\?\)\?\)\?=\(.*\)/--build=\3 --host=\3/`
  AS_VAR_APPEND([ac_sub_configure_args], [ '$ac_arg']) ;;
*)
  case $ac_arg in
  *\'*) ac_arg=`AS_ECHO([$ac_arg]) | sed s/'/'''/g` ;;
  esac
  AS_VAR_APPEND([ac_sub_configure_args], [ '$ac_arg']) ;;
esac
  done

  # Always prepend --prefix to ensure using the same prefix
  # in subdir configurations.
  ac_arg=--prefix=$prefix
  case $ac_arg in
  *\'*) ac_arg=`AS_ECHO([$ac_arg]) | sed s/'/'''/g` ;;
  esac
  ac_sub_configure_args='$ac_arg' $ac_sub_configure_args

  # Pass --silent
  if test $silent = yes; then
ac_sub_configure_args=--silent $ac_sub_configure_args
  fi

  # Always prepend --disable-option-checking to silence warnings, since
  # different subdirs can have different --enable and --with options.
  ac_sub_configure_args=--disable-option-checking $ac_sub_configure_args

  ac_popdir=`pwd`
  for ac_dir in : $native_subdirs; do test x$ac_dir = x:  continue

# Do not complain, so a configure script can configure whichever
# parts of a large source tree are present.
test -d $srcdir/$ac_dir || continue

ac_msg configuring for native build in $ac_dir (`pwd`/$ac_dir)
_AS_ECHO_LOG([$ac_msg])
_AS_ECHO([$ac_msg])
AS_MKDIR_P([$ac_dir])
_AC_SRCDIRS([$ac_dir])

cd $ac_dir

# Check for guested configure; otherwise get Cygnus style configure.
if test -f $ac_srcdir/configure.gnu; then
  ac_sub_configure=$ac_srcdir/configure.gnu
elif test -f $ac_srcdir/configure; then
  ac_sub_configure=$ac_srcdir/configure
elif test -f $ac_srcdir/configure.in; then
  # This should be Cygnus configure.
  ac_sub_configure=$ac_aux_dir/configure
else
  AC_MSG_WARN([no configuration information is in $ac_dir])
  ac_sub_configure=
fi

# The recursion is 

Re: cross-compiling but keeping one target native

2010-05-17 Thread Natalie Tasman
Hello Simon,

I've created a separate configure.ac and Makefile.in for the native
project.  However, when invoking configuration from the top-level
(cross-compiled) project, AC_CONFIG_SUBDIRS passes various options,
including directives to use the top-level cache as well as the --host
cross-compile directive.

Do you know how to cause the subproject to be ./configured as a truly
independent project, without passing cached config data as well as options
from the top level?

BTW, the autoconf list bounced me back here :)

Thanks,

-Natalie

On Sat, May 15, 2010 at 2:26 AM, Simon Richter simon.rich...@hogyros.dewrote:

 Hi,

 On Fri, May 14, 2010 at 03:53:29PM -0700, Natalie Tasman wrote:

  I have one target which is actually a utility used during *build* time.
  Is
  it possible to specify one target which should *not* be built with the
  cross-compiler, but natively instead?

 Not directly. The trick is to have a separate configure script for that
 tool, and have a mechanism in place to configure it differently, usually
 from the toplevel Makefile.

 I agree that it would be nice to have a readymade way for doing that.

  (I'm new to the list; please let me know if this is more appropriate on
 the
  autoconf list).

 It's more related to autoconf than to automake.

   Simon



Re: cross-compiling but keeping one target native

2010-05-15 Thread Simon Richter
Hi,

On Fri, May 14, 2010 at 03:53:29PM -0700, Natalie Tasman wrote:

 I have one target which is actually a utility used during *build* time.  Is
 it possible to specify one target which should *not* be built with the
 cross-compiler, but natively instead?

Not directly. The trick is to have a separate configure script for that
tool, and have a mechanism in place to configure it differently, usually
from the toplevel Makefile.

I agree that it would be nice to have a readymade way for doing that.

 (I'm new to the list; please let me know if this is more appropriate on the
 autoconf list).

It's more related to autoconf than to automake.

   Simon



Re: cross-compiling but keeping one target native

2010-05-15 Thread NightStrike
On Sat, May 15, 2010 at 5:26 AM, Simon Richter simon.rich...@hogyros.de wrote:
 It's more related to autoconf than to automake.

Oops :)

Sorry for replying too quickly on the autoconf list :(