29 messages in com.perforce.perforce-user[p4] newbie: how do I create empty di...
FromSent OnAttachments
Shackelford, John-Mason04 Mar 2004 09:04 
Noel Yap04 Mar 2004 09:11 
Ivey, William04 Mar 2004 09:16 
Matt Stave04 Mar 2004 09:46 
Ivey, William04 Mar 2004 09:46 
Noel Yap04 Mar 2004 10:15 
Ivey, William04 Mar 2004 10:52 
Gary Sanders04 Mar 2004 11:52 
Noel Yap04 Mar 2004 12:00 
Ivey, William04 Mar 2004 12:13 
Noel Yap04 Mar 2004 12:15 
Noel Yap04 Mar 2004 12:27 
Gary Sanders04 Mar 2004 12:54 
Ivey, William04 Mar 2004 13:00 
Noel Yap04 Mar 2004 13:04 
Gary Sanders04 Mar 2004 13:49 
Williams, Ken04 Mar 2004 13:57.bin
Noel Yap04 Mar 2004 14:04 
Hamish Macdonald04 Mar 2004 14:13 
Ivey, William04 Mar 2004 14:28 
Noel Yap04 Mar 2004 14:28 
Ivey, William04 Mar 2004 14:49 
Doug Palmer04 Mar 2004 15:17 
Ivey, William04 Mar 2004 15:21 
Matt Stave04 Mar 2004 15:28 
Doug Palmer04 Mar 2004 15:39 
jab04 Mar 2004 16:46 
Hamish Macdonald04 Mar 2004 17:21 
Noel Yap05 Mar 2004 04:12 
Subject:[p4] newbie: how do I create empty directories in the depot
From:Noel Yap (Noel@morganstanley.com)
Date:03/04/2004 02:04:10 PM
List:com.perforce.perforce-user

OK. Try: 1. placing test.exe into one of the directories 2. creating another .exe that gets built into the same directory as test.exe 3. removing test.exe 4. rebuilding

Does this new .exe get rebuilt? Should it?

Noel

Gary Sanders wrote:

Noel,

The output from the example below clearly demonstrates that only one invocation is needed to build everything. And BTW... with mkdir -p, there's no need to have a SubDir target by itself.

Using this makefile (purposely avoiding make variables, rules, etc for clarity and demonstration purposes):

all: SubDir/aoeu SubDir/ueoa test.exe

test.exe: test.cpp gcc test.cpp -o test.exe

SubDir/aoeu: mkdir -p $@

SubDir/ueoa: mkdir -p $@

clean: rm -fr SubDir rm -f test.exe

I get these results...

C:\foo>make mkdir -p SubDir/aoeu mkdir -p SubDir/ueoa gcc test.cpp -o test.exe

C:\foo>dir Volume in drive C has no label. Volume Serial Number is 0412-2284

Directory of C:\foo

03/04/2004 01:38 PM <DIR> . 03/04/2004 01:38 PM <DIR> .. 03/04/2004 01:38 PM 189 makefile 03/04/2004 01:38 PM <DIR> SubDir 03/04/2004 01:36 PM 79 test.cpp 03/04/2004 01:38 PM 11,224 test.exe 3 File(s) 11,492 bytes 3 Dir(s) 54,689,808,384 bytes free

C:\foo>test Hello World

C:\foo>touch test.cpp

C:\foo>make gcc test.cpp -o test.exe

C:\foo>

-----Original Message----- From: Noel Yap [mailto:Noel.Yap at morganstanley.com] Sent: Thursday, March 04, 2004 1:04 PM To: Gary Sanders Cc: 'Ivey, William'; Perforce userlist (E-mail) Subject: Re: [p4] newbie: how do I create empty directories in the depot

The "rm -f" in the target actions don't matter.

It's common to want to remove and rebuild just one of the targets. For example:

# GNUmakefile lib/libA.so: | lib/. touch $@

lib/libB.so: | lib/. touch $@

One should be able to remove just one of the targets (eg by using "gmake clean" within the source directory for libA) and not have it cause rebuilds of all the other targets later on. Would you agree?

If you're already using gmake 3.80, I think adding '|' to the rules is a gain with little cost.

Your example below just builds directories (I'm not sure if this was intentional) which implies performing two gmake invocations, once to build the directories, and another to build everything else. IHMO, there's no need to have two invocations unless one doesn't have order rules.

Noel

Gary Sanders wrote:

That's not the way I'm suggesting you do this so I'm not surprised you getting those results.

Try this instead (and move the rm -f into your clean target instead).

all: SubDir/aoeu SubDir/ueoa

SubDir/aoeu: SubDir mkdir -p $@

SubDir/ueoa: SubDir mkdir -p $@

SubDir: mkdir -p $@

Which gives this...

C:\foo>make mkdir -p SubDir mkdir -p SubDir/aoeu mkdir -p SubDir/ueoa

C:\foo>make make: Nothing to be done for `all'.

C:\foo>

-----Original Message----- From: Noel Yap [mailto:Noel.Yap at morganstanley.com] Sent: Thursday, March 04, 2004 12:15 PM To: Gary Sanders Cc: 'Ivey, William'; Perforce userlist (E-mail) Subject: Re: [p4] newbie: how do I create empty directories in the depot

OK, now try something a bit more complicated:

# GNUmakefile all: SubDir/aoeu SubDir/ueoa

SubDir/aoeu: SubDir rm -f $@ && touch $@

SubDir/ueoa: SubDir rm -f $@ && touch $@

SubDir: mkdir -p $@

$ gmake mkdir -p SubDir rm -f SubDir/aoeu && touch SubDir/aoeu rm -f SubDir/ueoa && touch SubDir/ueoa $ rm SubDir/aoeu $ gmake rm -f SubDir/aoeu && touch SubDir/aoeu rm -f SubDir/ueoa && touch SubDir/ueoa

Do you think it's correct behaviour to rebuild SubDir/ueoa? What if there are many targets in SubDir and they all take a while to rebuild?

Noel

Gary Sanders wrote:

I agree with Ivey so long as you make the subdir a proper target and don't just put the mkdir in the rules with something else.

I.e. this works!

makefile...

default: SubDir echo Hello World

SubDir: mkdir SubDir

Output...

C:\foo>rm -fr SubDir

C:\foo>make mkdir SubDir echo Hello World Hello World

C:\foo>make echo Hello World Hello World

-----Original Message----- From: Ivey, William [mailto:william_ivey at bmc.com] Sent: Thursday, March 04, 2004 10:53 AM To: 'Noel.Yap at morganstanley.com'; Ivey, William Cc: Perforce userlist (E-mail) Subject: RE: [p4] newbie: how do I create empty directories in the depot

-----Original Message----- From: Noel Yap [mailto:Noel.Yap at morganstanley.com]

"Ivey, William" wrote:

That's what I did, as well, through our Makefiles, either by adding a mkdir before any command that might fail, or by making the directories a target with a mkdir rule to create them. -Wm

FYI, unless you're using order rules in GNU make (or something similar), the latter is usually not a good idea since the directory's timestamp changes each time a directory element is added or removed.

I'm not sure why that's a problem. Timestamps going forward don't bother it, and, in any case, the worst thing that can happen is it tries to recreate a directory that already exists which does no harm (and isn't even close to being a speed bottleneck - besides, these Makefiles are only invoked once).

I haven't yet found a case where it didn't do the right thing - can you give me a scenario? -Wm