【发布时间】:2020-01-16 10:25:45
【问题描述】:
我想在我的项目中为每个名为“test”的目录创建单独的可执行文件。测试目录的结构如下: 测试.mk
test (dir)
|__test.mk
|__testRun.c
|__testRun.h
test.mk 包含特定测试的依赖项,testRun.c 是测试本身。
所以层次结构是这样的:
ROOT
|__Makefile
|__Module1 (dir)
|__some files
|__test (dir)
|__Module2 (dir)
|__some files
|__test (dir)
|__Module3 (dir)
|__some files
|__test (dir)
|__outdir (dir)
|__test1 (exec)
|__test2 (exec)
|__test3 (exec)
我想在根父目录中运行单个 Makefile。我希望它搜索所有test 目录并在outdirectory 中创建测试可执行文件。到目前为止,我有这个:
生成文件
CFLAGS = -I$(DIRTEST) -I$(DIRTEST)/..
OUTDIR= ./outdirectory
DIRTEST = $(shell find -type d -not -path "$(OUTDIR)/*" -name "test" -prune )
我不知道如何创建从不同目录的源和标头创建目标可执行文件的规则。我一直在寻找类似问题的解决方案,但到目前为止还没有运气。
注意:我不想使用递归 make。 test.mk 看起来像这样:
SRCTEST = module1/test/testRun.c \
module1/module1.c
CFLAGS += -Imodule1
【问题讨论】: