【发布时间】:2019-02-05 17:47:33
【问题描述】:
我需要一个允许我输入 make foo-program 的 Makefile,如果自上次构建以来有任何 foo-program/**/*.hs 文件发生更改,则构建目标(foo-program/.stack-work 中的输出)。
这是我的目录树:
project/
|-bar-other-program/
|-.stack-work/ # Generated output goes here
|-src/
|-BarOtherProgram.hs
|-test/
|-Tests.hs
|-foo-program/
|-.stack-work/ # Generated output goes here
|-src/
|-FooProgram.hs
|-test/
|-Tests.hs
|-notes/ # non-source, so no Make target for this
这是我目前所拥有的:
# evaluates to 'bar-other-program foo-program'
PROGS := $(shell find * -type f -name '*.hs' | cut -d'/' -f1 | uniq)
.SECONDEXPANSION:
$(PROGS): $$(wildcard $$@/src/*.hs) $$(wildcard $$@/test/*.hs)
# do-build $@
当我运行make foo-program时,无论来源是否改变,我都会得到:
make: Nothing to be done for 'foo-program'
更新:我的最终(非抽象)Makefile 可以在on GitHub 找到。请注意,当我写下这个问题时,我的解决方案与我预期的不同。查看那个 Makefile 也可能会让我更清楚我最初的目标。
【问题讨论】: