[Top][All Lists]

[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 15:16:21 -0600

On Sun, Jan 10, 2010 at 2:59 PM, Peng Yu <address@hidden> wrote:
> On Sun, Jan 10, 2010 at 11:02 AM, Paul Smith <address@hidden> wrote:
>> On Sun, 2010-01-10 at 10:22 -0600, Peng Yu wrote:
>>> 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 Makefile
>>> TXT_FILES:=$(wildcard somedir/*.txt)
>>> ifeq ($(TXT_FILES),)
>>> .PHONY: all
>>> endif
>>> .PHONY: clean
>>> all: $(TXT_FILES)
>>>       ./
>>> $make   # I do not expect should be called here, because
>>> all *.txt is newer than
>> ?!?!  What does whether the text files are newer than have to
>> do with anything?
> I don't understand how to adapt your following code segment. Would you
> please be explicit on how to use your code in my problem?
>     FILES := $(wildcard somedir/*)
>       ifeq ($(FILES),)
>       .PHONY: target
>       endif
>       target: $(FILES)
>               somecommand

The solution that I found is the following. But there is a caveat that
if I stop 'make' (say be ctrl-C) at the first time when it is running
(not all txt files are generated). When I rerun 'make', it will not
call to generate all the txt files. You might have a more
concise and correct solution.

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

.PHONY: all

ifeq ($(TXT_FILES),)

all: ./


all: $(TXT_FILES)

$(TXT_FILES): ./


.PHONY: clean

        @$(RM) -rf somedir

>> Your makefile shows that the target "all" depends on the text files, so
>> the only thing make cares about is whether any of the text files are
>> newer than "all".  Make doesn't know ANYTHING about
>> If you don't want the command to be run when the text files haven't been
>> changed then you to be sure the file "all" exists with a timestamp newer
>> than the text files.  Or, change your rules.
>> --
>> -------------------------------------------------------------------------------
>>  Paul D. Smith <address@hidden>          Find some GNU make tips at:
>>  "Please remain calm...I may be mad, but I am a professional." --Mad 
>> Scientist
>> _______________________________________________
>> Help-make mailing list
>> address@hidden

reply via email to

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