Re: cross-compiling but keeping one target native

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Dear Natalie,

Am 5/15/2010 10:52 AM, schrieb Natalie Tasman:
> I'm working on a build system with autotools.  I'd like to 
> cross-compile, building a mingw/windows executable from linux.  So far, 
> my system works well with the --host option (and appropriate cross tools 
> installed, from the mingw-cross-env project.)
> 
> 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?
> 
> I've considered creating a separate config.ac/Makefile.am for this one 
> executable, but am hoping to find a simpler solution.
> 
> (It was suggested that I post here over at the automake list).

I had a similar problem, see e.g.
http://www.mail-archive.com/automake@xxxxxxx/msg14826.html

My solution to the problem was to create a new macro
AC_CONIG_SUBDIR_CUSTOM([path to sub-configure], [your configure
arguments]) based on AC_CONFIG_SUBDIR. As the new macro uses some
autoconf internals I implemented it in autoconf's status.m4. To not
alter the autoconf installation, I put the modified status.m4 in my
AC_CONFIG_MACRO_DIR.

If you call the macro with an empty argument list, it will call the
sub-configure with the top-level --prefix, --disable-option-checking,
--cache-file=/dev/null and the --srcdir option.

To use some of the options provided to the toplevel configure in the
custom sub-configure, I write all user provided configure arguments to
file and process this file in a second step.

Please find attached a patch to be applied on autoconf's 2.65.
status.m4. Hope that helps.

Best regards,
Christian
196c196
< # MODE is `FILES', `HEADERS', `LINKS', `COMMANDS', or `SUBDIRS'.
---
> # MODE is `FILES', `HEADERS', `LINKS', `COMMANDS', `SUBDIRS' or CONFIG_SUBDIR_CUSTOM.
1093c1093
< [m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS],
---
> [m4_map_args_w([$1], [_AC_CONFIG_UNIQUE([SUBDIRS or CONFIG_SUBDIR_CUSTOM],
1101a1102,1135
> # AC_CONFIG_SUBDIR_CUSTOM(DIR, ARGUMENTS [, DISABLE_HELP_RECURSIVE])
> # ------------------------------------------------------------------
> # Build a list custom_subdirs of tuples (DIR, ARGUMENTS) where DIR is
> # unique in _AC_LIST_CUSTOM_SUBDIRS and _AC_LIST_SUBDIRS. This list is used in
> # _AC_OUTPUT_SUBDIRS to invoke nested configures in directory DIR with
> # arguments ARGUMENTS. The arguments are modified as in the AC_CONFIG_SUBDIRS
> # case, see _AC_SUB_CONFIGURE_ARGS. If the third argument
> # DISABLE_HELP_RECURSIVE is given, configure --help=recursive will omit DIR.
> AC_DEFUN([AC_CONFIG_SUBDIR_CUSTOM],
> [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
> AC_REQUIRE([AC_DISABLE_OPTION_CHECKING])dnl
> m4_foreach_w([_AC_Sub], [$1],
> 	     [_AC_CONFIG_UNIQUE([SUBDIRS or CONFIG_SUBDIR_CUSTOM],
> 				m4_bpatsubst(m4_defn([_AC_Sub]), [:.*]))])dnl
> 
> # build a list of (directory,arguments) tuples that will be processed in _AC_OUTPUT_SUBDIRS
> if test -z "$custom_subdirs"; then
>   custom_subdirs="custom_sub_configure_dir=\"m4_normalize([$1])\";custom_sub_configure_args=\"m4_normalize([$2])\""
> else
>   custom_subdirs="$custom_subdirs|custom_sub_configure_dir=\"m4_normalize([$1])\";custom_sub_configure_args=\"m4_normalize([$2])\""
> fi
> 
> # per default, enable --help=recursive in directory $1.
> m4_ifval([$3], 
>          [], 
>          [m4_append([_AC_LIST_SUBDIRS], [$1], [
> ])dnl
> ])dnl
> AS_LITERAL_IF([$1], [],
> 	      [AC_DIAGNOSE([syntax], [$0: you should use literals])])dnl
> AC_SUBST([subdirs_custom], ["$subdirs_custom m4_normalize([$1])"])dnl
> ]) # AC_CONFIG_SUBDIR_CUSTOM
> 
> 
1111a1146,1178
>   ac_popdir=`pwd`
> 
>   # call configures in list $custom_subdirs with directory-specific arguments.
>   OIFS=$IFS
>   IFS='|'
>   list=$custom_subdirs
>   for dir_and_args in $list; do
>     IFS=$OIFS
>     eval $dir_and_args
>     if test "x$custom_sub_configure_dir" = x; then continue; fi
>     ac_custom_sub_configure_args=
>     _AC_SUB_CONFIGURE_ARGS([$custom_sub_configure_args], 
>                            [ac_custom_sub_configure_args])
>     _AC_SUB_CONFIGURE([$custom_sub_configure_dir], 
>                       [$ac_custom_sub_configure_args])
>     cd "$ac_popdir"
>     IFS='|'
>   done
>   IFS=$OIFS  
> 
>   # call configures in $subdirs with fixed arguments.
>   ac_sub_configure_args=
>   _AC_SUB_CONFIGURE_ARGS([$ac_configure_args], 
>                          [ac_sub_configure_args])
>   for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
>      echo "ac_dir(inside): $ac_dir"
>     _AC_SUB_CONFIGURE([$ac_dir], 
>                       [$ac_sub_configure_args])
>     cd "$ac_popdir"
>   done
> fi
> ])# _AC_OUTPUT_SUBDIRS
> 
1112a1180,1184
> # _AC_SUB_CONFIGURE_ARGS(ARGUMENTS_IN, ARGUMENTS_OUT)
> # ---------------------------------------------------
> # Create ARGUMENTS_OUT from ARGUMENTS_IN for use in nested configure calls.
> m4_define([_AC_SUB_CONFIGURE_ARGS],
> [
1117c1189
<   eval "set x $ac_configure_args"
---
>   eval "set x $1"
1149c1221,1223
<       AS_VAR_APPEND([ac_sub_configure_args], [" '$ac_arg'"]) ;;
---
>       #AS_VAR_APPEND([ac_sub_configure_args], [" '$ac_arg'"]) ;;
>       #AS_VAR_APPEND([$$2], [" '$ac_arg'"]) ;;
>       AS_VAR_APPEND([$2], [" '$ac_arg'"]) ;;
1159c1233
<   ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
---
>   $2="'$ac_arg' $$2"
1163c1237
<     ac_sub_configure_args="--silent $ac_sub_configure_args"
---
>     $2="--silent $$2"
1168,1171c1242,1243
<   ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
< 
<   ac_popdir=`pwd`
<   for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
---
>   $2="--disable-option-checking $$2"
> ])# _AC_SUB_CONFIGURE_ARGS
1173,1196d1244
<     # 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 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
1198,1205c1246,1252
<     # The recursion is here.
<     if test -n "$ac_sub_configure"; then
<       # Make the cache file name correct relative to the subdirectory.
<       case $cache_file in
<       [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
<       *) # Relative name.
< 	ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
<       esac
---
> # _AC_SUB_CONFIGURE(DIR, ARGUMENTS)
> # ---------------------------------
> # Call nested configure in DIR with arguments ARGUMENTS.
> m4_define([_AC_SUB_CONFIGURE],
> [
>   sub_configure_dir=$1
>   sub_configure_args=$2
1207,1212c1254,1277
<       AC_MSG_NOTICE([running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
<       # The eval makes quoting arguments work.
<       eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
< 	   --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
< 	AC_MSG_ERROR([$ac_sub_configure failed for $ac_dir])
<     fi
---
>   # Do not complain, so a configure script can configure whichever
>   # parts of a large source tree are present.
>   test -d "$srcdir/$sub_configure_dir" || continue
> 
>   ac_msg="=== configuring in $sub_configure_dir (`pwd`/$sub_configure_dir)"
>   _AS_ECHO_LOG([$ac_msg])
>   _AS_ECHO([$ac_msg])
>   AS_MKDIR_P(["$sub_configure_dir"])
>   _AC_SRCDIRS(["$sub_configure_dir"])
> 
>   cd "$sub_configure_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 $sub_configure_dir])
>     ac_sub_configure=
>   fi
1214,1217c1279,1286
<     cd "$ac_popdir"
<   done
< fi
< ])# _AC_OUTPUT_SUBDIRS
---
>   # The recursion is here.
>   if test -n "$ac_sub_configure"; then
>     # Make the cache file name correct relative to the subdirectory.
>     case $cache_file in
>     [[\\/]]* | ?:[[\\/]]* ) ac_sub_cache_file=$cache_file ;;
>     *) # Relative name.
>       ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
>     esac
1218a1288,1294
>     AC_MSG_NOTICE([running $SHELL $ac_sub_configure $sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir])
>     # The eval makes quoting arguments work.
>     eval "\$SHELL \"\$ac_sub_configure\" $sub_configure_args \
> 	 --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
>       AC_MSG_ERROR([$ac_sub_configure failed for $sub_configure_dir])
>   fi
> ])# _AC_SUB_CONFIGURE
1300c1376,1379
< AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIRS], [_AC_OUTPUT_SUBDIRS()])dnl
---
> AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIRS], 
>                   [_AC_OUTPUT_SUBDIRS()],
>                   [AC_PROVIDE_IFELSE([AC_CONFIG_SUBDIR_CUSTOM],
>                                      [_AC_OUTPUT_SUBDIRS()])])dnl
_______________________________________________
Autoconf mailing list
Autoconf@xxxxxxx
http://lists.gnu.org/mailman/listinfo/autoconf

[Index of Archives]     [GCC Help]     [Kernel Discussion]     [RPM Discussion]     [Red Hat Development]     [Yosemite News]     [Linux USB]     [Samba]

  Powered by Linux