help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to specify a dependence on a directory?


From: Peng Yu
Subject: Re: How to specify a dependence on a directory?
Date: Sun, 10 Jan 2010 10:22:37 -0600

On Mon, Nov 23, 2009 at 11:01 PM, Paul Smith <address@hidden> wrote:
> On Fri, 2009-11-20 at 22:10 -0600, Peng Yu wrote:
>> I want the rule to run if there is no such a directory, or there are
>> no files in the directory, or there is any file that is older than the
>> dependent files.
>
> What I suggested should work since if there is no directory the wildcard
> will be empty as well.

The code that you suggested is not working properly, when make is
called the second time. Would you please take a look at how to fix it?

$ cat print.sh
echo \$make clean
make clean
echo \$make
make
echo \$ls -lgo
ls -lgo
echo \$make
make
echo \$ls -lgo
ls -lgo

$ cat command.sh
#!/usr/bin/env bash

mkdir -p somedir

echo in command.sh
for f in a b c d e f;
do
  sleep .1
  touch somedir/$f.txt
done


$ cat Makefile
TXT_FILES:=$(wildcard somedir/*.txt)

ifeq ($(TXT_FILES),)
.PHONY: all
endif

.PHONY: clean

all: $(TXT_FILES)
        ./command.sh

clean:
        @$(RM) -rf somedir


$ ./print.sh
$make clean
$make
./command.sh
in command.sh
$ls -lgo
total 12
-rwx------ 1 122 2010-01-10 10:06 command.sh
-rw------- 1 159 2010-01-10 10:14 Makefile
-rwx------ 1 109 2010-01-10 10:16 print.sh
drwx------ 2  78 2010-01-10 10:16 somedir
$make   # I do not expect command.sh should be called here, because
all *.txt is newer than command.sh
./command.sh
in command.sh
$ls -lgo
total 12
-rwx------ 1 122 2010-01-10 10:06 command.sh
-rw------- 1 159 2010-01-10 10:14 Makefile
-rwx------ 1 109 2010-01-10 10:16 print.sh
drwx------ 2  78 2010-01-10 10:16 somedir




reply via email to

[Prev in Thread] Current Thread [Next in Thread]