如何使用单个Makefile定位多个目录? [英] How to target multiple directories with a single Makefile?

查看:180
本文介绍了如何使用单个Makefile定位多个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用GNU Make构建静态html文档的三个不同版本.

I'm using GNU Make to build three different editions of a static html document.

我将Less用作CSS预处理器.

I use Less as a CSS preprocessor.

我的目录结构如下:

Makefile
160x600/style.less
300x250/style.less
728x90/style.less

这是我的Makefile:

This is my Makefile:

LESSC=lessc -x # use -x for debugging

.PHONY: all clean

all: 160x600 300x250 728x90

%.css: %.less
    $(LESSC) $< > $@

160x600: 160x600/style.css
300x250: 300x250/style.css
728x90: 728x90/style.css

clean:
    rm -f 160x600/*.css
    rm -f 300x250/*.css
    rm -f 728x90/*.css

这样,我可以使用make 160x600从style.less构建style.css.

This way, I can use make 160x600 to build style.css from style.less.

但是我不想为每个目录明确列出目标规则.相反,我尝试添加此规则,而不是添加三个特定于目录的规则:

But I don't want to explicitly list a target rule for each directory. Instead, I tried adding this rule instead of the three directory specific ones:

%: %/style.css

但这不起作用.我认为从该示例可以清楚看出我的目标是什么.有没有一种方法可以接受任何目录作为目标,因此我只需要在all:规则中列出目录名称?

But that does not work. I assume it's clear from that example what my goal is. Is there a way to accept any directory as a target, so that I just have to list the directory names in the all: rule?

推荐答案

使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆