3 ms·
I use make's `wildcard`, for example to locate all of my unit tests with the project sources (I don't use a `test` subdir): TEST_SRC = $(wildcard *_test.c)
by lsllc 3y ago
I use make's `wildcard`, for example to locate all of my unit tests with the project sources (I don't use a `test` subdir):
TEST_SRC = $(wildcard *_test.c)
If you follow TFA's guidelines about having a `src` dir, then:
SRC = $(wildcard src/*.c)
And if you need to convert that to a list of matching .o files, `patsubst` is your friend:
OBJ = $(patsubst %.c,%.o,$(SRC))
So now simply dropping a file into the right place (or a unit test ending in _test.c) won't require any makefile changes.
I tend to copy my most recent Makefile into my next project and generally it stays 90% the same (I have to edit a few macro definitions and rules, but not many).