Hello, On Thu, Sep 21, 2006 at 04:34:35PM +0200, Ralf Corsepius wrote: > On Thu, 2006-09-21 at 21:36 +0800, Tzu-Chien Chiu wrote: > > I've read configure.ac and Makefile.am of texinfo. Here is how it works. [...]
I'm afraid you have not understood the trick. Perhaps you could try to cross-compile texinfo, watching how the build works. > Normally with autoconf/automake, you need 2 different build-directories, > each individually being configured for one host, because > autoconf/automake only support one host at a time per configure script. > > To be able to support this, you'll need to implement a toptevel > configure script, which configures sub-directories this way. [...] And the trick in Texinfo is based on this, of course. But the native build is performed in a subdirectory of the main build directory. So when cross-compiling, a secondary configure is run from the main one, configuring for a native build. And an Automake conditional (TOOLS_ONLY) is used to limit the native build only to the tools which are needed for the ``bootstrap''. > > [...] When building native tools, the variables CC, AR, and > > RANLIB copied from the their BUILD_* environment variable > > counterparts. Yes. > > The users have to manually set BUILD_CC, BUILD_AR, BUILD_RANLIB before > > running 'configure', right? No. > > I thought there would be AC_PROG_*-like macros for these? The configure.ac contains AC_PROG_CC. When configure is run for a native build, this macro searches for a native C compiler. So when the main configure invokes itself recursively for the build of native tools, this macro finds the native compiler. Actually, the recursive call looks like this: CC="${BUILD_CC}" AR="${BUILD_AR}" RANLIB="${BUILD_RANLIB}" \ ${confdir}/configure --build=${build} --host=${build} But this does not mean tha BUILD_CC has to be set! If BUILD_CC is empty, this just makes CC empty. AC_PROG_CC then does its work. (The variable CC overrides the test only if it is nonempty.) Yes, I agree this is tricky, yet I think this aproach is appropriate for a small project. Have a nice day, Stepan Kasal