use the easy way.
the maintanance problems of the hard way have no real benefit over doing
some renamings. 

And if there are other reasons that you are not supposed to 
rename something, well, then you could use the rename trick.
this is - you add the following two pattern rules to your makefile

%-coo.c : %.c
        cp $< $@

%-cpp.cpp : %.cpp
        cp $< $@

and make the link target dependent on objects one-coo.o and one-cpp.o!!!!

.... in automake-speak:

lib_LTLIBRARIES = libtest.la 
libtest_la_SOURCES = one-cpp.cpp one-coo.c

%-cpp.cpp : %.cpp
        cp $< $@

%-coo.c : %.c
        cp $< $@

... which will instantly compile with the following configure.in:
AC_INIT(Makefile.am)
AM_INIT_AUTOMAKE(test,1.0)
AC_LANG_C
AC_PROG_CC
AC_PROG_CXX
AM_PROG_LIBTOOL
AC_PROG_INSTALL
AC_OUTPUT(Makefile)


HTH, cheers, Guido

Eric Lemings wrote:
> 
> Hello all,
> 
> Suppose you have the following Makefile.am.
> 
> lib_LTLIBRARIES = libfoo.la
> libfoo_la_SOURCES = \
>     one.c \
>     one.cpp \
>     two.c \
>     two.cpp
> 
> I need the library to contain both the C object files and the C++ object files.  
>There are two ways that I can think of to do
> this: the easy way and the hard way.  The easy way would be two rename either the C 
>or the C++ source files so that they do
> not have the same basename and thus the object files would have different names.
> 
> The hard way would be to add additional variables and rules to Makefile.am so that 
>the object files use different suffixes.
> Suppose you use .co, .clo, .o, and .lo suffixes for the static C object file, shared 
>C object file, static C++ object file,
> and shared C++ object file respectively.  Using the latest versions of Autoconf, 
>Automake, and Libtool, you would first need
> implicit rules to create the .co and .clo files.
> 
> .SUFFIXES: .c .clo .co .lo .o .obj
> 
> .c.co:
>         source='$<' object='$@' libtool=no \
>         depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' \
>         $(CCDEPMODE) $(depcomp) \
>         $(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$< -o $@
> 
> .c.clo:
>         source='$<' object='$@' libtool=yes \
>         depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' \
>         $(CCDEPMODE) $(depcomp) \
>         $(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$< -o $@
> 
> Now you'd have to link the C object files with the new suffixes into the target 
>shared library.
> 
> libfoo_la_COBJECTS = $(libfoo_la_OBJECTS:.lo=.clo)
> 
> libfoo.la: $(libfoo_la_COBJECTS) $(libfoo_la_OBJECTS) $(libfoo_la_DEPENDENCIES)
>         $(LINK) $(libfoo_la_LDFLAGS) $(libfoo_la_COBJECTS) $(libfoo_la_OBJECTS) 
>$(libfoo_la_LIBADD) $(LIBS)
> 
> So how would the static library get built?  Did I get the shared library parts right?
> 
> Thanks,
> Eric.

-- guido                            Edel sei der Mensch, hilfreich und gut
GCS/E/S/P C++$++++ ULHS L++w- N++@ d(+-) s+a- r+@>+++ y++ 5++X- (geekcode)

Reply via email to