Makefile:如果源更改,则重建目标

时间:2016-08-30 14:47:22

标签: makefile gnu-make

我在PHP项目中获得了这个Makefile(这是从完整的Makefile中删除的)。如何更改此设置,以便automake检测到public/assets/styles/main.scss已更改&重新运行sass?

all: public/assets/styles/styles.css

public/assets/styles/styles.css:
    sass public/assets/styles/main.scss > public/assets/styles/styles.css

1 个答案:

答案 0 :(得分:1)

Simply make the .scss file a prerequisite of your .css target. As a bonus, avoid repetition of your base path and use automatic variables to make the recipe less redundant:

STYLEDIR := public/assets/styles

all: $(STYLEDIR)/styles.css

$(STYLEDIR)/styles.css: $(STYLEDIR)/main.scss
    sass $< > $@