Makefile中的文件夹目标阻止其他目标运行

时间:2016-01-30 08:40:43

标签: makefile

我有一个简单的makefile,它通过将资源从〜/ static_source移动到〜/ static来负责构建我的网站。但是,当我将我的Javascript文件夹添加到makefile时,我的HTML和CSS停止编译!当我注释掉JS块时,我的HTML和CSS再次编译。

错误版

LESS = $(wildcard static_source/styles/*.less)
CSS = $(patsubst static_source/%.less,static/%.css,$(LESS))
static/styles/%.css: static_source/styles/%.less static_source/styles/base.less static_source/styles/header.less
    lessc $< $@

HTML = $(patsubst static_source/%,static/%,$(wildcard static_source/*.html))
static/%.html: static_source/%.html
    ln -s ../$< $@

#This stops CSS and HTML from running. Perhaps it's because static/scripts is a folder?
JS = static/scripts
static/scripts: static_source/scripts
    ln -s ../$< $@


all: $(CSS) $(HTML)

好版本:

LESS = $(wildcard static_source/styles/*.less)
CSS = $(patsubst static_source/%.less,static/%.css,$(LESS))
static/styles/%.css: static_source/styles/%.less static_source/styles/base.less static_source/styles/header.less
    lessc $< $@

HTML = $(patsubst static_source/%,static/%,$(wildcard static_source/*.html))
static/%.html: static_source/%.html
    ln -s ../$< $@

#This stops CSS and HTML from running. Perhaps it's because static/scripts is a folder?
JS = static/scripts
#static/scripts: static_source/scripts
#   ln -s ../$< $@


all: $(CSS) $(HTML)

我不知道为什么使用&#34; bad&#34;创建脚本文件夹?版本(不依赖于它),或静态/脚本规则阻止创建HTML和CSS的原因。

从第二次运行开始,坏版本的唯一输出是&#34; make:&#39; static / scripts&#39;是最新的。&#34;好的版本的输出,从第二次运行开始,是&#34; make:没有什么可以为所有&#39;。&#39;。&#34;

1 个答案:

答案 0 :(得分:0)

啊,kill适用 - 似乎make使用第一个&#34; plain&#34;规则作为默认值。因此,在这种情况下,首先是static / scripts,修复方法是将all全部设置为默认规则。前置:

.DEFAULT_GOAL := all
相关问题