Ralf Wildenhues wrote: > Hello Christian, > > * Christian Rössel wrote on Tue, Apr 14, 2009 at 03:20:35PM CEST: >> I have a cross-compile situation where I want to compile sources of a >> subdirectory for the host system as well as for the build system. I pass >> --host, --build and CC_FOR_BUILD to configure. Then I have two >> Makefile.am in distinct subdirectories, one has the statement >> CC=$(CC_FOR_BUILD), the other just uses CC. The rest is identical. >> >> These two Makefile.am reference the same target_SOURCES, but I need to >> have distinct object files. In my setup the Makefile that comes first >> creates the object files (in the directory of the sources) and the other >> Makefile just uses them, hm, not what I intended. >> >> How can I create distinct object files? Is there a way to specify a >> "object-file-directory"? I know that if I specify (the noop) >> target_CFLAGS=$(AM_CFLAGS) in one Makefile.am the object files get >> prefixed. I also can symlink the sources. But is there a better >> solution? > > You could also just not use the subdir-objects option in both of the > directories. This option can be enabled on a per-directory basis. > I haven't tested it, but I think you need to disable it in both of them > so that 'make' will not be confused by an object file lying around in > the same directory as the source, and a suffix rule nearby.
Hi Ralf, removing the subdir-objects option in the AM_INIT_AUTOMAKE macro does the job. Thanks. >> Maybe by modifying OBJEXT and .SUFFIXES? > > I think that would only be asking for more trouble. > > BTW, how do you ensure configure tests are correct for both compilers > without running two configure scripts, or running one of them twice? Hm, good question. We are in the process of modifying an existing autotools framework to meet new requirements. In the existing setup there were some custom m4 scripts that were executed in the cross-compile case (we need cross compilation only on special machines like IBM Blue Gene/P). But replacing them by the standard checks seems to be a good thing. The approach of calling configure twice with different options places an unnecessary burden and source of errors to the user. >From the user's perspective, one call with --host, --build and CC_FOR_BUILD in the cross-compile situation should be sufficient. A scenario to accomplish this could be: configure needs to invoke two nested configures (via AC_CONFIG_SUBDIRS), one for the host-system and one for the build-system. The build-system configure must then set CC=$(CC_FOR_BUILD) and host=build (or call AC_CANONICAL_BUILD and AC_CANONICAL_HOST). Then the usual checks follow. When there is no need for cross-compilation, the top-level configure does not invoke the nested configures which can be done with conditionals. Is this a possible scenario? Cheers, Christian ------------------------------------------------------------------- ------------------------------------------------------------------- Forschungszentrum Jülich GmbH 52425 Jülich Sitz der Gesellschaft: Jülich Eingetragen im Handelsregister des Amtsgerichts Düren Nr. HR B 3498 Vorsitzende des Aufsichtsrats: MinDir'in Bärbel Brumme-Bothe Geschäftsführung: Prof. Dr. Achim Bachem (Vorsitzender), Dr. Ulrich Krafft (stellv. Vorsitzender), Prof. Dr. Harald Bolt, Dr. Sebastian M. Schmidt ------------------------------------------------------------------- -------------------------------------------------------------------
