C Makefile中的测试命令
我已经用C写了一些函数,我想用一个Makefile编译它们 在编译之前,我想用另一个命令对它们进行测试,然后仅当它们通过测试时才编译它们 我在想什么:C Makefile中的测试命令,c,makefile,C,Makefile,我已经用C写了一些函数,我想用一个Makefile编译它们 在编译之前,我想用另一个命令对它们进行测试,然后仅当它们通过测试时才编译它们 我在想什么: tests : gcc tests.c all : tests gcc *.c 我想编译tests.c,然后如果它们可以编译所有函数 我该怎么做?非常感谢您仅在测试通过后才能构建realproduct的一般大纲: all: realproduct realproduct: | run-tests run-tests: tests
tests :
gcc tests.c
all : tests
gcc *.c
我想编译tests.c,然后如果它们可以编译所有函数
我该怎么做?非常感谢您仅在测试通过后才能构建
realproduct
的一般大纲:
all: realproduct
realproduct: | run-tests
run-tests: tests
./$<
最后,您可以使用确保始终运行某些命令,而不仅仅是在依赖项发生更改时
$ make
cc tests.c -o tests
./tests
cc realproduct.c -o realproduct