[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Copying files and making directories
From: |
BShah |
Subject: |
RE: Copying files and making directories |
Date: |
Wed, 7 Aug 2002 19:00:52 +0100 |
See inline comments.
In principle, what you ask isn't impossible though I believe a bit of
lateral thinking will apply. The missing bit of information is "why?" - a
bit more of a description of what you are trying to achieve would be useful.
It would help to know which version of gmake you are currently using. I've
supplied what snipnets I can to solve particular issues but they are
probably version 3.79.1 dependant.
<SNIP>
>
>
> I'm working on a project that includes a lot of making directories and
> copying files.
>
> I have the following problems:
> My makefiles are quite large and unwieldy.
> A make run will typically spend time copying already up-to-date files.
> A make run will typically log lots of failed (but ignored)
> calls to 'mkdir'
>
> Writing explicit rules to avoid the last 2 problems would
> make the makefiles
> even bigger.
>
> I think I would like to be able to express the following rules.
>
> 1) To build anything that is a directory, mkdir it.
How do you know what is a directory? If you have a list of directories or
can construct a list, this works quite well:
.PHONY: $(LIST_OF_DIRS)
# the command sequence says - if a directory exists, then do nothing
# else make it. The rule gets execed for each directory.
$(LIST_OF_DIRS):
$(if $(wildcard $@),,mkdir $@)
all: $(LIST_OF_DIRS)
@echo ++ Done creating.
> 2) Anything that is a directory is dependant on its parent directory
Not sure what the purpose of this is.
> 3) This is a generalisation of (2): Anything that has a path
> in its name
> depends on that path, i.e. A/B/foo.c is dependant on A/B/
$(FILE_WITH_PATH): $(dir $(FILE_WITH_PATH))
...
> 4) If A is dependant on B and they have the same filenames
> but different
> paths then A is build by copying B to A
I found it quite tricky to do this as a general case rule. I'm not entirely
sure that its possible in a straight-forward manner. I had a lot of
difficulties with cyclic dependencies with this. More thinking required,
once more information available.
Hope this helps a bit.
B.