automake
[Top][All Lists]
Advanced

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

Need help with problem...


From: Eric Lemings
Subject: Need help with problem...
Date: Tue, 25 Sep 2001 14:49:10 -0600

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.


reply via email to

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