Automake is not designed to produce object. It will build either programs or libraries.
It's hard to answer your question without knowing why you'd want to compile a single object file and not something else. Maybe there is a cleaner answer to your "real" problem.
A Makefile.am
you could write is
noinst_LIBRARIES = libThread.a
libThread_a_SOURCES = Thread.cc Thread.h # No need to put headers in EXTRA_DIST
The resulting Makefile
would build a library libThread.a
containing only libThread.o
, ans because *.a
libraries are just a collection of object files there is no linking involved.
The above Makefile.am
also causes the emitted Makefile
to contain rules to compile libThread.o
, so you can add a build:
rule if you like.
If you really want Automake to emit this compile rule, but not build the library, you could go with
EXTRA_LIBRARIES = libThread.a # EXTRA here means "output build rules but don't
# build unless something depends on it".
libThread_a_SOURCES = Thread.cc Thread.h
build: Thread.$(OBJEXT)
Now you are explicitely requiring the file Thread.$(OBJEXT)
to be built only when you type make build
, as in your original Makefile
.
(Automake uses .$(OBJEXT)
rather than .o
to support extensions like .obj
in DOS variants.)