Reputation: 21
i have a directory structure as
src
\__lib_foo
| \__ foo.c foo.h
\__ main
\__ main.c main.h
the main is the main application and main.c uses some function defined in foo.c. The requirement for me is "lib_foo must be compiled but not distributed"..how can i achieve this??
Thanks in advance
Upvotes: 1
Views: 277
Reputation: 212238
The autotools provide a framework for distributing source code, not compiled products. If that is your question, you can easily use an autotooled project to construct a binary package (rpm, deb, pkg, etc.) and distribute that. On the other hand, if you are merely looking for a way to use foo.c to construct a convenience library that main is statically linked against during the build, then (assuming you are using automake) you want to do put this in Makefile.am:
bin_PROGRAMS= main noinst_LIBRARIES = libfoo.a libfoo_a_SOURCES = foo.c
If you change the name of foo.c to libfoo.c, the third line is not needed.
--EDIT after the question was edited to display a non-flat directory structure--
If you do not have foo.c and main.c in the same directory, there is a bit more work involved. In toplevel/Makefile.am:
# You must list lib_foo first SUBDIRS = lib_foo main
in lib_foo/Makefile.am
noinst_LIBRARIES = libfoo.a libfoo_a_SOURCES = foo.c
and in main/Makefile.am
bin_PROGRAMS = main main_LDADD = ../lib_foo/libfoo.a
Upvotes: 3
Reputation: 10551
Compiled programs are never distributed, but the source to compiled programs is of course generally distributed. (There would not be much point in a source distribution without source, would it.) There is also nodist_*_SOURCES
(cf. chapter 14.2 Fine-grained Distribution Control in the automake manual). Also note that BUILT_SOURCES
is nodist by default unless overriden, e.g.
bin_PROGRAMS = foo
nodist_foo_SOURCES = foo.c
BUILT_SOURCES = foo.c
but:
bin_PROGRAMS = foo
foo_SOURCES = foo.c
BUILT_SOURCES = foo.h
Upvotes: 1