Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

automake Adding all c files in a directory

In automake's Makefile.am , the sources of a program is listed like

bin_PROGRAMS = os345v1

os345v1_SOURCES = os345.c os345interrupts.c os345semaphores.c

Instead of specifying individual files, How to add all c files in a specific directory and subdirectory ?

like image 326
nmxprime Avatar asked Nov 19 '25 14:11

nmxprime


1 Answers

it's usually a bad idea to do use wildcards in automake.

for one thing, your automake project might be processed used with a non-GNU make implementation (which might not be able to use GNU-make extensions such as $(wildcard *.c)). One of the strengts of autotools/automake is that it is agnostic of the target systems and their tool-chains.

More importantly, automake might need to actually know exactly which source files you want to be build. This is important for instance when you want to make out-of-source-tree builds (e.g. with the source-code on read-only media, and the builds being "somewhere else): this is a common use-case for distributions (e.g. Debian) that allow to easily build multiple flavours (with different configure flags) from the same source in a single run.

And finally, not using wildcards protects your build against stray source code. E.g. having "foo.c" and a backup-file "foo_old.c" (e.g. because you are re-implementing "foo" and want to have check with the old implementation and want your editor to automatically enable syntax-highlighting) lying around in the same folder, might accidentally build both files resulting in multiple-definitions of the same symbols.

See also the automake documentation why automake does not support wildcards

like image 156
umläute Avatar answered Nov 23 '25 11:11

umläute



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!