【发布时间】:2011-08-05 03:24:24
【问题描述】:
我想做一个使用 gnumake 或 makepp 运行的 Makefile,它可以打包给定目录下的所有文件:
DIRS:=$(shell find . -mindepth 2 -maxdepth 2 -not -name mp3 -not -name ".*" -type d)
PACKAGES = $(DIRS:%=%.npk)
all: packages
packages: $(PACKAGES)
%.npk: %/*
npack c $@ @^
.PHONY: all packages
问题是依赖项中没有 %/* 这样的东西。 我需要目标(X.npk)依赖于目录 X 中的每个文件,但我不知道在编写 Makefile 时这些文件是什么,因为它们是稍后生成的。
一个例子:
./dirA/x
./dirA/y
./dirB/e
./dirB/f
我想创建 ./dirA.npk (取决于 x,y), ./dirB.npk (e,f) 除了第一行中使用的 find 找到所有目录之外,我对目录或文件一无所知。
【问题讨论】:
-
我试过了:%.npk: $(wildcard %/*) 但这不起作用。我也考虑过 semafor,但遇到了同样的问题,我需要依赖 target_dir/*。