automake
[Top][All Lists]
Advanced

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

Re: Specifying include directories for groups of source files


From: William S Fulton
Subject: Re: Specifying include directories for groups of source files
Date: Sat, 14 Dec 2002 16:17:12 +0000
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.1) Gecko/20020826

Alexandre Duret-Lutz wrote:
"William" == William S Fulton <address@hidden> writes:


 William> A question about groups of files in subdirectories. I
 William> would like Automake's generated Makefiles to compile
 William> groups of files using different include directories,
 William> that is, different INCLUDES (AM_CFLAGS) for each
 William> group. Each group is in a different subdirectory. Is
 William> this possible without using the _LIBRARIES or
 William> _LTLIBRARIES primary?

Can't think of any other way.

 William> Motivation: We don't want to use libtool and having a
 William> separate Makefile.am each with its own _LIBRARIES does
 William> not work on all platforms, notably using native
William> Windows compilers.
(This doesn't necessarily require separate Makefile.ams: you can
build the subdir libraries from the parent directory.)

What's wrong with Windows compilers?  Is there anything we could
fix in Automake to make generated Makefiles more portable?

[...]

The problem is that Automake attempts to use ranlib and ar to create a static library. This does not work with MSVC (Microsoft Visual C++). The solution then of course is to use libtool with Automake as libtool knows how to create static libraries with this compiler. Although this is a solution, it is unacceptable to our project, and I suspect many others, as the overhead that libtool introduces is excessive. We don't even want a library, we merely want to compile our .c files into an executable and use different CFLAGS on some of the source files. Perhaps I've overlooked something, but it looks to me as though this is not possible using MSVC and Automake without Libtool.

As for fixing automake,

1) Perhaps Automake merely has a bug when creating static libraries with MSVC, I'm not sure if it is an Automake goal to support this? I'm using Automake 1.7.1, autoconf 2.54 and Cygwin as the 'unix' environment. MSVC's LIB ought to be used instead of ar and ranlib.

2) Perhaps avoiding static libraries altogether will make the Makefiles more portable? Would it be possible to create a new primary which would compile the source files into object files as usual, then instead of creating a static library ala _LIBRARIES from these object files, create a relocatable object. This is possible with the GNU linker using 'ld -r'. An executable is then possible by linking all the relocatable objects. To be considered, this approach would have to be possible across all the various linkers and I don't have a clue if that is possible.

3) Another idea is again to avoid convenience libraries and to fine tune the compilation on a per source file basis. It strikes me that if one wants to fine tune the generated makefiles, then one loses the benefits of using Automake to compile a particular source file. If the compilation of a particular file is overridden using a normal make rule, for example:

foo.o: foo.c
        $(COMPILE) -DMY_DEFINE -c foo.c

it is not clear to me, as I don't have the experience, whether this will mess up the dependency tracking as it overrides all of this generated into the Makefile.in:

.c.o:
@am__fastdepCC_TRUE@    if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCC_TRUE@      -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
@am__fastdepCC_TRUE@    then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
@am__fastdepCC_TRUE@    else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
@am__fastdepCC_TRUE@    fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@       $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@   $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<


Would it not be possible to add in per source file compilation customisation, eg when compiling foo.c have an Automake rule like this:

foo_c_CFLAGS = -DMY_DEFINE

so that it is only added to the compilation of foo.c.

Cheers
William




reply via email to

[Prev in Thread] Current Thread [Next in Thread]