Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C Makefile中的测试命令_C_Makefile - Fatal编程技术网

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

我已经用C写了一些函数,我想用一个Makefile编译它们

在编译之前,我想用另一个命令对它们进行测试,然后仅当它们通过测试时才编译它们

我在想什么:

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