简体   繁体   English

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

[英]Makefile: rebuild target if its source changes

I've got this Makefile in a PHP project (this is trimmed down from the full Makefile). 我已经在一个PHP项目中得到了这个Makefile(这是从完整的Makefile中删减的)。 How can I change this so automake detects that public/assets/styles/main.scss has changed & re-run sass? 如何更改此设置,以便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

Simply make the .scss file a prerequisite of your .css target. 只需将.scss文件作为.css目标的先决条件。 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 $< > $@

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM