1
votes

I have a problem with automake/autoconf. I will show you the layout of my source tree first:

src
------arch
----------avr
--------------i2c.c
-------sys
-----------thread.c

Now my problem. It isn't that hard to fully compile arch/avr/i2c.c and sys/thread.c. But what i actualy want is to compile all my sub directories partialy (with gcc -c) and then link all objects from one subdir together (ld -r) and make a program of of those subdirectory object files when all subdirectories are compiled. Is this possible, and if so, how?

Greetz, Michel

1

1 Answers

5
votes

Automake has no support for ld -r, and I don't think libtool can do it either. The usual setup is to build one static archive per directory, and link the main program with these static archives.

You could have in arch/avr/Makefile.am

noinst_LIBRARIES = libavr.a
libavr_a_SOURCES = i2c.c ...

something similar in sys/, and src/Makefile.am would look like

SUBDIRS = arch sys .
bin_PROGRAMS = foo
foo_SOURCES = main
foo_LDADD = arch/avr/libavr.a sys/libsys.a